Enterprise Security API
Enterprise Security API
Enterprise Security API
Jarret Raim
June 3rd, 2010
What is it?
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.
Who cares?
How Does it Work?
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.
• 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.
There are several supported languages
• Java EE
• PHP
• Classic ASP
• .NET
• Coldfusion
• Python
• JavaScript
• Haskell
• Force.com And they have a plan. Maybe.
Tyranny of Choice
Write
Spring Custom
Java Jasypt Java
Code
Pattern URL
Commons xml-enc EncoderLog4j
Validator
Cryptix JAAS
JCE ACEGI Stinger
Struts BouncyCastle
Reform Anti-XSS Many
HDIV More Standard
xml-dsig Java Control
Logging
Vulnerability Theory
Vector
Business
Impact
Asset Business
Impact
Missing
Vector Vulnerability
Control
Function Business
Impact
Vector Vulnerability
Asset
Vector Vulnerability Control
Where do Vulnerabilities Come From?
• Missing Controls
– Lack of encryption
– Failure to perform access control
• Broken Controls
– Weak hash algorithm
– Fail open
• Ignored Controls
– Failure to use encryption
– Forgot to use output encoding
• ESAPI Solves
– Missing
– Broken
• Process Solves
– Ignored
Authenticator
User
AccessController
AccessReferenceMap
Validator
Encoder
HTTPUtilities
Encryptor
EncryptedProperties
Randomizer
Enterprise Security API
Exception Handling
Custom Enterprise Web Application
Logger
IntrusionDetector
Existing Enterprise Security Services/Libraries
SecurityConfiguration
Encoder
• Typical output in most web <p>Hello, <%=name%></p>
frameworks leads to XSS and
<p>Hello,
CSRF vulnerabilities.
<%=ESAPI.encoder().encodeForHTML(name)%>
• The ESAPI encoder allows </p>
direct encoding depending on
context.
• Web (HTML, JavaScript, CSS)
• Databases (MySQL, Oracle)
• URL
• Shells (Unix, Windows)
• XML
• LDAP
• Also provides a canonnicalize
method to remove any
encodings.
User Controller Business Data Layer Backend
Functions
isValidCreditCard encodeForJavaScript
isValidDataFromBrowser encodeForVBScript
isValidDirectoryPath Validator Encoder encodeForURL
isValidFileContent encodeForHTML
isValidFileName encodeForHTMLAttribute
isValidHTTPRequest encodeForLDAP
isValidListItem Canonicalization encodeForDN
isValidRedirectLocation Double Encoding Protection encodeForSQL
isValidSafeHTML Sanitization encodeForXML
isValidPrintable Normalization encodeForXMLAttribute
safeReadLine encodeForXPath
Validator
EXAMPLE: <script>alert(document.cookie)</script> • The Validator interface defines a
set of methods for canonicalizing
ESAPI.validator().getValidInput(String context,String
input,String type,int maxLength,boolean
and validating untrusted input.
allowNull,ValidationErrorList errorList) – Returns booleans as not all
validation problems are security
issues.
assertIsValidHttpRequest()
assertIsValidHttpRequestParameterSet()
• Invalid input will generate a
assertIsValidFileUpload() descriptive ValidationException
getValidCreditCard() which will be stored in the
getValidDate() ValidationErrorList
getValidDirectoryPath()
getValidDouble()
• Input that is clearly an attack will
getValidFileContent() generate a descriptive
getValidFileName() IntrusionException
…
Validator Example
Mainframe
User
Interface
File System
Set Character Set Canonicalize
support for
Detection
Intrusion
projects like
Logging
Control
Access
Web Service
isAuthorizedForFunction
isAuthorizedForService
Controller
Database
Mainframe
isAuthorizedForFile
User
Interface
File System
isAuthorizedForFunction
Encryption
Database
Mainframe
User Access
Reference Map
Etc…
Report123.xls
File System
AccessControlException
AuthenticationException
AvailabilityException Configurable Thresholds
Intrusion
EncodingException Detector Responses
EncryptionException •Log Intrusion
ExecutorException •Logout User
IntegrityException •Disable Account
IntrusionException
ValidationException
Handling HTTP
Web: www.denimgroup.com
Blog: blog.denimgroup.com
27