OWASP Enterprise Security API (ESAPI)
ESAPI (The OWASP Enterprise Security API) is a free, open source, web application security control library that makes it easier for programmers to write lower-risk applications. The ESAPI libraries are designed to make it easier for programmers to retrofit security into existing applications. The ESAPI libraries also serve as a solid foundation for new development.
Allowing for language-specific differences, all OWASP ESAPI versions have the same basic design:
- There is a set of security control interfaces. They define for example types of parameters that are passed to types of security controls.
- There is a reference implementation for each security control. The logic is not organization‐specific and the logic is not application‐specific. An example: string‐based input validation. (Note that some of the reference implementations are simply “toy” examples to illustrate how to implement a specific interface [e.g., ESAPI for Java’s
org.owasp.esapi.reference.FileBasedAuthenticator] whereas others are full-fledged enterprise ready reference implementations [e.g.,
- There are optionally your own implementations for each security control. There may be application logic contained in these classes which may be developed by or for your organization. An example: enterprise authentication.
What I did with ESAPI
I used ESAPI for Java with Google AppEngine. I used it for simple validation and encoding. –Jeff
I used ESAPI for PHP with a custom web 2.0 corporate knowledge management application, made up of many open source and commercial applications integrated to work together. I added an organization- and application-specific “Adapter” control to wrap calls to the other ESAPI controls. –Mike
I used ESAPI for Java’s “Logger” control to make it easier for a US Government customer to meet C\&A requirements. –Dave
I used ESAPI for Java to build a low risk web application that was over 250,000+ lines of code in size. –Jim
I used ESAPI for Java’s “Authenticator” to replace a spaghetti-like mechanism in a legacy financial services web application. In hindsight I should have used the application-specific “Adapter” pattern mentioned by Mike above. The organization also uses the ESAPI Encryptor as an interface to a hardware security module. –Roman
I use ESAPI to be our security package for all our product, this way we can set one standard for all products. –Yair
I use ESAPI for Java to educate developers about application security principals at several of the world’s largest organizations. –Jim
Should I use ESAPI?
[NOTE: The heretical opinions on this ESAPI tab are 100% my own and do not necessarily reflect the rest of other ESAPI contributors or the OWASP staff, leadership, community. –kevin wall]
Or, specifically, “Should I use ESAPI for Java?” since that’s the only one run by OWASP that still shows any semblance of life. Maintenance activities is down, way down in fact of its peak development activities. Some of us are still trying and haven’t given up and volunteers are still welcome. But without active contributors, projects make slow progress.
The first question to ask is, are you already using ESAPI in your project, and if so, do you have a lot vested in it? If so, then the answer to “Should I use ESAPI?” probably is “yes”. The second question you should ask, if I’m using it, why am I not contributing to it in some manner? But we won’t go there.
If you are starting out on a new project or trying for the first time to secure an existing project, then before you consider ESAPI, you should consider these possible alternatives:
- Output encoding: OWASP Java Encoder Project
- General HTML sanitization: OWASP Java HTML Sanitizer
- Validation: JSR-303/JSR-349 Bean Validation
- Strong cryptography: Google Tink, Keyczar
- Authentication / authorization: Apache Shiro
- CSRF protection: OWASP CSRFGuard Project or OWASP CSRFProtector Project
Note that this is not to suggest that ESAPI is dead, but rather to acknowledge the fact that it isn’t being as well-maintained as most F500 companies would like for their enterprise software. There may be alternatives, such as companies that you can purchase ESAPI support from. Those are not being considered here for various reasons, not the least of which is to remain vendor neutral. Rather, instead these recommendations should be taken as possible alternatives to secure your application. It is not a perfect world that we live in, but I would be remiss as an appsec guy if I were to plug ESAPI over other good security solutions simply because of my contributions to / involvement with ESAPI. I think that ESAPI has it’s place and I will do my best to maintain it, but not to the exclusion of my family or day job. If you would like to volunteer to help, you know where to find me.
- adapter - There are optionally your own implementations for each security control. There may be application logic contained in these classes which may be developed by or for your organization. The logic may be organization-specific and/or application-specific. There may be proprietary information or logic contained in these classes which may be developed by or for your organization.
- built-in singleton design pattern - The “built-in” singleton design pattern refers to the replacement of security control reference implementations with your own implementations. ESAPI interfaces are otherwise left intact.
- codec - ESAPI encoder/decoder reference implementations.
- core - The ESAPI interfaces and reference implementations that are not intended to be replaced with enterprise-specific versions are called the ESAPI Core.
- exception - ESAPI exception reference implementations.
- extended factory design pattern - The “extended” factory design pattern refers to the addition of a new security control interface and corresponding implementation, which in turn calls ESAPI security control reference implementations and/or security control reference implementations that were replaced with your own implementations. The ESAPI locator class would be called in order to retrieve a singleton instance of your new security control, which in turn would call ESAPI security control reference implementations and/or security control reference implementations that were replaced with your own implementations.
- extended singleton design pattern - The “extended” singleton pattern refers to the replacement of security control reference implementations with your own implementations and the addition/modification/subtraction of corresponding security control interfaces.
- ES-enable (or ESAPI-enable) - Just as web applications and web services can be Public Key Infrastructure (PKI) enabled (PK-enabled) to perform for example certificate-based authentication, applications and services can be OWASP ESAPI-enabled (ES-enabled) to enable applications and services to protect themselves from attackers.
- filter - In ESAPI for Java, there is additionally an HTTP filter that can be called separately from the other controls.
- interfaces - There is a set of security control interfaces. There is no application logic contained in these interfaces. They define for example types of parameters that are passed to types of security controls. There is no proprietary information or logic contained in these interfaces.
- locator - The ESAPI security control interfaces include an “ESAPI” class that is commonly referred to as a “locator” class. The ESAPI locator class is called in order to retrieve singleton instances of individual security controls, which are then called in order to perform security checks (such as performing an access control check) or that result in security effects (such as generating an audit record).
- reference implementation - There is a reference implementation for each security control. There is application logic contained in these classes, i.e. contained in these interface implementations. However, the logic is not organization-specific and the logic is not application-specific. There is no proprietary information or logic contained in these reference implementation classes.
- Web Application Firewall (WAF) - In ESAPI for Java, there is additionally a Web Application Firewall (WAF) that can be called separately from the other controls.
OWASP ESAPI for Java EE
Purpose: This is the Java EE language version of OWASP ESAPI. The ESAPI for Java EE is the baseline ESAPI design.
- The current release of this project is suitable for production use.
- The ESAPI 2.x branch supports Java 5 and above, but the latest release (18.104.22.168) requires Java 7 or later. You may view the Javadocs here http://www.javadoc.io/doc/org.owasp.esapi/esapi/
- The ESAPI 1.4 branch supports Java 4 and above. Complete information on latest 1.4 branch dependencies can be found here http://owasp-esapi-java.googlecode.com/svn/trunk_doc/1.4.4/site/dependencies.html. (Google may have removed this though, so you may have to search for it on https://archive.org/)
- The OWASP AppSensor-ESAPI integration guide is out! See AppSensor_GettingStarted for details.