Practical Application Security
no text exists for this slide
no notes exist for this slide
Agenda
Introduction
Introduction
Landscape
Best Practices Guidelines
Examples and Code
Beyond the Platform (ESAPI)
Closing
no notes exist for this slide
Introduction
Bilal Soylu
Bilal Soylu
CTO Verian Technologies LLC (www.verian.com)
ColdFusion since mid 90s
Open Source contributor
Enough mistakes to know better ;o)
Blog
http://BonCode.blogspot.com
no notes exist for this slide
Security is a common challenge
Many applications have security issues regardless of platform
Many applications have security issues regardless of platform
Thinking about security comprehensively is actually the best way to achieve secure applications
Writing insecure code is easy
Time
Budget
Knowledge
Lunch
no notes exist for this slide
Overall Top Ten Vulnerability Classes of 2010
no text exists for this slide
no notes exist for this slide
No Application is an Island My Model
no text exists for this slide
no notes exist for this slide
Common Framework
OWASP (www.owasp.org)
OWASP (www.owasp.org)
Open Web Application Security Project
Using Top Ten (Ranked by Severity)
no notes exist for this slide
Current Top 10
A1: Injection (SQL) â User Input
A1: Injection (SQL) â User Input
A2: Cross-Site Scripting (XSS) - User Input
A3: Broken Authentication and Session Management - Logic
A4: Insecure Direct Object References â User Input
A5: Cross-Site Request Forgery (CSRF) â User Input
A6: Security Misconfiguration - Logic
A7: Insecure Cryptographic Storage - Knowledge
A8: Failure to Restrict URL Access â System Input
A9: Insufficient Transport Layer Protection â System Input
A10: Unvalidated Redirects and Forwards - User Inputs
https://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project
no notes exist for this slide
Platform got me covered right
Why do I have to worry. Look at this:
Why do I have to worry. Look at this:
no notes exist for this slide
XSS A2
Most common vulnerability in web-apps
Most common vulnerability in web-apps
Target is other users
Break out context into the other
Data : for display to user
Code: for execution (running your logic)
Common example, using vulnerability in your app to distribute a script to others
XSS is possible without <script> tag
no notes exist for this slide
XSS Example
no notes exist for this slide
Easy Hacks Some Common Trouble
Sessions are always mine (A3)
Sessions are always mine (A3)
I am good with Files (A10?)
no notes exist for this slide
A Safer File Upload
no notes exist for this slide
Session
Session
Session
Donât pass in URL (addToken=false in CFLOCATION)
Validate with cross checked or encrypted stored cookie (see below)
Switch to JEE or UUID tokens
Use HTTP only Session Cookies
-Dcoldfusion.sessioncookie.httponly=true on CF 9.0.1
Consider using SSL when authenticated (prevent sniffers)
Use application logic to check against hijack
no notes exist for this slide
Injection SQL A1
Target is database
Target is database
no notes exist for this slide
Do we really know where youve been last night
Stateless nature of http causes loss of insight into transferred data to client
Stateless nature of http causes loss of insight into transferred data to client
Common Scopes with loss of control
CGI
COOKIE
FORM
URL
CLIENT (?)
no notes exist for this slide
Establish a Chain of Trust
no text exists for this slide
no notes exist for this slide
How to Regain Control Trust
How to re-establish trust
How to re-establish trust
Outbound: Encryption ï¨ secure encryption
Inbound: Validation
Type
Numeric, Date, String
Content / Scope
Number Range, Date Range, distinct string values, e.g. Pass valid Whitelist in encrypted form for non-sequential selections)
Whitelist, whitelist, whitelist
Examples for Form and URL
no notes exist for this slide
URL
no text exists for this slide
no notes exist for this slide
Form Scope
no text exists for this slide
no notes exist for this slide
Indicating trust within your code
Use generic URL / FORM encryption function
Use generic URL / FORM encryption function
Once inputs have been validated or secured put them into a different scope, e.g.:
Request.URL
Request.Form
no notes exist for this slide
Outputting Data
Still use Global Script protection
Still use Global Script protection
Important to know where we ware using user generated data (context)
Outputting data from an uncontrolled / un-trusted input will lead to common XSS scenarios.
Only output from verified scope (e.g. Reques.URL), whitelist, whitelist, whitelist
Output data requires context awareness
In data context: XMLFormat()
Welcome #XMLFormat(Form.UserName)#
URL Context
<a href=âmy.cfm?par=#URLEncodedFormat(orm.color)#>Col</a>
no notes exist for this slide
Outputting ESAPI Enterprise Security API
Java library OWASP project
Java library OWASP project
A port to CF (CFESAPI) is in progress (rumor CF10)
In HTML Attributes (between double quotes):
<a href=â#Form.Page#â>myLink</a>
encoderForHTMLAttribute(formString)
JavaScript Context (+DOM Events)
<div onfocus=âthis.style.color=â#form.color#â>
encodeForJavaScript(form.color)
CSS Context
.myCss { color: #form.color# }
encodeForCSS(form.color)
URL Context
<a href=âhttp://targetsite.com/my.cfm?para1=#form.color#>Color</a>
encodeForURL(form.color)
ESAPI has more stuff, e.g. command line, SQL etc.
no notes exist for this slide
Keep current with updates
Operating Systems
Operating Systems
Databases
Application Servers
no notes exist for this slide
Conclusions
Most web attack vectors are based on developer logic errors
Most web attack vectors are based on developer logic errors
Establishing trust in your inputs will go a long way in securing your applications
You can have coding practices indicate to you if inputs have been secured/validated.
Outputting data needs to be in context sensitive
OWASP is superset of guidelines that we should be familiar with.
no notes exist for this slide
Resources
OWASP (www.owasp.org)
OWASP (www.owasp.org)
Nice video episodes
Adobe (http://www.adobe.com/support/security/)
My Blog (http://boncode.blogspot.com)
CFESAPI (https://www.owasp.org/index.php/ESAPI_ColdFusion_CFML_Readme)
ESAPI (https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API)
no notes exist for this slide
Thank You
no notes exist for this slide
More Stuff
Passwords
Passwords
Use Hash (SHA-256 or SHA-512)⦠you need longer storage, add salt
Encryption
Use strong encryption method, including salt and IV to introduce variability
CFMX_COMPAT is bad
TripleDES, AES, Blowfish are good, AES fast
Use CBC mode of operation
For stronger encryption need to change Java Policy files changed
no notes exist for this slide