Multiple choice technology security

Identify the Vulnerable Line # in the below code: 1 ... 2 public static Connection getConnection() 3 { 4 Connection con = null; 5 try 6 { 7 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 8 con = DriverManager.getConnection("jdbc:odbc:Lookup","admin","admin"); 9 10 }catch (ClassNotFoundException e) 11 { 12 if(con!=null) 13 close(con); 14 log.debug(“Error Occurred:” + e); 15 16 } catch(SQLException ex) 17 { 18 19 if(con!=null) 20 close(con); 21 log.debug(“Error Occurred:” + ex); 22 } 23 return con; 24 } 25 ...

  1. Line # 4

  2. Line # 13 & 20

  3. Line # 7 & 8

  4. None of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Lines 7 and 8 contain hardcoded database credentials ('admin'/'admin') and use an outdated, insecure JDBC-ODBC bridge driver, presenting a significant security vulnerability.

AI explanation

To identify the vulnerable line in the given code, we need to understand what vulnerability we are looking for.

In this case, the code is establishing a database connection using JDBC. The vulnerability we are looking for is an SQL injection vulnerability, where an attacker can manipulate the SQL query being executed.

Looking at the code, we can see that the SQL query is being constructed in line #8 using a hardcoded username and password. This can be a potential vulnerability if the username and password are not properly validated or sanitized.

Therefore, the vulnerable lines in the code are Line #7 and Line #8.

The correct answer is C) Line #7 and Line #8.