SlideShare a Scribd company logo
HTTP BASICS
WHERE ARE WE GOING?
HTTP Basics
HTTP Request Methods
HTTP Security Response Headers
Sensitive Data In Transit
Intercepting Proxy
Don’t Trust The HTTP Request!
WEB APPLICATION BEHAVIOUR
 HTTP is stateless. Requests and responses between browsers and servers have no shared memory.
Application layer sessions are needed to track state.
 Dynamic Scripting can occur on Server-Side (e.g. RoR, Django, ASP.NET, JSP, Express, etc) or on Client-
Side (Javascript, Flash, Applets).
 A web server or an application server can deliver HTML to be directly rendered by the web browser. Or,
the server might deliver data as JSON or XML to be processed by a Client-Side application in the
browser.
 Requests for data such as images, scripts, and stylesheets are typically retrieved using HTTP GET.
Requests from HTML forms typically submit data using HTTP POST. AJAX requests can additionally
submit HTTP requests of types PUT, PATCH, and DELETE.
WHAT ARE HTTP HEADERS?
HTTP headers are components of the message header of HTTP
Requests and Responses.
HTTP headers are used to define meta-information for an HTTP
transaction.
HTTP headers are colon-separated name-value pairs in clear-text
string format, terminated by a carriage return (r) and line feed
(n) character sequence.
http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
EXAMPLES OF HTTP REQUEST HEADERS
Authorization:
Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Accept:
text/plain
Content-Type:
application/x-www-form-urlencoded
User-Agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9;
rv:30.0) Gecko/20100101 Firefox/30.0
VALIDATING HTTP REQUEST HEADERS
 Are the headers themselves known to IANA?
 Are the number of headers received appropriate to the application context?
 Do each of the headers come with a pre-determined regular expression or equivalent for
validation?
 What headers are usually seen in context with other headers?
 How do I detect missing headers?
 Some headers occur in context of the application and are not global. For example, is a
cookie scoped to a domain?
 Some headers have time components to them such as expires. Is the header contextually
validated by date checks?
Official standard on HTTP Request Headers
https://www.iana.org/assignments/message-headers/message-headers.xhtml
HTTP REQUEST: GET VS POST
GET https://example.com/search.jsp?name=foo HTTP/1.0rn
User-Agent: Mozilla/4.0rn
Host: example.comrn
Cookie: SESSIONID=2KDSU72H9GSA289rn
rn
HTTP GET Request
POST https://example.com/search.jsp?data=jim HTTP/1.0rn
User-Agent: Mozilla/4.0rn
Host: example.comrn
Content-Length: 16rn
Cookie: SESSIONID=2KDSU72H9GSA289rn
rn
name=blah&type=1
rn
HTTP POST Request
TRIGGERING AN HTTP(S) GET
 Typing into a URL bar
 Bookmark selection
 <img> tag
 Loading a JS or CSS file
 Loading a Webfont
 HTML Form submission method="GET"
 jQuery.get() http://api.jquery.com/jQuery.get/
HTTP GET REQUEST: PLAINTEXT IMAGE
GET /personal/dancing/naked/inebriated/kauaifun.jpg HTTP/1.1rn
Host: images.manico.netrn
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:30.0)
Gecko/20100101 Firefox/30.0rn
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8rn
Accept-Language: en-US,en;q=0.5rn
Accept-Encoding: gzip, deflatern
DNT: 1rn
Connection: keep-alivern
rn
HTTP GET REQUEST:
INSECURE FORM SUBMISSIONGET
http://example.com/search?form_name=home&title=security&database=cli
ents HTTP/1.1rn
Host: example.comrn
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)rn
Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8rn
Accept-Language: en-us,en;q=0.5rn
Accept-Encoding: gzip,deflatern
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7rn
Keep-Alive: 300rn
Proxy-Connection: keep-alivern
Referer: http://company.com?username=Jim&pass=rp2h6jibalicern
HTTP GET SHOULD BE BORING
 Most web frameworks intentionally do not provide CSRF protection
for GET requests
 A GET request should not produce side effects. It should be
"Nullipotent".
 A GET request should only be used for data retrieval
 A GET request should NEVER be used for:
• Logging out a user
• Logging in a user
• Deleting a resource
• Modifying a resource
• Creating a resource
• Sending an email
HTTP GET PARAMETER LEAKAGE
 Bookmarks
 Browser History
 Proxy Server Logs
 Web Server Logs
 Referrer Request Headers
TRIGGERING AN HTTP/S POST
HTML Form POST Submission
jQuery.post() http://api.jquery.com/jQuery.post/
<form
action="https://acme-bank.example/payment"
method="POST"
id="payment-form">
$.post(
"https://acme-bank.example/payment",
function () {
$(".result").html("Payment was successful");
}
);
HTTP POST REQUEST
POST https://login.example.com:443/login.php?loginfail=3 HTTP/1.1rn
Host: login.example.comrn
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)rn
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8rn
Accept-Language: en-us,en;q=0.5rn
Accept-Encoding: gzip,deflatern
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7rn
Keep-Alive: 300rn
Connection: keep-alivern
Referer: https://www.example.com/rn
Cookie: JSessionID=1263464364617-95d75464239e7rn
Content-Type: application/x-www-form-urlencodedrn
Content-length: 224rn
rn
locale=en_US&email=joe@example.com&pass=letmein123!!Let
rn
HTTP PUT REQUEST
$.ajax(
"https://contact-manager.example/contacts/1234",
dataType: "json",
type: "PUT",
data: {
name: "John Doe",
email: "john.doe@example.com"
}
);
 An HTTP PUT request is used to replace a resource, or to create a new resource
where the identifier of the resource is known.
 The same security precautions that apply to an HTTP POST request should also
apply to a PUT request.
 Never send sensitive data in the query string of an HTTP PUT request
HTTP PATCH REQUEST
$.ajax(
"https://contact-manager.example/contacts/1234",
dataType: "json",
type: "PATCH",
data: {
email: "john.doe@example.com"
}
);
 An HTTP PATCH request is used to apply partial modifications to a
resource.
 The same security precautions that apply to an HTTP POST request should
also apply to a HTTP PATCH request.
 Never send sensitive data in the query string of an HTTP PATCH request
HTTP DELETE REQUEST
$.ajax(
"https://contact-manager.example/contacts/1234",
dataType: "json",
type: "DELETE"
);
 An HTTP DELETE request is used to delete a resource.
 The same security precautions that apply to an HTTP POST request should
also apply to a PUT request.
 Never send sensitive data in the query string of an HTTP PUT request.
 Not all web servers and application frameworks will allow for a message
body in an HTTP DELETE. Therefore, it is sometimes possible that
sensitive cannot be securely sent from an HTTP DELETE.
TRANSPORTING SENSITIVE DATA
 Never transmit sensitive data over HTTP/S GET
 Always use SSL for everything!
 In HTML forms, only submit sensitive data over HTTPS POST
 When using AJAX, submit sensitive data only using POST, PUT, and PATCH
 Only submit sensitive data only in the HTTPS REQUEST BODY
 Never submit sensitive data in the HTTP/S query string
EXAMPLE HTTP RESPONSE
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Cache-Control: no-cache, no-store, must-revalidate
Expires: -1
Content-Type: text/html; charset=UTF-8
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>WOOT HTML5</title>
</head>
<body>
<h1>I LOVE HTML</h1>
</body>
</html>
HTTP RESPONSE Set-Cookie HEADER
Set-Cookie: NAME=VALUE; expires=EXPIRES;
path=PATH; domain=DOMAIN;
secure; httponly;
Name The name of the cookie parameter
Value The parameter value
Expires The date at which to discard the cookie. If absent, the cookie will not be persistent, and will be discarded
when the browser is closed. If "-1", the cookie will be discarded immediately.
Domain The domain that the cookie applies to
Path The path that the cookie applies to
Secure Indicates that the cookie can only be used over secure HTTPS. USE THIS!
HttpOnly Indicates that the cookie can only be modified and accessed from the server. For example, JavaScript within
the browser application will not be able to access the cookie. USE THIS FOR SESSION IDs!
WHAT ARE HTTP RESPONSE HEADERS?
 HTTP headers are components of the message header of HTTP Responses.
 HTTP headers define different aspects of an HTTP transaction.
 HTTP headers are colon-separated name-value pairs in clear-text string
format, terminated by a carriage return (r) and line feed (n) character
sequence.
http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
HTTP RESPONSE SECURITY
HEADERS SUMMARY
X-Frame-Options
X-Xss-Protection
X-Content-Type-Options
Content Security Policy
Access-Control-Allow-Origin
HTTPS Strict Transport Security
Cache-Control / Pragma
HTTP RESPONSE SECURITY HEADERS
X-Frame-Options  Set to "SAMEORIGIN" to allow framing on same domain.
 Set to "DENY" to deny framing at all
 Set to "ALLOWALL" if you want to allow framing for all website
X-XSS-Protection  Set to "1; mode=block" to use XSS Auditor and block page if XSS attack is detected.
 Set to "0;" if you want to switch XSS Auditor off. This is useful if response contents scripts
from request parameters
X-Content-Security-Policy  A powerful mechanism for controlling which sites certain content types can be loaded
from
Access-Control-Allow-Origin  Used to control which sites are allowed to bypass same origin policies and send cross-
origin requests.
Strict-Transport-Security  Used to control if the browser is allowed to only access a site over a secure connection
Cache-Control  Used to control mandatory content caching rules
HTTP RESPONSE HEADER:
X-Frame-Options
Protects you from most classes of
Clickjacking
X-Frame-Options: DENY
X-Frame-Options: SAMEORIGIN
X-Frame-Options: ALLOW FROM
example.com
HTTP RESPONSE HEADER:
X-Xss-Protection
X-Xss-Protection: 0;
Use the browser’s built-in XSS auditor:
X-Xss-Protection: 1; mode=block
Disable the browser’s built-in XSS auditor:
CONTENT SECURITY POLICY
 Move all inline script and style into separate files
 Add the X-Content-Security-Policy response header to
instruct the browser that CSP is in use
 Define a policy for the site regarding loading of content
Anti-XSS W3C standard
http://www.w3.org/TR/CSP/
CSP Support Statistics
http://caniuse.com/#feat=contentsecuritypolicy
CSP Example Usage
http://content-security-policy.com/
OTHER SSL FAILS
Posting passwords or other sensitive data over HTTP
Using weak version of SSL
Using weak ciphers
Terminating SSL early in your infrastructure
Trusting the CA system 
HTTP RESPONSE HEADER:
Strict-Transport-Security
Forces your browser to always use HTTPS
Strict-transport-security: max-age=10000000; includeSubdomains
Base case:
Strict-transport-security: max-age=10000000
Do all of your subdomains support SSL?
DISABLING THE BROWSER CACHE
Add the following as part of your HTTP Response:
Cache-Control: no-store, no-cache, must-revalidate
Expires: -1
APPLY ALL THE HEADERS!
strict-transport-security: max-age=631138519rn
version: HTTP/1.1rn
x-frame-options: SAMEORIGINrn
x-gitsha: d814fdf74482e7b82c1d9f0344a59dd1d6a700a6rn
x-rack-cache: missrn
x-request-id: 746d48ca76dc0766ac24e74fa905be11rn
x-runtime: 0.023473rn
x-ua-compatible: IE=Edge,chrome=1rn
x-webkit-csp-report-only: default-src 'none'; script-src 'self'; connect-src 'self'; img-src
'self'; style-src 'self’rn
content-security-policy-report-only: default-src 'none'; script-src 'self'; connect-src
'self'; img-src 'self'; style-src 'self’rn
x-content-security-policy-report-only: default-src 'none'; script-src 'self'; connect-src
'self'; img-src 'self'; style-src 'self’rn
ASVS 2 HTTP REQUIREMENTS:
EASY
V11.2 Verify that the application accepts only a defined set of HTTP request methods, such as
GET and POST and unused methods are explicitly blocked.
V11.3 Verify that every HTTP response contains a content type header specifying a safe character
set (e.g., UTF-8).
V11.8 Verify that HTTP headers and / or other mechanisms for older browsers have been
included to protect against clickjacking attacks.
ASVS 2 HTTP REQUIREMENTS:
INTERMEDIATE
V11.6 Verify that HTTP headers in both requests and responses contain only printable ASCII
characters.
V11.9 Verify that HTTP headers added by a frontend (such as X-Real-IP), and used by the
application, cannot be spoofed by the end user.
V11.10 Verify that the HTTP header, X-Frame-Options is in use for sites where content should not
be viewed in a 3rd-party X-Frame. A common middle ground is to send SAMEORIGIN,
meaning only websites of the same origin may frame it.
V11.12 Verify that the HTTP headers do not expose detailed version information of system
components.
HTTP Basics
HTTP Request Methods
HTTP Security Response Headers
Sensitive Data In Transit
Intercepting Proxy
Don’t Trust The HTTP Request!
SUMMARY

More Related Content

PDF
RESTful Web Services
PPTX
Overview of RESTful web services
PDF
Doing REST Right
PPT
RESTful SOA - 中科院暑期讲座
PPTX
Restful webservices
PDF
The never-ending REST API design debate -- Devoxx France 2016
ODP
RESTful Web Services with JAX-RS
PDF
REST API Recommendations
RESTful Web Services
Overview of RESTful web services
Doing REST Right
RESTful SOA - 中科院暑期讲座
Restful webservices
The never-ending REST API design debate -- Devoxx France 2016
RESTful Web Services with JAX-RS
REST API Recommendations

What's hot (19)

PPTX
Restful webservice
PPTX
Rest & RESTful WebServices
PDF
RESTful http_patterns_antipatterns
PDF
Rest web services
PPT
RESTful services
PDF
Representational State Transfer (REST) and HATEOAS
PPTX
PPT
External Data Access with jQuery
PPT
Source Code Analysis with SAST
PPT
HTTP protocol and Streams Security
PPTX
ASP.NET WEB API
PPT
KMUTNB - Internet Programming 2/7
PPTX
Web Security - Cookies, Domains and CORS
PDF
Making Java REST with JAX-RS 2.0
PPTX
Implementation advantages of rest
PPT
Understanding REST
PPTX
Soap and restful webservice
PDF
Cross site calls with javascript - the right way with CORS
PPTX
Elegant Rest Design Webinar
Restful webservice
Rest & RESTful WebServices
RESTful http_patterns_antipatterns
Rest web services
RESTful services
Representational State Transfer (REST) and HATEOAS
External Data Access with jQuery
Source Code Analysis with SAST
HTTP protocol and Streams Security
ASP.NET WEB API
KMUTNB - Internet Programming 2/7
Web Security - Cookies, Domains and CORS
Making Java REST with JAX-RS 2.0
Implementation advantages of rest
Understanding REST
Soap and restful webservice
Cross site calls with javascript - the right way with CORS
Elegant Rest Design Webinar
Ad

Viewers also liked (8)

PDF
JavaDayIV - Leoncini Writing Restful Applications With Resteasy
PPT
Introduction to API Design: REST and Java
PDF
RESTful Web Services with Jersey
PDF
Tech Meetup: How to build a Rest API in Java
PDF
Servicio y Consumo de Servicios REST en PHP
ODP
Infinispan and Enterprise Data Grid
PDF
Rest api design by george reese
PPTX
Building RESTful Java Applications with EMF
JavaDayIV - Leoncini Writing Restful Applications With Resteasy
Introduction to API Design: REST and Java
RESTful Web Services with Jersey
Tech Meetup: How to build a Rest API in Java
Servicio y Consumo de Servicios REST en PHP
Infinispan and Enterprise Data Grid
Rest api design by george reese
Building RESTful Java Applications with EMF
Ad

Similar to 01. http basics v27 (20)

PPT
Http request&response
PPT
Http request&response session 1 - by Vignesh.N
PPT
Http request&response by Vignesh 15 MAR 2014
KEY
Webapp security testing
KEY
Webapp security testing
PDF
CNIT 129S - Ch 3: Web Application Technologies
PDF
CNIT 129S: Ch 3: Web Application Technologies
PDF
HTTP Request and Response Structure
PPTX
http presentation 1.pptx
PDF
Ch 3: Web Application Technologies
PPTX
HTTP fundamentals for developers
PPTX
Chapter 2: Web application technologies
PDF
Communicating on the web
PPT
Hyper text transport protocol
PPTX
Http - All you need to know
PPTX
PPTX
www and http services
PPTX
Lesson 6 web based attacks
PPTX
PDF
Web I - 05 - HTTP Protocol
Http request&response
Http request&response session 1 - by Vignesh.N
Http request&response by Vignesh 15 MAR 2014
Webapp security testing
Webapp security testing
CNIT 129S - Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application Technologies
HTTP Request and Response Structure
http presentation 1.pptx
Ch 3: Web Application Technologies
HTTP fundamentals for developers
Chapter 2: Web application technologies
Communicating on the web
Hyper text transport protocol
Http - All you need to know
www and http services
Lesson 6 web based attacks
Web I - 05 - HTTP Protocol

More from Eoin Keary (20)

PPTX
IISF-March2023.pptx
PDF
Validation of vulnerabilities.pdf
PDF
Does a Hybrid model for vulnerability Management Make Sense.pdf
PDF
Edgescan 2022 Vulnerability Statistics Report
PPTX
Edgescan 2021 Vulnerability Stats Report
PPTX
One login enemy at the gates
PDF
Edgescan vulnerability stats report 2020
PDF
edgescan vulnerability stats report (2018)
PDF
edgescan vulnerability stats report (2019)
PPTX
Full stack vulnerability management at scale
PPTX
Vulnerability Intelligence - Standing Still in a world full of change
PPTX
Edgescan vulnerability stats report 2019 - h-isac-2-2-2019
PPTX
Hide and seek - Attack Surface Management and continuous assessment.
PPTX
Online Gaming Cyber security and Threat Model
PPTX
Keeping the wolf from 1000 doors.
PPTX
Security by the numbers
PPTX
Web security – everything we know is wrong cloud version
PPTX
Cybersecurity by the numbers
PPTX
Ebu class edgescan-2017
PPTX
Vulnerability management and threat detection by the numbers
IISF-March2023.pptx
Validation of vulnerabilities.pdf
Does a Hybrid model for vulnerability Management Make Sense.pdf
Edgescan 2022 Vulnerability Statistics Report
Edgescan 2021 Vulnerability Stats Report
One login enemy at the gates
Edgescan vulnerability stats report 2020
edgescan vulnerability stats report (2018)
edgescan vulnerability stats report (2019)
Full stack vulnerability management at scale
Vulnerability Intelligence - Standing Still in a world full of change
Edgescan vulnerability stats report 2019 - h-isac-2-2-2019
Hide and seek - Attack Surface Management and continuous assessment.
Online Gaming Cyber security and Threat Model
Keeping the wolf from 1000 doors.
Security by the numbers
Web security – everything we know is wrong cloud version
Cybersecurity by the numbers
Ebu class edgescan-2017
Vulnerability management and threat detection by the numbers

Recently uploaded (20)

PDF
The New Creative Director: How AI Tools for Social Media Content Creation Are...
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PPTX
Introuction about WHO-FIC in ICD-10.pptx
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PPTX
artificial intelligence overview of it and more
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
PDF
Cloud-Scale Log Monitoring _ Datadog.pdf
PDF
Testing WebRTC applications at scale.pdf
PPTX
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
PPTX
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
PPTX
Introuction about ICD -10 and ICD-11 PPT.pptx
PPTX
Digital Literacy And Online Safety on internet
PPTX
Funds Management Learning Material for Beg
PPTX
PptxGenJS_Demo_Chart_20250317130215833.pptx
PDF
RPKI Status Update, presented by Makito Lay at IDNOG 10
PPTX
introduction about ICD -10 & ICD-11 ppt.pptx
PPTX
innovation process that make everything different.pptx
PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
PDF
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
The New Creative Director: How AI Tools for Social Media Content Creation Are...
An introduction to the IFRS (ISSB) Stndards.pdf
Introuction about WHO-FIC in ICD-10.pptx
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
artificial intelligence overview of it and more
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
Cloud-Scale Log Monitoring _ Datadog.pdf
Testing WebRTC applications at scale.pdf
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
Introuction about ICD -10 and ICD-11 PPT.pptx
Digital Literacy And Online Safety on internet
Funds Management Learning Material for Beg
PptxGenJS_Demo_Chart_20250317130215833.pptx
RPKI Status Update, presented by Makito Lay at IDNOG 10
introduction about ICD -10 & ICD-11 ppt.pptx
innovation process that make everything different.pptx
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
Unit-1 introduction to cyber security discuss about how to secure a system

01. http basics v27

  • 2. WHERE ARE WE GOING? HTTP Basics HTTP Request Methods HTTP Security Response Headers Sensitive Data In Transit Intercepting Proxy Don’t Trust The HTTP Request!
  • 3. WEB APPLICATION BEHAVIOUR  HTTP is stateless. Requests and responses between browsers and servers have no shared memory. Application layer sessions are needed to track state.  Dynamic Scripting can occur on Server-Side (e.g. RoR, Django, ASP.NET, JSP, Express, etc) or on Client- Side (Javascript, Flash, Applets).  A web server or an application server can deliver HTML to be directly rendered by the web browser. Or, the server might deliver data as JSON or XML to be processed by a Client-Side application in the browser.  Requests for data such as images, scripts, and stylesheets are typically retrieved using HTTP GET. Requests from HTML forms typically submit data using HTTP POST. AJAX requests can additionally submit HTTP requests of types PUT, PATCH, and DELETE.
  • 4. WHAT ARE HTTP HEADERS? HTTP headers are components of the message header of HTTP Requests and Responses. HTTP headers are used to define meta-information for an HTTP transaction. HTTP headers are colon-separated name-value pairs in clear-text string format, terminated by a carriage return (r) and line feed (n) character sequence. http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
  • 5. EXAMPLES OF HTTP REQUEST HEADERS Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== Accept: text/plain Content-Type: application/x-www-form-urlencoded User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:30.0) Gecko/20100101 Firefox/30.0
  • 6. VALIDATING HTTP REQUEST HEADERS  Are the headers themselves known to IANA?  Are the number of headers received appropriate to the application context?  Do each of the headers come with a pre-determined regular expression or equivalent for validation?  What headers are usually seen in context with other headers?  How do I detect missing headers?  Some headers occur in context of the application and are not global. For example, is a cookie scoped to a domain?  Some headers have time components to them such as expires. Is the header contextually validated by date checks? Official standard on HTTP Request Headers https://www.iana.org/assignments/message-headers/message-headers.xhtml
  • 7. HTTP REQUEST: GET VS POST GET https://example.com/search.jsp?name=foo HTTP/1.0rn User-Agent: Mozilla/4.0rn Host: example.comrn Cookie: SESSIONID=2KDSU72H9GSA289rn rn HTTP GET Request POST https://example.com/search.jsp?data=jim HTTP/1.0rn User-Agent: Mozilla/4.0rn Host: example.comrn Content-Length: 16rn Cookie: SESSIONID=2KDSU72H9GSA289rn rn name=blah&type=1 rn HTTP POST Request
  • 8. TRIGGERING AN HTTP(S) GET  Typing into a URL bar  Bookmark selection  <img> tag  Loading a JS or CSS file  Loading a Webfont  HTML Form submission method="GET"  jQuery.get() http://api.jquery.com/jQuery.get/
  • 9. HTTP GET REQUEST: PLAINTEXT IMAGE GET /personal/dancing/naked/inebriated/kauaifun.jpg HTTP/1.1rn Host: images.manico.netrn User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:30.0) Gecko/20100101 Firefox/30.0rn Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8rn Accept-Language: en-US,en;q=0.5rn Accept-Encoding: gzip, deflatern DNT: 1rn Connection: keep-alivern rn
  • 10. HTTP GET REQUEST: INSECURE FORM SUBMISSIONGET http://example.com/search?form_name=home&title=security&database=cli ents HTTP/1.1rn Host: example.comrn User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)rn Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8rn Accept-Language: en-us,en;q=0.5rn Accept-Encoding: gzip,deflatern Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7rn Keep-Alive: 300rn Proxy-Connection: keep-alivern Referer: http://company.com?username=Jim&pass=rp2h6jibalicern
  • 11. HTTP GET SHOULD BE BORING  Most web frameworks intentionally do not provide CSRF protection for GET requests  A GET request should not produce side effects. It should be "Nullipotent".  A GET request should only be used for data retrieval  A GET request should NEVER be used for: • Logging out a user • Logging in a user • Deleting a resource • Modifying a resource • Creating a resource • Sending an email
  • 12. HTTP GET PARAMETER LEAKAGE  Bookmarks  Browser History  Proxy Server Logs  Web Server Logs  Referrer Request Headers
  • 13. TRIGGERING AN HTTP/S POST HTML Form POST Submission jQuery.post() http://api.jquery.com/jQuery.post/ <form action="https://acme-bank.example/payment" method="POST" id="payment-form"> $.post( "https://acme-bank.example/payment", function () { $(".result").html("Payment was successful"); } );
  • 14. HTTP POST REQUEST POST https://login.example.com:443/login.php?loginfail=3 HTTP/1.1rn Host: login.example.comrn User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)rn Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8rn Accept-Language: en-us,en;q=0.5rn Accept-Encoding: gzip,deflatern Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7rn Keep-Alive: 300rn Connection: keep-alivern Referer: https://www.example.com/rn Cookie: JSessionID=1263464364617-95d75464239e7rn Content-Type: application/x-www-form-urlencodedrn Content-length: 224rn rn locale=en_US&email=joe@example.com&pass=letmein123!!Let rn
  • 15. HTTP PUT REQUEST $.ajax( "https://contact-manager.example/contacts/1234", dataType: "json", type: "PUT", data: { name: "John Doe", email: "john.doe@example.com" } );  An HTTP PUT request is used to replace a resource, or to create a new resource where the identifier of the resource is known.  The same security precautions that apply to an HTTP POST request should also apply to a PUT request.  Never send sensitive data in the query string of an HTTP PUT request
  • 16. HTTP PATCH REQUEST $.ajax( "https://contact-manager.example/contacts/1234", dataType: "json", type: "PATCH", data: { email: "john.doe@example.com" } );  An HTTP PATCH request is used to apply partial modifications to a resource.  The same security precautions that apply to an HTTP POST request should also apply to a HTTP PATCH request.  Never send sensitive data in the query string of an HTTP PATCH request
  • 17. HTTP DELETE REQUEST $.ajax( "https://contact-manager.example/contacts/1234", dataType: "json", type: "DELETE" );  An HTTP DELETE request is used to delete a resource.  The same security precautions that apply to an HTTP POST request should also apply to a PUT request.  Never send sensitive data in the query string of an HTTP PUT request.  Not all web servers and application frameworks will allow for a message body in an HTTP DELETE. Therefore, it is sometimes possible that sensitive cannot be securely sent from an HTTP DELETE.
  • 18. TRANSPORTING SENSITIVE DATA  Never transmit sensitive data over HTTP/S GET  Always use SSL for everything!  In HTML forms, only submit sensitive data over HTTPS POST  When using AJAX, submit sensitive data only using POST, PUT, and PATCH  Only submit sensitive data only in the HTTPS REQUEST BODY  Never submit sensitive data in the HTTP/S query string
  • 19. EXAMPLE HTTP RESPONSE HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Cache-Control: no-cache, no-store, must-revalidate Expires: -1 Content-Type: text/html; charset=UTF-8 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>WOOT HTML5</title> </head> <body> <h1>I LOVE HTML</h1> </body> </html>
  • 20. HTTP RESPONSE Set-Cookie HEADER Set-Cookie: NAME=VALUE; expires=EXPIRES; path=PATH; domain=DOMAIN; secure; httponly; Name The name of the cookie parameter Value The parameter value Expires The date at which to discard the cookie. If absent, the cookie will not be persistent, and will be discarded when the browser is closed. If "-1", the cookie will be discarded immediately. Domain The domain that the cookie applies to Path The path that the cookie applies to Secure Indicates that the cookie can only be used over secure HTTPS. USE THIS! HttpOnly Indicates that the cookie can only be modified and accessed from the server. For example, JavaScript within the browser application will not be able to access the cookie. USE THIS FOR SESSION IDs!
  • 21. WHAT ARE HTTP RESPONSE HEADERS?  HTTP headers are components of the message header of HTTP Responses.  HTTP headers define different aspects of an HTTP transaction.  HTTP headers are colon-separated name-value pairs in clear-text string format, terminated by a carriage return (r) and line feed (n) character sequence. http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
  • 22. HTTP RESPONSE SECURITY HEADERS SUMMARY X-Frame-Options X-Xss-Protection X-Content-Type-Options Content Security Policy Access-Control-Allow-Origin HTTPS Strict Transport Security Cache-Control / Pragma
  • 23. HTTP RESPONSE SECURITY HEADERS X-Frame-Options  Set to "SAMEORIGIN" to allow framing on same domain.  Set to "DENY" to deny framing at all  Set to "ALLOWALL" if you want to allow framing for all website X-XSS-Protection  Set to "1; mode=block" to use XSS Auditor and block page if XSS attack is detected.  Set to "0;" if you want to switch XSS Auditor off. This is useful if response contents scripts from request parameters X-Content-Security-Policy  A powerful mechanism for controlling which sites certain content types can be loaded from Access-Control-Allow-Origin  Used to control which sites are allowed to bypass same origin policies and send cross- origin requests. Strict-Transport-Security  Used to control if the browser is allowed to only access a site over a secure connection Cache-Control  Used to control mandatory content caching rules
  • 24. HTTP RESPONSE HEADER: X-Frame-Options Protects you from most classes of Clickjacking X-Frame-Options: DENY X-Frame-Options: SAMEORIGIN X-Frame-Options: ALLOW FROM example.com
  • 25. HTTP RESPONSE HEADER: X-Xss-Protection X-Xss-Protection: 0; Use the browser’s built-in XSS auditor: X-Xss-Protection: 1; mode=block Disable the browser’s built-in XSS auditor:
  • 26. CONTENT SECURITY POLICY  Move all inline script and style into separate files  Add the X-Content-Security-Policy response header to instruct the browser that CSP is in use  Define a policy for the site regarding loading of content Anti-XSS W3C standard http://www.w3.org/TR/CSP/ CSP Support Statistics http://caniuse.com/#feat=contentsecuritypolicy CSP Example Usage http://content-security-policy.com/
  • 27. OTHER SSL FAILS Posting passwords or other sensitive data over HTTP Using weak version of SSL Using weak ciphers Terminating SSL early in your infrastructure Trusting the CA system 
  • 28. HTTP RESPONSE HEADER: Strict-Transport-Security Forces your browser to always use HTTPS Strict-transport-security: max-age=10000000; includeSubdomains Base case: Strict-transport-security: max-age=10000000 Do all of your subdomains support SSL?
  • 29. DISABLING THE BROWSER CACHE Add the following as part of your HTTP Response: Cache-Control: no-store, no-cache, must-revalidate Expires: -1
  • 30. APPLY ALL THE HEADERS! strict-transport-security: max-age=631138519rn version: HTTP/1.1rn x-frame-options: SAMEORIGINrn x-gitsha: d814fdf74482e7b82c1d9f0344a59dd1d6a700a6rn x-rack-cache: missrn x-request-id: 746d48ca76dc0766ac24e74fa905be11rn x-runtime: 0.023473rn x-ua-compatible: IE=Edge,chrome=1rn x-webkit-csp-report-only: default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self'; style-src 'self’rn content-security-policy-report-only: default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self'; style-src 'self’rn x-content-security-policy-report-only: default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self'; style-src 'self’rn
  • 31. ASVS 2 HTTP REQUIREMENTS: EASY V11.2 Verify that the application accepts only a defined set of HTTP request methods, such as GET and POST and unused methods are explicitly blocked. V11.3 Verify that every HTTP response contains a content type header specifying a safe character set (e.g., UTF-8). V11.8 Verify that HTTP headers and / or other mechanisms for older browsers have been included to protect against clickjacking attacks.
  • 32. ASVS 2 HTTP REQUIREMENTS: INTERMEDIATE V11.6 Verify that HTTP headers in both requests and responses contain only printable ASCII characters. V11.9 Verify that HTTP headers added by a frontend (such as X-Real-IP), and used by the application, cannot be spoofed by the end user. V11.10 Verify that the HTTP header, X-Frame-Options is in use for sites where content should not be viewed in a 3rd-party X-Frame. A common middle ground is to send SAMEORIGIN, meaning only websites of the same origin may frame it. V11.12 Verify that the HTTP headers do not expose detailed version information of system components.
  • 33. HTTP Basics HTTP Request Methods HTTP Security Response Headers Sensitive Data In Transit Intercepting Proxy Don’t Trust The HTTP Request! SUMMARY

Editor's Notes

  • #2: 1
  • #4: The stateless nature of HTTP means that abstractions need to be used in order to create a persistence layer between the client and server. This creates complexities which are responsible for many web security issues. Websockets was primarily designed to provide full-duplex communication between web browser and server. The initiation of the websockets session is handled through via HTTP, but it otherwise acts independently of HTTP. However, because it allows for communication to the browser, it opens up possible attack vectors. Although traditional web forms primarily use GET and POST, many contemporary SPAs make extensive use of PUT/PATCH/DELETE. An SPA is a "Single Page Application". Examples of frameworks used to build SPAs would be BackboneJS, Angular, and EmberJS.
  • #5: Http headers can be thought of the addressing information on the outside of a postage envelope.
  • #6: The Authorization header is built-in method for the browser to send identification credentials for a user to the web server. This header should only be used over HTTPS. The Accept header allows the browser to identify to the server which kinds of content it is expecting in the HTTP response. The Content-Type header tells the browser what kind of content is being sent in the request. The User-Agent identifies information about the browser to the web server.
  • #7: Not all headers will be known to IANA. Some applications might need to make use of custom request headers. In this case, the application should check the custom request headers against a whitelist within the application.
  • #10: For your safety, you are advised to not download kauaifun.jpg
  • #11: Some of the security problems here are: The GET URL contains sensitive parameters. These can turn up in log files and analytics tools. The Referer URL contains sensitive parameters. These can turn up in log files and analytics tools. The JSESSIONID is being sent over an insecure (non HTTPS) connection. This could allow for a session-hijacking attack.
  • #12: RFC 2616 #9.1.1: "the GET and HEAD methods SHOULD NOT have the significance of taking an action other than retrieval" Nullipotent means "No Power". https://en.wiktionary.org/wiki/nullipotent: Describes "nullipotent" as "an action which has no side effect. Queries are typically nullipotent: they return useful data, but do not change the data structure queried."
  • #13: Bookmarks: Bookmarks are not stored securely, leaving URLs open to a potential attacker. Browser History: Browser history is not stored securely, leaving URLs open to a potential attacker. Proxy Server Logs: Proxies can potentially be operated by persons with malicious intentions. Even trustworthy proxies are susceptible to intrusions, which could reveal proxy logs to an attacker. Web Server Logs: In the event that a web server is compromised, an attacker could have access to web server logs which could reveal sensitive information in URLs. Referer: The HTTP 1.1 RFC explicitly states: "Clients SHOULD NOT include a Referer header field in a (non-secure) HTTP request if the referring page was transferred with a secure protocol."
  • #14: rfc2616, section 15.1.3 recommends that sensitive data should not be sent in a form submission which has method="GET". But, it is a good idea to take this a step further, and simply never use method="GET" at all as a general good practice.
  • #16: RFC 2616 #9.6: "The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. If the Request-URI does not point to an existing resource, and that URI is capable of being defined as a new resource by the requesting user agent, the origin server can create the resource with that URI." HTTP PUT is useful when designing RESTful web applications
  • #17: RFC 5789 #2: "The PATCH method requests that a set of changes described in the request entity be applied to the resource identified by the Request-URI. The set of changes is represented in a format called a "patch document" identified by a media type. If the Request-URI does not point to an existing resource, the server MAY create a new resource, depending on the patch document type." HTTP PATCH is useful when designing RESTful web applications, although opinions on how it should be properly implemented are varied.
  • #18: RFC 2616 #9.7: "The DELETE method requests that the origin server delete the resource identified by the Request-URI. This method MAY be overridden by human intervention (or other means) on the origin server. The client cannot be guaranteed that the operation has been carried out, even if the status code returned from the origin server indicates that the action has been completed successfully. However, the server SHOULD NOT indicate success unless, at the time the response is given, it intends to delete the resource or move it to an inaccessible location." HTTP DELETE is useful when designing RESTful web applications
  • #20: The body is HTML5 markup: http://www.w3.org/TR/html5/
  • #25: JM: Save resources since nothing is framed BC: Use "DENY" whenever possible
  • #26: BC: Surprisingly, it seems difficult to find information on the actual algorithms the XSS protection uses
  • #27: BC: Talk about when/how to use CSP vs when/how to use CORS? BC: This is a very interesting topic. Perhaps add visual examples to slide?
  • #28: BC: Heartbleed as example of insecure SSL version
  • #29: BC: Run site through SSL checker https://www.ssllabs.com/ssltest/
  • #30: // HTTP 1.1 response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); response.setDateHeader("Expires", -1); // HTTP 1.0 response.setHeader("Pragma","no-cache"); response.setDateHeader("Expires", -1);