14
Secure HTTP Headers Akash Mahajan c0c0n 2011

Secure HTTP Headers c0c0n 2011 Akash Mahajan

Embed Size (px)

DESCRIPTION

Web site users are facing new and improved threats nowadays. These range from clickjacking, json injection to likejacking among others. Companies like Google, Mozilla, Microsoft etc. have started implementing new HTTP response headers to counter some of the advanced attacks against their website users. Some of the new attacks aren't well understood by the application developers and hence they aren’t using the new secure headers supported by the new browsers. This is either due to ignorance or in order to keep supporting older insecure browsers versions of Internet Explorer. This talk we will walkthrough what these attacks are, how this various security headers protect the web application users and what is the status of compatibility currently.

Citation preview

Page 1: Secure HTTP Headers c0c0n 2011 Akash Mahajan

Secure HTTP Headers

Akash Mahajanc0c0n 2011

Page 2: Secure HTTP Headers c0c0n 2011 Akash Mahajan

Agenda

• Programmers should know about the new HTTP response headers

• Web security testers should be testing for these response headers as defenses

• All you Facebook/Google+ users should be aware of these as well

Page 3: Secure HTTP Headers c0c0n 2011 Akash Mahajan

Overview of the Talk

• Cover all some of the new HTTP response headers

• Cover which attacks are mitigated by using these headers

• Build an case for upgrading to IE8/9, Firefox 5+ or Chrome if that is your type

Page 4: Secure HTTP Headers c0c0n 2011 Akash Mahajan

HTTP Response Headers

• X-Frame-Options• X-XSS-Protection• X-Content-Type-Options• X-Content-Security-Policy• Set-Cookie – Secure – HttpOnly

Page 5: Secure HTTP Headers c0c0n 2011 Akash Mahajan

X-Frame-Options

• Used to prevent Clickjacking

• Doesn’t allow page to be rendered in a frame

• DENY : Don’t render at all if inside a frame, SAMEORIGIN : Only if being served from the origin

• IE8+, FF4+, Chrome5+

Page 6: Secure HTTP Headers c0c0n 2011 Akash Mahajan

X-XSS-Protection

• Used to prevent reflected XSS

• Doesn’t allow the page to be rendered if a reflected XSS attack is detected

• 0 is off, 1 is on, Additional mode = block

• IE8+, Chrome, No FF ( use noscript )

Page 7: Secure HTTP Headers c0c0n 2011 Akash Mahajan

X-Content-Type-Options

• Used to prevent mime based attacks.

• Browser will not try to figure out content type if not sent to it in the response header– An image uploading site with script code is bad

• X-Content-Type-Options: nosniff

• IE8+

Page 8: Secure HTTP Headers c0c0n 2011 Akash Mahajan

X-Content-Security-Policy: policy

• Used to define a whitelist of domains and actions which are allowed.

• Example usage– X-Content-Security-Policy:

allow 'self'; img-src *; object-src media1.com media2.com; script-src userscripts.example.com; allow https://payments.example.com

• FF4+

Page 9: Secure HTTP Headers c0c0n 2011 Akash Mahajan

Set-Cookie with Secure and HTTPOnly

• With Secure keyword– Only allow cookie to travel with a secure

connection– An attack where HTTP and HTTPs is mixed

• With HTTPOnly keyword– Scripts can’t read the cookie– Any attack where session cookie is stolen

• IE7+, Chrome12+, FF3+

Page 10: Secure HTTP Headers c0c0n 2011 Akash Mahajan

Compatibility with browsers

Headers / BrowsersMS Internet Explorer

Google Chrome

Mozilla Firefox

X-Frame-OptionsYES YES YES

X-XSS-Protection YES YES NO

X-Content-Type-Options YES NO NO

X-Content-Security-Policy NO NO YES

Set-Cookie Secure HttpOnly YES YES YES

This slide needs a lot more work. Specific versions, more browsers.

Page 11: Secure HTTP Headers c0c0n 2011 Akash Mahajan

A logical argument for upgrading IE

• A ten year old browser ( IE6 ) just can’t keep up with the advanced web application attacks against users. The new crop of browsers are proactively adding support to stop the attacks at the browser level itself.

• Microsoft runs a http://ie6countdown.com with a mission of moving the world off Internet Explorer 6

Page 12: Secure HTTP Headers c0c0n 2011 Akash Mahajan

Revisiting the attacks and headers

• X-Frame-Options– Especially useful against clickjacking

• X-XSS-Protection– Refelected XSS

• X-Content-Type-Options– Mime attacks for executing malicious scripts

Page 13: Secure HTTP Headers c0c0n 2011 Akash Mahajan

Revisiting the attacks and headers

• Set-Cookie – Secure• No sniffing of user session cookie

– HttpOnly• Not allowing javascript to read the session cookie

• X-Content-Security-Policy– Whitelisting of content domains for including in

the page

Page 14: Secure HTTP Headers c0c0n 2011 Akash Mahajan

My info while I answer your questions

Akash Mahajan That Web Application Security Guy

– Web Application Security Consultant– null Co-Founder, Bangalore Chapter Lead– Certified Ethical Hacker

@makash | http://akashm.com | [email protected] | 9980527182