web 2.0 security james walden northern kentucky university

36
Web 2.0 Security James Walden Northern Kentucky University

Upload: steven-harrell

Post on 12-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Web 2.0 Security James Walden Northern Kentucky University

Web 2.0 Security

James WaldenNorthern Kentucky University

Page 2: Web 2.0 Security James Walden Northern Kentucky University

Speaker Biography

Assistant Professor at NKUGraduate certificate in Secure Software Eng.Minors in Infosec and Forensics.Papers & workshops in software security.

Contributor toSANS/CWE Top 25 programming flaws.SANS GSSP secure programmer cert.OWASP/Fortify Open Source Review.

Page 3: Web 2.0 Security James Walden Northern Kentucky University

Why Target Web Apps?

Page 4: Web 2.0 Security James Walden Northern Kentucky University

Attack Surface

A system’s attack surface consists of all of the ways an adversary can enter the system.

Merchant’s Bank Building

Page 5: Web 2.0 Security James Walden Northern Kentucky University

Defender’s View

firewall

VPN wireless

web server

Page 6: Web 2.0 Security James Walden Northern Kentucky University

History of Web Security

Year Technology Security

1993 CGI Firewalls, SSL

1995 PHP, Javascript Firewalls, SSL

1997 ASP, JSP Firewalls, SSL

2000 SOA Firewalls, SSL

2006 AJAX Firewalls, SSL

Page 7: Web 2.0 Security James Walden Northern Kentucky University

Firewalls and Web Apps

Firewall

Port 80HTTP Traffic

WebClient

WebServer

Application

Application

DatabaseServer

telnet

ftp

Page 8: Web 2.0 Security James Walden Northern Kentucky University

SSL: injection attacks, XSS

Firewall

Port 443HTTPS Traffic

WebClient

WebServer

Application

Application

DatabaseServer

telnet

ftp

Page 9: Web 2.0 Security James Walden Northern Kentucky University

Revised Attack Surface

firewall

VPN

wireless

external web server

external web apps

database

Page 10: Web 2.0 Security James Walden Northern Kentucky University

Intra-Security Assumptions

Since the firewall protects you Patches don’t have to be up to date. Passwords don’t have to be strong. There’s no need to be careful when you code. There’s no need to audit your source code. There’s no need to run penetration tests.

But do your users have web browsers?

Page 11: Web 2.0 Security James Walden Northern Kentucky University

Javascript Malware

Firewall

Port 80

HTTP Traffic

WebServer

(Javascript malware)

WebClient

telnet

ftp

Intranet

Main Server

Wiki

Group Server

Page 12: Web 2.0 Security James Walden Northern Kentucky University
Page 13: Web 2.0 Security James Walden Northern Kentucky University

Malware Sources

1. Evil web site owner inserts in page.

2. Attacker inserts malware into defaced page.

3. Attacker inserts malware into a public comment or forum post (stored XSS.)

4. Attacker creates link that causes web site to echo malware to user (reflected XSS.)

Page 14: Web 2.0 Security James Walden Northern Kentucky University

Re-revised Attack Surface

firewall

VPN

wireless

external web server

external web apps

database

internal web servers

internal web apps

Page 15: Web 2.0 Security James Walden Northern Kentucky University

Web Applications

firewall

VPN

wireless

external web server

external web apps

database

internal web servers

internal web apps

Page 16: Web 2.0 Security James Walden Northern Kentucky University

Web App Vulnerabilities

Input-based Security ProblemsInjection FlawsInsecure Remote File InclusionUnvalidated Input

Authentication and AuthorizationAuthenticationAccess ControlCross-Site Attacks

Other BugsError Handling and Information LeakageInsecure StorageInsecure Communications

Page 17: Web 2.0 Security James Walden Northern Kentucky University

SQL Injection

1. App sends form to user.2. Attacker submits form

with SQL exploit data.3. Application builds string

with exploit data.4. Application sends SQL

query to DB.5. DB executes query,

including exploit, sends data back to application.

6. Application returns data to user.

Attacker

Web Server DB Server

Firewall

User

Pass

‘ or 1=1--

Page 18: Web 2.0 Security James Walden Northern Kentucky University

Cross-Site Scripting

1. Login

2.

Cookie

Web Server

3. XSS Attack

AttackerUser

4. User clicks on XSS link.

5. XSS URL

7. Browser runs injected code.

Evil site saves ID.

8. Attacker hijacks user session.

6. Page with injected code.

Page 19: Web 2.0 Security James Walden Northern Kentucky University

Feature Vulnerability Map

Database interaction

Displays user-supplied data

Error messages

File upload/download

Login

SQL injection.

Cross-site scripting.

Information leakage.

Path traversal.

Authentication, session management, access control flaws.

Page 20: Web 2.0 Security James Walden Northern Kentucky University

Web App Attack Surface

form inputs

HTTP headersURLs

cookies

Page 21: Web 2.0 Security James Walden Northern Kentucky University

Traditional Web Apps

HTTP Request (form submission)

HTTP Response (new web page)Server processingUser waits

HTTP Request (form submission)User interaction

HTTP Response (new web page)User waits Server processing

Page 22: Web 2.0 Security James Walden Northern Kentucky University

AJAX

Asynchronous Javascript & XML User interacts with client-side

Javascript. Javascript makes asynchronous

requests to server for data. Continues to allow user to

interact with application. Updates when receives

encoded data from server.

Page 23: Web 2.0 Security James Walden Northern Kentucky University

AJAX Applications

Server processingUser interaction

User interaction

Server processing

Client-sideCode

HTTP request (asynchronous)

partial update

partial update

HTTP Response (data)

partial update HTTP request (asynchronous)

HTTP Response (data)

HTTP request (asynchronous)

HTTP Response (data)partial update

User interaction

Server processing

Page 24: Web 2.0 Security James Walden Northern Kentucky University

Architecture Differences

Traditional

Application on server.

Entire form sent to server.User fills in input items.Clicks on submit.

Server returns new page.Presentation + Data.

AJAX

App on client and server.

JavaScript receives user input, issues function calls to server when needed.Get map tile.Save location data.

Server returns individual data items.

JavaScript incorporates data items into existing page.

Page 25: Web 2.0 Security James Walden Northern Kentucky University

AJAX: More Entry Points

Purchase Item

downloadItem()

debitAccount()

getPrice()

Page 26: Web 2.0 Security James Walden Northern Kentucky University

Example Client-side Code

var auth = checkPassword(user, pass);

if (auth == false) {

alert(‘Authentication failed.’);

return;

}

var itemPrice = getPrice(itemID);

debitAccount(user, itemPrice);

downloadItem(itemID);

Page 27: Web 2.0 Security James Walden Northern Kentucky University

Client Side Data

Use Firebug to modify variables.

Modifying session stateSet auth to true.Set itemPrice to $0.01, $0, -$1.00.

Viewing sensitive dataif (discountCode == “HALF_OFF”) {

window.location(“discount_order.html”);

}

Page 28: Web 2.0 Security James Walden Northern Kentucky University

Client Side Code

Example Code (AJAX Security, p. 176)<script>function sum(x,y) { var z = x + y; alert(“Sum is “ + z);}</script><input type=“button” value=“5 + 6 = ?” onclick=“sum(5,6);” />

Insert with Firebug to replace sum() in 5s:setTimeout(“sum = function() { alert(‘hijacked!’); }”, 5000);

Page 29: Web 2.0 Security James Walden Northern Kentucky University

AJAX: More Client Data

Web ServerDatabase

SQL Injection SQL Injection

Web ServerDatabase

Intended DataExtra Data

Selected DataPresentation (HTML)

SQL Injection SQL Injection

Intended DataExtra Data

Selected DataData (XML,JSON)

Server returns XML/JSON full data for AJAX client to display.

Server returns HTML page that displays desired data.

Page 30: Web 2.0 Security James Walden Northern Kentucky University

Client Data Vulnerability

SQL QuerySELECT * FROM USERS WHERE UID=<>

Injected QuerySELECT * FROM USERS WHERE UID=12345UNION SELECT * FROM CREDITCARDS

XML Data<data>

<user><uid>12345</uid><name>John Smith</name>

</user><creditcard>

<ccnumber>4444-4444-4444-4444</ccnumber><expire>01/01/2011</expire>

</creditcard></data>

Page 31: Web 2.0 Security James Walden Northern Kentucky University

JSON

var json = getItem()

// json = “[ ‘Toshiba’, 499, ‘LCD TV’]”

var item = eval(json)

// item[0] = ‘Toshiba’

// item[1] = 499

// item[2] = ‘LCD TV’

Page 32: Web 2.0 Security James Walden Northern Kentucky University

JSON Injection

Evil input: ‘];alert(‘XSS’);//

var json = getItem()

// json = “[ ‘Toshiba’, 499, ‘’];alert(‘XSS’);//”

var item = eval(json)

// Alert box with ‘XSS’ appears.

// Use json2.js validation library to prevent.

Page 33: Web 2.0 Security James Walden Northern Kentucky University

Client-Side State

Storage Technologies

Client-Side Storage Issues

User can always modify client-side data.

Cross-Domain Attacks (between subdomains).

Cross-directory Attacks.

Cross-port Attacks.

Cookies

DOM Storage (HTML5)

Flash LSOs

UserData (IE)

Page 34: Web 2.0 Security James Walden Northern Kentucky University

AJAX Attack Surface

form inputs

HTTP headers

URLs

cookies

client-sidecode client-side

state

server API

client-side data

transforms

Page 35: Web 2.0 Security James Walden Northern Kentucky University

firewall

VPN

wireless

external web server

external web apps

database

internal web servers

internal web apps

client-sidestate

form inputs

HTTP headers

URLs

cookies client-sidecode

server API

client-side data

transformsis nearly fractal.

A site’s attack surface

Page 36: Web 2.0 Security James Walden Northern Kentucky University

Discussion Items

Are organization’s security policies changing in response to Web 2.0?

What are people currently doing to determine their attack surface?

How do people select which elements of the attack surface to reduce first?