of HTTP Headers Dirk Wetter @drwetter Licence: http://creativecommons.org/licenses/by-nc-sa/4.0/



Similar documents
AppSec USA 2014 Denver, Colorado Security Header Injection Module (SHIM)

Protecting Web Applications and Users

Web Application Security

Zeitgemäße Webserver-Konfiguration. Ein Serviervorschlag

HTTP. Internet Engineering. Fall Bahador Bakhshi CE & IT Department, Amirkabir University of Technology

Criteria for web application security check. Version

CloudOYE CDN USER MANUAL

Modern Web Development From Angle Brackets to Web Sockets

Recent Advances in Web Application Security

Security starts in the head(er)

Module 45 (More Web Hacking)

Protocolo HTTP. Web and HTTP. HTTP overview. HTTP overview

1. When will an IP process drop a datagram? 2. When will an IP process fragment a datagram? 3. When will a TCP process drop a segment?

Hypertext for Hyper Techs

(WAPT) Web Application Penetration Testing

Web. Services. Web Technologies. Today. Web. Technologies. Internet WWW. Protocols TCP/IP HTTP. Apache. Next Time. Lecture # Apache.

Weird New Tricks for Browser Fingerprinting. yan ToorCon 2015

HTML5. Eoin Keary CTO BCC Risk Advisory.

CONTENT of this CHAPTER

CTIS 256 Web Technologies II. Week # 1 Serkan GENÇ

Ethical Hacking as a Professional Penetration Testing Technique

Varnish Tips & Tricks, 2015 edition

Securing the SSL/TLS channel against man-in-the-middle attacks: Future technologies - HTTP Strict Transport Security and Pinning of Certs

Web Application and API Security The Latest Trends and Threats. 03/19/15 Sean Leach

Project #2. CSE 123b Communications Software. HTTP Messages. HTTP Basics. HTTP Request. HTTP Request. Spring Four parts

Network Technologies

HTTP Protocol. Bartosz Walter

HTTP Fingerprinting and Advanced Assessment Techniques

Department of Computing Imperial College London. BrowserAudit. A web application that tests the security of browser implementations

Relax Everybody: HTML5 Is Securer Than You Think

Outline Definition of Webserver HTTP Static is no fun Software SSL. Webserver. in a nutshell. Sebastian Hollizeck. June, the 4 th 2013

TYPO3 Security. Jochen Weiland CertiFUNcation 2016

Table of Contents. Open-Xchange Authentication & Session Handling. 1.Introduction...3

CS640: Introduction to Computer Networks. Applications FTP: The File Transfer Protocol

XSS PROTECTION CHEATSHEET FOR DEVELOPERS V1.0. Author of OWASP Xenotix XSS Exploit Framework opensecurity.in

Web applications. Web security: web basics. HTTP requests. URLs. GET request. Myrto Arapinis School of Informatics University of Edinburgh

Playing with Web Application Firewalls

World Wide Web. Before WWW

Cache All The Things

reference: HTTP: The Definitive Guide by David Gourley and Brian Totty (O Reilly, 2002)

What is Web Security? Motivation

Information Extraction Art of Testing Network Peripheral Devices

No. Time Source Destination Protocol Info HTTP GET /ethereal-labs/http-ethereal-file1.html HTTP/1.

Web Development. Owen Sacco. ICS2205/ICS2230 Web Intelligence

Secure Coding in Node.js

Web Application Attacks And WAF Evasion

SSL BEST PRACTICES OVERVIEW

Hack Yourself First. Troy troyhunt.com

A Study of What Really Breaks SSL HITB Amsterdam 2011

REDCap Technical Overview

SESSION IDENTIFIER ARE FOR NOW, PASSWORDS ARE FOREVER

WompMobile Technical FAQ

A Server and Browser-Transparent CSRF Defense for Web 2.0 Applications. Slides by Connor Schnaith

Playing with Web Application Firewalls

SSL Report: ebfl.srpskabanka.rs ( )

Cyber Security Workshop Ethical Web Hacking

CIS 551 / TCOM 401 Computer and Network Security. Spring 2007 Lecture 20

elearning for Secure Application Development

By Bardia, Patit, and Rozheh

Sichere Webanwendungen mit Java

Web Application Firewall

Front-End Performance Testing and Optimization

Enterprise Application Security Workshop Series

Phishing by data URI

Cross Site Scripting (XSS) and PHP Security. Anthony Ferrara NYPHP and OWASP Security Series June 30, 2011

Advanced XSS. Nicolas Golubovic

HTTP Caching & Cache-Busting for Content Publishers

Computer Networks. Lecture 7: Application layer: FTP and HTTP. Marcin Bieńkowski. Institute of Computer Science University of Wrocław

Web Application Firewall Technology Insight OWASP 22/ The OWASP Foundation. Joakim Sandström Role: OWASP Prospect.

The Web: some jargon. User agent for Web is called a browser: Web page: Most Web pages consist of: Server for Web is called Web server:

LBSEC.

Abusing Insecure Features of Internet Explorer

Check list for web developers

JOOMLA SECURITY. ireland website design. by Oliver Hummel. ADDRESS Unit 12D, Six Cross Roads Business Park, Waterford City

Acunetix Website Audit. 5 November, Developer Report. Generated by Acunetix WVS Reporter (v8.0 Build )

People Data and the Web Forms and CGI CGI. Facilitating interactive web applications

Internet Technologies Internet Protocols and Services

Hardened Plone. Making Your Plone Site Even More Secure. Presented by: Nathan Van Gheem

Lektion 2: Web als Graph / Web als System

APACHE WEB SERVER. Andri Mirzal, PhD N

SSL implementieren aber sicher!

APACHE HTTP SERVER 2.2.8

Bypassing Internet Explorer s XSS Filter

How to Run an Apache HTTP Server With a Protocol

An Insight into Cookie Security

Certified Secure Web Application Secure Development Checklist

Lecture 11 Web Application Security (part 1)

APPLICATION SECURITY AND ITS IMPORTANCE

Webapps Vulnerability Report

How to hack a website with Metasploit

Nginx 1 Web Server Implementation

Transcription:

Security Security and and Insecurity Insecurity of of HTTP HTTP Headers Headers Dirk Dirk Wetter Wetter @drwetter Licence: http://creativecommons.org/licenses/by-nc-sa/4.0/

imaohw Independent Security Consultant Offense / Defense / Security Project Management Historical strong Unix/networking background OWASP Involvement OWASP AppSec Research 2013 German OWASP Day 2012, 2014 German Chapter Lead Helping hand here/there Other My TLS hobby: testssl.sh chair

Security and Insecurity of HTTP Headers Disclaimer Completeness Perspective Matt McGee, CC-BY=ND 2.0, http://wiki.ironchariots.org/index.php?title=file:cherry_picking_med.jpg

1. What, (in)security? Instruction: Browser Do this 30x, 401 Cache Expire Do not frame this, set Cookie, keep-alive, etc Displaying: specify Content-Type/Encoding, Compression More properties to identify session / keep backend server

1. What, (in)security? Redundant information Type of server, application Version numbers, more or less Framework Architecture hints Via <proxy> IP of load balanced server

2. Where does it come from? Where do header lines originate from? Simple setup (Web+Appl server} + Application

2. Where does it come from? Where do header lines originate from? - Not so simple setup RP or WAF Entry web server App server + Application

2. Where does it come from? <OT> Often forgotten Server time! - HTTP header: Date - TLS timestamp - SChannel: all - OpenSSL < 1.0.1f - 1-4 conclusions from date timestamps </OT>

2. Where does it come from? Further Interesting stuff Big IP F5 Set Cookie: BIGip<str>=1677787402.36895.0000; Netweaver-Cluster

2. Where does it come from? Conclusion #I Fingerprinting of Architecture / Infrastructure Patchlevel of Components Maybe more (see l8er) Evil dude: Gimme more!

2. Where does it come from? Conclusion #II - Client side perspective: What's really necessary? What else can be done to improve security?

dirks@laptop:~ 1% wget -qso /dev/null eiklaut.net HTTP/1.1 200 OK Date: Thu, 21 May 2015 22:44:42 GMT Content-Type: text/html Content-Length: 630 Last-Modified: Fri, 29 Nov 2013 08:39:54 GMT Server: Apache 2.2.22 (RHEL), mod_ssl openssl 1.0.3 Set-Cookie: PHPSESSID=44h5vc482fgiapfmit5t0n9f03; path=/; X-Powered-By: PHP/4.4.42 X-UA-Compatible: IE=EmulateIE7 Accept-Ranges: bytes Connection: keep-alive dirks@laptop:~ 0%

2. Where does it come from? Conclusion #II : If / where possible: Proper secure defaults! Remove chatty lines add security headers

3. Theory Cookie attributes / flags HttpOnly access of JavaScript methods cookie classical XSS some browser protection nowadays Secure no transport via plaintext HTTP cookie clobbering, mixed content SOP, works?!» Some bypasses

3. Theory Transport encryption: HSTS (RFC 6797) HTTP Strict Transport Security @Browser : Within max age never ever use plain http, maybe includesubdomains max age: [seconds] Recommended > ½ year: 3600 24 181 Browser support ok *) Chrome >=4 Firefox >= 4 Safari >=7, Opera >=12.1 IE 11 on W10 only! *) see http://caniuse.com/#feat=stricttransportsecurity

3. Theory Transport encryption: HSTS One problem though TOFU! preload: http://hstspreload.appspot.com/ DryPot / GDFL 2.0/ CC BY-SA 3.0 http://en.wikipedia.org/wiki/tofu#/media/file:japanese_silkytofu_(kinugoshi_tofu).jpg

3. Theory Transport encryption: HSTS Pitfalls Change of mind (http!) within time specified Certificate expired (example Firefox) Careful with includesubdomains for TLD!

3. Theory Transport encryption: HSTS Solution to Pitfalls set max age to 0 (see RFC 6797, 6.1.1) worked w/ FF Chrome? order new certificate ;-)

3. Theory IETF Draft RFC 7469 HTTP Public Key Pins / Public Key Pins Report Only Certificate pinning a.k.a. HPKP @Browser: Within max age remember keys and do not except anything else includesubdomains pin sha256=<base64str> report uri=<json POST URI>!

3. Theory Goodbye (un)lawful / whatsoever interception ;-) RFC: UAs MUST close the connection to a host upon Pin Failure Ok, some constraints... (quality of encryption) Local CAs TOFU Picture courtesy of Submessenger @ www.bullshido.net

3. Theory HPKP: which keys? - Best: pins of >= two keys actual Pin of backup key in pocket / safe Careful with issuer pinning - how? script from Hanno Böck - Locking out? - max age=0???

3. Theory

3. Theory HPKP, browser support: Chrome >=35 Firefox >= 35 Safari, Opera? IE 1x probably not at all (yet) https://projects.dm.id.lv/public-key-pins_test

3. Theory Was: per site Now per page

3. Theory X Content Type Options: nosniff Originally designed for IE < 8 MIME sniffing! Ignored Content-Type completely Similar unix file (or MIME libs file uploads) User controlled content chameleon files, picture XSS HTML/JS in PS, PNG etc. Attention: Compatibility view of IE Warning for Aliens, liftarn,openclipart.org/detail/2881/warning-for-aliens T-800: by Noble0, CC BY SA 3.0 / r.wikipedia.org/wiki/fichier:old_artificial_profile_avatar.jpg

3. Theory Safer dl'ing: Content Disposition: attachment X Download Options : noopen CC-BY_SA 2.0 Magnus Manske https://commons.wikimedia.org/wiki/file:condom_gun.jpg

3. Theory X Content Type Options: nosniff Border cases for Firefox General: trust MIME type What if empty? PDF/PS, XML, HTML Determine image type T-800: by Noble0, CC BY SA 3.0 / https://fr.wikipedia.org/wiki/fichier:old_artificial_profile_avatar.jpg

3. Theory X FRAME OPTIONS DENY SAMEORIGIN ALLOW FROM uri Clickjacking 'n friends Against framing your page Attention: Business reasons for framing Application (e.g. Typo3 backend) Chrome/Webkit? don't give a damn: ALLOW FROM

3. Theory XSS X XSS Protection 0 off, sense? (https://www.facebook.com/) 1 on, browser engine can sanitize 1; mode=block better: no rendering Good thing (again): report=<json POST URI> Support: no Firefox Chrome/Webkit IE

3. Theory

3. Theory XSS, again X Content Security Policy (FF < 23) X WebKit CSP (Chrome < 25) Content Security Policy (+ related) (Content Security Policy Report Only) not trivial! Cooperation of development, JS frameworks, templates, trackers, objects embedded,... ~two parts 1. Policy directive (*-src) 2. source value(s) Concat as much pairs as you want Separation by semicolon

3. Theory XSS, again Content Security Policy Policy directive @Browser: which content are you allowed to render?» script src» img src» style src» frame src (father option to X-FRAME-OPTIONS)» font src» media src (video, audio)» default src»...

3. Theory XSS, again Content Security Policy eet Source value: @Browser: this are you allowed to do with directive h S at_ e 'none' h _C y c i ol 'self' P _ y ritxss u 'unsafe inline' Attention: standard defense c _Se t n 'unsafe eval' bad nte o C Uri hp/ p. ex» trick only https:g/ind or» * Attention!asp..o w w ww Violations (json POST URI): / / : ps t t h Content Security Policy <key value> report uri <URI> See Support Chrome/ Firefox: good! IE 10/11 fragmentary Shameless plug: OWASP TT 2013

3. Theory

3. Theory CSP v2 (still W3C draft) 1. Whitelist scripts: Hash support Inline Code: <script> notevilstuff </script> Header: Content Security Policy: script src 'sha256 <base64 encoded hash( notevilstuff ))>'; 2. Whitelist script: Nonce Inline Code: <script nonce='n0n53'> notevilstuff </script> Header: Content Security Policy: script src 'nonce n0n53';

3. Theory CSP v2 (still W3C draft) 3. /4. Same whitelists with style src 5. frame ancestors

4. Where to set / unset? Depends... Your access Your hat on your head In principle 4 possibilities application application server configuration {server,web}.xml, web.config, php.ini etc. web server (configuration) reverse proxy / load balancer / WAF

4. Where to set / unset? What's the best place? KISS What ever is the easiest for you As long as the application still works Best At the root of the cause

4. Where to set / unset? Disclaimer: Obscurity & Security Do PROPER defense! Maybe protection against shodan search Otherwise: criminals throw everything @ target

4. Where to set / unset? Pitfalls Application needs still to work! Cookie: Secure, HTTPOnly, restricting domain scope Caching

5. Practice Two examples Looking @ Web servers (reverse proxy, resp.) Apache + nginx no IIS today Tasks 1. Minimize default verbosity 2. Provide / remove additional headers

5. Practice Apache Default configuration Server: Apache/2.2.3 (Linux/SUSE) Server: Apache/2.4.8 (Win32) OpenSSL/1.0.1b PHP/5.5.3 Server: Apache/2.2.17 (Ubuntu)PHP/5.3.5 1ubuntu7.5 with Suhosin Patch mod_python/3.3.1 Python/2.7.2 I. Secure defaults ServerTokens Prod (Header) Results in not enough? while you're at it: ServerSignature Off (Error) Server: Apache a2enmod security2; echo \ "ServerTokens Full\nSecServerSignature Microsoft IIS/8.0" \ >> /etc/<somepath>/mod*security*.conf omit Server: not possible (recompile)

5. Practice Apache II. Remove /add header lines a2enmod headers Header always set X FRAME OPTIONS sameorigin Header always set X Content Type Options nosniff Header always set X XSS Protection "1; mode=block" Header always set Strict Transport Security "max age=16070400" env=https Header edit Set Cookie "^(.*)" $1;Secure env=https Header edit Set Cookie "^(.*)" $1; HttpOnly Header unset "X Pingback" Header always unset "X Powered By" Header unset sap cache control

5. Practice nginx Default configuration Server: nginx/1.x.y I. Secure defaults remove banner (both error and header): server_tokens off; Enable module: ngx_headers_more more_set_headers Server: OWASP ru135 ; more_clear_headers Server: * ; II. Remove/add header lines more_set_headers more_clear_headers

5. Practice Remarks 1. As usual for nginx/apache: set/clear headers: per location possible! small fixes possible w/o access to app 2. PHP Better @ r00t of all evil e.g. php.ini: expose_php=off Same: real app server hardening

5. Practice Test it! - Tool from the outside - curl / wget / devel tools browser - Thorough functional tests! - BROWSERS!!