I am planing to develop a web application using Spring MVC and trying to figure out which is the best library to use to over come Top 10 OWASP issue. I came to see two HDIV and ESAPI, can any one please help me to understand the difference between them.
Thank you for your help.
Well first and foremost, OWASP's ESAPI is no longer a flagship product for OWASP anymore: major development work on the library stagnated and the 2.1 release was just to fix a major CVE. Looks like regular contributions go into the HDIV library. HDIV also has copious resources demonstrating how to integrate it into common web frameworks--their documentation covers Spring, Grails, and of course it started with Struts1 and Struts2.
HDIV provides a powerpoint that talks about its architecture. Though I really don't like that it says it eliminates XSS (it doesn't, and cannot) the basic architecture looks pretty good.
The only thing IMHO that HDIV appears to be missing when searching the documentation is a method of canonicalization-as-intrusion-detection. In theory, because its relying on hashes taken on non-editable data, you are getting a warning that someone tried to possibly tamper with your parameters. However, with esapi, it will detect muliple encoding attacks and inform you accordingly--it gives you better information. (Parameter name, user Id, and the attempted input.)
Also HDIV doesn't appear to have several features that ESAPI provides:
validation.properties
.First of all I think the approach and scope of both web application security frameworks is different. In some of the aspects they can be also complementary solutions that can be used together.
Regarding the approach, HDIV tries to automate security best practices through the integration with web frameworks. In order to implement this approach, HDIV has been integrated within some of the most used Java/JVM web frameworks such as: Spring MVC, Grails, JSF, Struts 1, Struts 2. It’s important to note that if your application uses web frameworks tags to render links and forms, HDIV does not require any change within the source code, just a declarative configuration (XML or Java config based configuration).
On the other hand, ESAPI offers a number of utilities (APIs) that developers must use within their source code. In other words, the programmer has to include manually all this utilities in their source code. ESAPI is not web framework dependent and can be used in any web application because it's not integrated with web frameworks.
Regarding the scope, HDIV does not cover some of the features offered by ESAPI and also is limited to the supported web frameworks. It's important to note that some of these features are already covered by web frameworks (Struts, Spring MVC,...) or by solutions like Spring Security:
HDIV was designed as a complement to the security features offered by Java EE, Spring Security and web frameworks.
In order to understand more deeply the differences between HDIV and ESAPI I will try to compare the features to cover OWASP top ten web risks with both frameworks. I have included the features included within ESAPI 2.x and ESAPI 3.x at github (https://github.com/ESAPI).
A1- Injection:
A2-Broken Authentication and Session Management:
A3-XSS: the same as A1 but in that case to avoid XSS risks.
A4-Insecure Direct Object References:
(http://www.jtmelton.com/2010/05/10/the-owasp-top-ten-and-esapi-part-5-insecure-direct-object-reference/). This feature is included within ESAPI 2.x but I haven’t found within ESAPI 3.x.
A5-Security misconfiguration:
A6-Sensitive Data Exposure:
A7-Missing Function Level Access Control :
A8-Cross-Site Request Forgery (CSRF):
A9-Using components with known vulnerabilities:
A10-Unvalidated redirects and forwards: This vulnerability is mainly related to the manipulation of non editable data or data generated previously at server side and it’s very similar to A4.
Roberto Velasco Sarasola (HDIV team)