diff --git a/src/main/java/servlets/module/challenge/SqlInjectionStoredProcedure.java b/src/main/java/servlets/module/challenge/SqlInjectionStoredProcedure.java index 9e7890770..69e1f5e89 100644 --- a/src/main/java/servlets/module/challenge/SqlInjectionStoredProcedure.java +++ b/src/main/java/servlets/module/challenge/SqlInjectionStoredProcedure.java @@ -3,10 +3,10 @@ import dbProcs.Database; import java.io.IOException; import java.io.PrintWriter; +import java.sql.CallableStatement; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; -import java.sql.Statement; import java.util.Locale; import java.util.ResourceBundle; import javax.servlet.ServletException; @@ -75,13 +75,6 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) log.debug("User Submitted - " + userIdentity); String ApplicationRoot = getServletContext().getRealPath(""); - log.debug("Getting Connection to Database"); - Connection conn = - Database.getChallengeConnection(ApplicationRoot, "SqlChallengeStoredProc"); - // CallableStatement callstmt = conn.prepareCall("CALL findUser('" + userIdentity + "');"); - Statement stmt = conn.createStatement(); - ResultSet resultSet = stmt.executeQuery("CALL findUser('" + userIdentity + "');"); - int i = 0; htmlOutput = "
" + bundle.getString("response.noResults") + "
"; } } catch (SQLException e) { - log.debug("SQL Error caught - " + e.toString()); - htmlOutput += - "" - + errors.getString("error.detected") - + "
" - + "" - + Encode.forHtml(e.toString()) - + "
"; + // Report only the generic localized error to the caller - echoing the driver's own + // exception text (e.g. column/table names, driver/connection identifiers) back to an + // attacker is itself an information leak that helps refine further injection attempts. + // The full detail still goes to the server log for debugging. + log.error("SQL Error caught - " + e.toString()); + htmlOutput += "" + errors.getString("error.detected") + "
"; } catch (Exception e) { out.write(errors.getString("error.funky")); log.fatal(levelName + " - " + e.toString());