Top Banner
Fachbereich Informatik SVS – Sicherheit in Verteilten Systemen Universität Hamburg SessionSafe: Implementing XSS Immune SessionHandling ESORICS ‘06 20. September 2006 Martin Johns
27

ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

Jul 27, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

Fachbereich InformatikSVS – Sicherheit in Verteilten Systemen

Universität Hamburg

SessionSafe:Implementing XSS ImmuneSessionHandling

ESORICS ‘0620. September 2006

Martin Johns

Page 2: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 2

Me, myself and I

Martin Johns johns at informatik.uni-hamburg.de Security researcher at the University of Hamburg Member of the secologic project

Research project carried out by SAP, Commerzbank, Eurosecand the University of Hamburg

Sponsored by the German Ministry of Technology (BMWi) Goal: Improving software security Visit us at http://www.secologic.org

Page 3: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 3

Agenda

Web Application Session Management Cross Site Scripting Protection Approaches Conclusion

Page 4: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 4

Agenda

Web Application Session Management Cross Site Scripting Protection Approaches Conclusion

Page 5: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 5

Session management in http

As http is stateless a web application has to implement itsown session tracking mechanism

An authenticated user gets assigned a session ID

Three common methods URL rewriting Form based session IDs Cookies

Page 6: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 6

Cookies

Cookies are used to maintain state Stored on the client’s browser Send to the server along with matching requests Example: A request to www.example.org/index.html will send

all cookies that are stored for www.example.org and example.org

Cookies stored for other (sub-)domains are not sent

Page 7: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 7

Session management with cookies

The server sets a cookie at the client’s browser after theauthentication form

This cookie is automatically included in all further requests The client’s requests are treated as authorized as long as this

cookie is valid

Page 8: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 8

Agenda

Web Application Session Management Cross Site Scripting Protection Approaches Conclusion

Page 9: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 9

Cross Site Scripting (XSS)

Domain: www.example.org

JavaScript

CookiesHTML

Attacker

XSS

JavaScript

An attacker includes malicious JavaScript code into awebpage

This code is executed in the victim’s browser session

Page 10: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 10

Today’s defense against XSS

Input Validation (IV): All untrusted input data is checked against predefined

specification

Output Sanitization (OS): “Cleaning” of HTML

Removing malicious data Encoding malicious data

IV OSOS

OS

OS

Application

Page 11: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 11

This approach fails frequently

Reported XSS vulnerabilities: In the first six month of 2006 over 550 XSS vulnerabilities

were reported to BugTraq All major frameworks were affected (php, j2ee, asp.NET,…)

Affected websites: Google (16.09.2006) MSN (25.06.2006) Yahoo (28.04.2006) PayPal.com (23.07.2006) Amazon.com (27.06.2006) Verisign (14.08.2006) ibm.com, sun.com, ebay.com,…

Page 12: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 12

Why does the approach fail?

Input Validation (IV): IV is not always possible Has to be tailored to a specific scenario Scattered code

Output Sanitization (OS): Context dependent

e.g., from data origin, data destiny, role of the application’s user Heterogeneous technologies lead to losing data’s context

IV/OS is not centralized enforceable

Page 13: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 13

Why does the approach fail? (II)

Furthermore, there are XSS attacks that cannot beprevented this way: DOM based XSS Server induced XSS

Expect handler vulnerability

To make things worse: One single XSS vulnerability compromises the whole web

application

Page 14: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 14

Motivation

Can we defend a web application againstsession hijacking

after a successful XSS attack?

Approach: Determining the available security mechanisms in web

architecture Classification of XSS session hijacking attacks Investigation of the basic requirements of these attack

classes Applying the security mechanisms to revoke those

requirements

Page 15: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 15

Agenda

Web Application Session Management Cross Site Scripting Protection Approaches Conclusion

Page 16: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 16

Security Mechanisms in Web Architecture

The same origin policy Defines basic access rights in http Two elements have the “same origin” if the

protocol, port, and host

are the same for both elements Access rights

JavaScript has unlimited access to all elements, which matchthe script’s origin

Cookies are sent along with all requests with matching target

JavaScript Closures

Page 17: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 17

XSS Session-Hijacking-Attack Classes

Attack class SessionID Theft

Leakage of the SID

Browser Hijacking Execution of the attack within

the broswser

Background XSS Propagation Controlling the attack with an

outside entity

Requirement Accessibility of the SID by the

malicious JavaScriptDeferred Loading

Pre-knowledge of theapplication’s URLsOne-Time URLs

Implicit trust between browserdocuments with the sameoriginSubdomain Switching

Page 18: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 18

This is XSS 101 The malicious JavaScript obtains the SID

All presented SID mechanisms (URL, Form, Cookie) arevulnerable

and communicates it to the attacker. The attacker is now able to impersonate the victim

Requirement: Malicious JavaScript has to be able to accessthe SID

Session ID Theft

Victim AttackerSID

XXS

Page 19: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 19

Deferred Loading: Concept

www.example.org

JavaScript

CookiesHTML

Attacker

XSS

JavaScript

Page 20: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 20

Deferred Loading: Concept

www.example.org

JavaScript

HTML

Attacker

XSS

JavaScript

secure.example.orgCookies

synchronisation

Cookies

Page 21: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 21

Concept: Synchronisation Problem

Webserver

Browser

HTML

Cookie

www.example.org secure.example.org

?

Page 22: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 22

Concept: Pageloader

Webserver

Browser

HTML

Cookie

synchronisation

Cookie

HTML

www.example.org secure.example.org

PageLoader <img>

Page 23: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 23

Protection against: SID Theft

Because of the Deferred Loading process, the SID cookie andpotential XSSs belong to different (sub)domains

For this reason the malicious script has no access to the SID

www.example.org

JavaScript

HTML

XSS

JavaScript

secure.example.org

Cookie: SID

Page 24: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 24

Implementation

Transparent implementation for J2EE Serverside proxy The proxy executes the Deferred Loading process before

passing the requests to the server

Page 25: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 25

Agenda

Web Application Session Management Cross Site Scripting Protection Approaches Conclusion

Page 26: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 26

Conclusion

Implementation Transparent server-side proxy for J2EE

Limitations The XSS still has full control over the vulnerable webpage Further drawbacks:

AJAX has to be treated separately One-Time URLs may break the “Back” and “Reload” button

Protection: Good protection against “hidden” attacks XSS may still be able to steal passwords by spoofing

authentication dialogs Client Side SSL authentication could help

Page 27: ESORICS ‘06 Martin Johns · 2019-07-17 · ©Marti nJohs ,UHFBIf SV 20.9 6 1 This approach fails frequently Reported XSS vulnerabilities: In the first six month of 2006 over 550

© Martin Johns, UHH, FB Inf, SVS, 20.09.2006 27

Thank you

Thanks for listening.

Questions? Comments?