This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Found security vulnerability when application is scanned .
While scanning the application, they are passing diff values for TRANS_CD, due to these invalid values , system thorwing exception , how can we restrict this ?
16 Apr 2013 16:58:58,105 [SocketListener0-7] ERROR com.xelus.solos.trans.TransRunner - Object Not In Db Exception
com.xelus.solos.persistent.ObjectNotInDbException: TransactionMap could not be found in the database with key of TRANS_CD = [DISPLAY_1C_SELECTION' OR] at com.xelus.solos.persistent.TransactionMap.loadByTransCd(Unknown Source)
16 Apr 2013 16:59:09,970 [SocketListener0-7] ERROR com.xelus.solos.trans.TransRunner - Object Not In Db Exception
com.xelus.solos.persistent.ObjectNotInDbException: TransactionMap could not be found in the database with key of TRANS_CD = [DISPLAY_1C_SELECTION' AND 5=5 OR 's'='0] at com.xelus.solos.persistent.TransactionMap.loadByTransCd(Unknown Source)
at com.xelus.solos.trans.TransRunner.execute(Unknown Source)
That's not cross site request forgery. It looks like they were trying to do SQL Injection. And failed since that code protects against SQL Injection. If you don't want to throw ane xception on error, you can catch the exception. It is a good idea to not be showing the user a stack trace. But it's not cross site request forgery.
Actually it is an attempted SQL injection attack. You obviously cannot prevent such attempts, you can only make sure they fail - which they did. "Preventing SQL injection" usually means exactly that - making sure the attacker won't gain unauthorized access using SQL injection. If you weren't using prepared statements (nor had escaped the inputs properly, but it is a lot of unnecessary work), the attacker might perhaps execute some unauthorized statements in the database.
The SQL injection attacks is based on entering invalid inputs to the application. Obviously that causes errors in the application. You can handle these errors one way or another - you might, for example, check that the user input corresponds to an expected format, but sometimes that could be hard. I don't think relying on an exception being thrown is a bad solution, assuming you don't show the exception details to the end user.
author & internet detective