|
|
||
Inderjeet Singh's Blog
«Improving support for generics in the Java Persistence API |
Main
| Can GroupThink result in poor decision making in strong open-source communities? »
Fortifying Web 2.0 Pet StorePosted by inder on January 08, 2007 at 01:11 PM | Comments (0)Folks at FortifySoftware are running a program where they run their static analysis tool for code checking and security analysis for free on open-source projects. They were kind enough to run their tool on our Web 2.0 Pet Store application and report bugs to us. In this blog, I share my experiences with some of the subtle errors that their tool caught. Some of the bugs that fortify reported were spurious because, presumably, the tool doesn't know about Java EE 5 annotations yet. For example, it failed to notice the following dependency injection:
The tool reported the above statement as uninitialized variable that may result in a null pointer exception or cause other errors. But since this code belongs to a Java EE managed component, the container will initialize the The next bug is something we all know academically, but sometimes run into because of oversight. This has to do with integer division when the two operands are roughly of the same magnitude. The result can contain significant value in the fraction, so it is a good idea to store it in a
However, there is a bug in the above code that fortify caught: In line 3, both The solution, of course, is to cast one of the elements to
Lesson re-learnt. That brings us to the final type of bug that fortify reported. This relates to cross-side scripting attacks. Essentially, in the petstore we were using some user-submitted data without first validating it. Here is an example:
In this code, we are using the value of the user-submitted paramater Needless to say that we have fixed most of these bugs in the petstore application, and intend to fix the remaining ones soon as well. What are your thoughts on a tool like Fortify? Have you run into similar silly bugs as well? Share your experiences as comments to this blog. Thanks for reading. Bookmark blog post: CommentsComments are listed in date ascending order (oldest first) | Post Comment | ||
|
|