establishing an enterprise security api to reduce application security costs

34
) Copyright © 2008 – Aspect Security – www.aspectsecurity.com Establishing an Enterprise Security API to Reduce Application Security Costs Jeff Williams Aspect CEO and Founder Volunteer Chair of OWASP [email protected] 410-707-1487

Upload: brendan-wagner

Post on 31-Dec-2015

27 views

Category:

Documents


0 download

DESCRIPTION

Establishing an Enterprise Security API to Reduce Application Security Costs. Jeff Williams Aspect CEO and Founder Volunteer Chair of OWASP [email protected] 410-707-1487. The Problem…. Spring. Write Custom Code. Jasypt. Java Pattern. Java URL Encoder. xml-enc. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com

Establishing an Enterprise Security APIto Reduce Application Security Costs

Jeff WilliamsAspect CEO and Founder

Volunteer Chair of [email protected]

410-707-1487

Page 2: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com2

The Problem…

Java LoggingJava Logging

BouncyCastleBouncyCastle

SpringSpring

Log4jLog4j

JasyptJasypt

JCEJCE

JAASJAASCryptixCryptix

HDIVHDIVxml-dsigxml-dsig

xml-encxml-enc

Many MoreMany More

ACEGIACEGI

CommonsValidatorCommonsValidator

StrutsStruts

ReformReform Anti-XSSAnti-XSS

StingerStinger

Standard Control

Standard Control

Java Pattern

Java Pattern

Java URLEncoderJava URLEncoder

Write Custom

Code

Write Custom

Code

Page 3: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com3

Vulnerability Theory

VectorVector

VectorVector

VectorVector

VectorVector

VectorVector

Vulnerability Vulnerability

Vulnerability Vulnerability

AssetAsset

Technical Impact Business ImpactVulnerabilityVectorThreat Agent

Vulnerability Vulnerability

Vulnerability Vulnerability

BusinessImpactBusinessImpact

BusinessImpactBusinessImpact

FunctionFunction

AssetAsset

BusinessImpactBusinessImpact

Control

ControlControl

ControlControl

MissingControlMissingControl

A risk is a path from threat agent to business impact

Page 4: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com4

More Vulnerability Theory

Every vulnerability stems from….

Missing control) Lack of encryption

) Failure to perform access control

Broken control) Weak hash algorithm

) Fail open

Ignored Control) Failure to use encryption

) Forgot to use output encoding

Page 5: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com5

Time to Stamp Out Homegrown Controls

Security controls are very difficult to get right) Requires extensive understanding of attacks

One was built with stuff “Larry” had lying around!

Page 6: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com6

Imagine an Enterprise Security API

All the security controls a developer needs

StandardCentralizedOrganizedIntegratedHigh QualityIntuitiveTested

Solves the problems of missing and broken controls

Page 7: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com7

Ignored Controls

Not solved but we can make it far simpler…) Coding Guidelines

) Static Analysis

) Developer Training

) Unit Testing

) Etc…

Page 8: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com8

Enterprise Security API

8

Page 9: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com9

Validation, Encoding, and Injection

Set Character Set

Encode For HTML

Any Encoding

Global Validate Any Interpreter

CanonicalizeSpecific Validate

Sanitize

Canonicalize

Validate

Page 10: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com10

Handling Validation, and Encoding

encodeForURL

encodeForJavaScriptencodeForVBScript

encodeForDN

encodeForHTMLencodeForHTMLAttribute

encodeForLDAP

encodeForSQLencodeForXML

encodeForXMLAttributeencodeForXPath

isValidDirectoryPath

isValidCreditCardisValidDataFromBrowser

isValidListItem

isValidFileContentisValidFileNameisValidHTTPRequest

isValidRedirectLocationisValidSafeHTMLisValidPrintablesafeReadLine

CanonicalizationDouble Encoding Protection

NormalizationSanitization

Page 11: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com11

Handling Authentication and Users

Users

Strong Passwords

Random TokensCSRF Tokens

Lockout Remember Me

Screen Name

Roles

Timeout

Page 12: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com12

Handling Access Control

isAuthorizedForURL

isAuthorizedForFunction

isAuthorizedForFunction isAuthorizedForServic

e

isAuthorizedForData

isAuthorizedForFile

Page 13: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com13

Handling Direct Object References

http://app?file=7d3J93

Report123.xls

Direct ReferencesIndirect References

http://app?id=1 Acct:9182374http://app?id=9182374

Page 14: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com14

Handling Sensitive Information

Encryption

Digital Signatures

Integrity Seals

Strong GUID

Random Tokens Timestamp Salted HashSafe Config Details

Page 15: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com15

Handling Exceptions, Logging, and Detection

•Log Intrusion•Logout User•Disable Account

AccessControlExceptionAuthenticationExceptionAvailabilityExceptionEncodingExceptionEncryptionExceptionExecutorExceptionIntegrityExceptionIntrusionExceptionValidationException

User Message(no detail)

Log Message(w/Identity)

Configurable ThresholdsResponses

Page 16: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com16

Handling HTTP

Add Safe Cookie

No Cache Headers

CSRF Tokens

Safe Request Logging

Encrypt State in Cookie

Add Safe Header

Querystring EncryptionChange SessionID

isSecureChannel

sendSafeRedirect

sendSafeForward

Safe File Uploads

Set Content Type

Kill CookieHidden Field Encryption

Page 17: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com17

Handling Application Security Configuration

•Select crypto algorithms•Select encoding algorithms•Define sets of characters•Define global validation rules•Select logging preferences•Establish intrusion detection thresholds and actions•Etc…

Page 18: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com18

Coverage

Page 19: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com19

Frameworks and ESAPI

Frameworks already have some security) Controls are frequently missing, incomplete, or wrong

ESAPI is NOT a framework) Just a collection of security building blocks, not “lock in”

) Designed to help retrofit existing applications with security

ESAPI Framework Integration Project) We’ll share best practices for integrating

) Hopefully, framework teams like Struts adopt ESAPI

Page 20: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com20

Potential Enterprise Cost Savings

Application Security Program) AppSec Training

) Secure Development Lifecycle

) AppSec Guidance and Standards

) AppSec Inventory and Metrics

Assumptions) 1000 applications, many technologies, some outsourcing

) 300 developers, 10 training classes a year

) 50 new application projects per year

) Small application security team

) 50 reviews per year

Page 21: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com21

Small Project Costs to Handle XSS

Cost Area Typical With Standard XSS Control

XSS Training 1 days 2 hours

XSS Requirements 2 days 1 hour

XSS Design(Threat Model, Arch Review)

2.5 days 1 hour

XSS Implementation(Build and Use Controls)

7 days 16 hours

XSS Verification(Scan, Code Review, Pen Test)

3 days 12 hours

XSS Remediation 3 days 4.5 hours

Totals 18.5 days 4.5 days

Page 22: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com22

Potential Enterprise ESAPI Cost Savings

Cost Area Typical With ESAPI

AppSec Training (semiannual)

$270K $135K

AppSec Requirements 250 days ($150K) 50 days ($30K)

AppSec Design(Threat Model, Arch Review)

500 days ($300K) 250 days ($150K)

AppSec Implementation(Build and Use Controls)

1500 days ($900K) 500 days ($300K)

AppSec Verification(Scan, Code Review, Pen Test)

500 days ($300K) 250 days ($150K)

AppSec Remediation 500 days ($300K) 150 days ($90K)

AppSec Standards and Guidelines

100 days ($60K) 20 days ($12K)

AppSec Inventory, Metrics, and Management

250 days ($150K) 200 days ($120K)

Totals $2.43M $1.00M

Page 23: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com23

OWASP Project Status

Page 24: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com24

Source Code and Javadoc Online Now!

http://code.google.com/p/owasp-esapi-java

Page 25: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com25

Banned Java APIs

System.out.println() -> Logger.*Throwable.printStackTrace() -> Logger.*Runtime.exec() -> Executor.safeExec()Reader.readLine() -> Validator.safeReadLine()Session.getId() -> Randomizer.getRandomString() (better not to use at all)ServletRequest.getUserPrincipal() -> Authenticator.getCurrentUser()ServletRequest.isUserInRole() -> AccessController.isAuthorized*()Session.invalidate() -> Authenticator.logout()Math.Random.* -> Randomizer.*File.createTempFile() -> Randomizer.getRandomFilename()ServletResponse.setContentType() -> HTTPUtilities.setContentType()ServletResponse.sendRedirect() -> HTTPUtilities.sendSafeRedirect()RequestDispatcher.forward() -> HTTPUtilities.sendSafeForward()ServletResponse.addHeader() -> HTTPUtilities.addSafeHeader()ServletResponse.addCookie() -> HTTPUtilities.addSafeCookie()ServletRequest.isSecure() -> HTTPUtilties.isSecureChannel()Properties.* -> EncryptedProperties.*ServletContext.log() -> Logger.*java.security and javax.crypto -> Encryptor.*java.net.URLEncoder/Decoder -> Encoder.encodeForURL/decodeForURLjava.sql.Statement.execute -> PreparedStatement.executeServletResponse.encodeURL -> HTTPUtilities.safeEncodeURL (better not to use at all)ServletResponse.encodeRedirectURL -> HTTPUtilities.safeEncodeRedirectURL (better not to use at all)

Page 26: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com26

About Aspect Security

Page 27: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com27

Questions and Answers

Page 28: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com28

Extra Slides

Page 29: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com29

Rich Data == Code

29

<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE note SYSTEM "Note.dtd"><note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>

<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE note SYSTEM "Note.dtd"><note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>

{"text": {        "data": "Click Here",        "size": 36,        "style": "bold",        "name": "text1",        "hOffset": 250,        "vOffset": 100,        "alignment": "center",        "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"    }}}

{"text": {        "data": "Click Here",        "size": 36,        "style": "bold",        "name": "text1",        "hOffset": 250,        "vOffset": 100,        "alignment": "center",        "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"    }}}

<s:task b:action="xsl-transform" b:stylesheet="$stylesheet" b:datasource="$data" b:destination="id('destination')" ><s:with-param b:name="parameter" b:select="'123'"></s:with-param></s:task>

<s:task b:action="xsl-transform" b:stylesheet="$stylesheet" b:datasource="$data" b:destination="id('destination')" ><s:with-param b:name="parameter" b:select="'123'"></s:with-param></s:task>

<xsl:template match="/"><xsl:param name="parameter"/><xsl:value-of select="$parameter"/></xsl:template>

<xsl:template match="/"><xsl:param name="parameter"/><xsl:value-of select="$parameter"/></xsl:template>

Page 30: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com30

Browser Same Origin Policy

investorsblog.net

XHR

XHR

document, cookies

TAG

TAG

JS

www.mybank.com

Page 31: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com31

Operating SystemOperating System

Javascript EngineJavascript Engine

Browser == Operating System

Javascript Engine

Javascript Engine

JavaEngine

JavaEngine

FlashEngineFlash

EngineQuicktime

EngineQuicktime

EngineAcrobatReaderAcrobatReader

Silverlight, etc…

Silverlight, etc…

Page 32: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com32

DOM Checker

IE 7.0.6… latest patches (remote)Firefox 2.0.0.12 latest patches (remote)

http://code.google.com/p/dom-checker/

Page 33: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com33

Network == Computer

StorageStorage ServicesServices CPU, Identities, and Access

CPU, Identities, and Access

<!-- deploy program in website and wait --><program> loop through top 100 banks { use local credentials to attempt access to bank if access allowed { pull list of attacks from storage attack 1: use checking service to steal $99 attack 2: post this comment to a blog ... } }</program>

Internet API

Page 34: Establishing an Enterprise Security API to Reduce Application Security Costs

)

Copyright © 2008 – Aspect Security – www.aspectsecurity.com34

Potential Enterprise ESAPI Cost Savings