SlideShare une entreprise Scribd logo
1  sur  27
Télécharger pour lire hors ligne
HTTP SECURITY HEADERS
(Protection For Browsers)
BIO
Bug bounty student by night – 1st Private Invite on Hackerone
• Emmanuel JK Gbordzor
ISO 27001 LI, CISA, CCNA, CCNA-Security, ITILv3, …
11 years in IT – About 2 years In Security
Information Security Manager @ PaySwitch
Head, Network & Infrastructure @ PaySwitch
Head of IT @ Financial Institution
Introduction
• In this presentation, I will introduce you to HyperText Transfer
Protocol (HTTP) response security headers.
• By specifying expected and allowable behaviors, we will see how
security headers can prevent a number of attacks against websites.
• I’ll explain some of the different HTTP response headers that a web
server can include in a response, and what impact they can have on
the security of the web browser.
• How web developers can implement these security headers to make
user experience more secure
A Simple Look At Web Browsing
Snippet At The Request And Response Headers
Why
Browser
Security
Headers?
Browser Security Headers help:
➢ to define whether a set of security
precautions should be activated or
deactivated on the web browser.
➢ to reinforce the security of your web
browser to fend off attacks and to
mitigate vulnerabilities.
➢ in fighting client side (browser)
attacks such as clickjacking,
injections, Multipurpose Internet
Mail Extensions (MIME) sniffing,
Cross-Site Scripting (XSS), etc.
Content / Context
HTTP STRICT
TRANSPORT SECURITY
(HSTS)
X-FRAME-OPTIONS EXPECT-CT
CONTENT-SECURITY-
POLICY
X-XSS-PROTECTION X-CONTENT-TYPE-
OPTIONS
HTTP Strict Transport Security (HSTS)
• HSTS header forces browsers to communicate using
secure (HTTPS) connection.
• Protects against “downgrade attacks”
• When configured with the “Preload” option, it can
prevent Man-In-The-Middle (MiTM) attack
• “Preload” - https://hstspreload.org/ - from google
HTTP Redirection To HTTPS
HTTP Redirection To HTTPS - Continued
HTTP Strict Transport Security (HSTS) - Implementation
Syntax:
Strict-Transport-Security: max-age=<expire-time>
includeSubDomains
preload
Apache:
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload“
Nginx:
add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains; preload';
Microsoft IIS:
Name: Strict-Transport-Security
Value: max-age=31536000; includeSubDomains; preload
X-Frame-
Options
• An iFrame is an element that
allows a web app to be
nested within a parent web
app.
• Can be used maliciously for a
clickjacking attack or loading
a malicious website inside
the frame
Prevention:
• Frame busting
• X-Frame-Option Header
X-Frame-Options - Implementation
Apache:
Header always set X-Frame-Options “deny”
Nginx:
add_header X-Frame-Options “DENY”;
WordPress:
header('X-Frame-Options: DENY);
Microsoft IIS:
Name: X-Frame-Options
Value: DENY
Syntax:
X-Frame-Options: deny
sameorigin
allow-from url (deprecated)
Expect-CT
• HTTP Public Key Pinning (HPKP) header is being
deprecated to Expect-CT
• Expect-CT detects certificates issued by rogue Certificate
Authorities (CA) or prevents them from doing so
• This header prevents MiTM attack against compromised
Certificate Authority (CA) and rogue issued certificate
Expect-CT - Implementation
Apache:
Header set Expect-CT 'enforce, max-age=86400, report-uri="https://foo.example/report“’
Nginx:
add_header Expect-CT 'max-age=60, report-uri="https://mydomain.com/report"';
Syntax:
Expect-CT: max-age
enforce
report-uri
Content-Security-Policy (CSP)
When this header is well implemented, there is no
need to implement “X-Frame-Options” and “X-XSS-
Protection” headers
This helps prevents XSS, clickjacking, code
injection, etc., attacks
This header helps you to whitelist sources of
approved content into your browser hence,
preventing the browser from loading malicious
assets.
Content-Security-Policy - Directives
Keywords: *, none, self, hosts
Content-Security-Policy:
default-src Serves as a fallback for the other fetch directives
font-src Specifies valid sources for fonts loaded
frame-src Sources for nested contexts such as <frame> and <iframe>
img-src Sources of images and favicons
media-src Valid sources for loading <audio>, <video> & <track>
object-src Sources for the <object>, <embed> and <applet> elements
script-src Specifies valid sources for JavaScript
style-src Specifies valid sources for stylesheets
report-uri Reports violations
CSP Sample - https://haveibeenpwned.com
content-security-policy: default-src 'none';script-src
'self' www.google-analytics.com www.google.com
www.gstatic. js.stripe.com ajax.cloudflare.com;style-src
'self' 'unsafe-inline' cdnjs.cloudflare.com;img-src 'self'
www.google-analytics.com stats.g.doubleclick.net
www.gstatic.com;font-src 'self' cdnjs.cloudflare.com
fonts.gstatic.com;base-uri 'self';child-src
www.google.com js.stripe.com;frame-ancestors
'none';report-uri https://troyhunt.report-
uri.com/r/d/csp/enforce.com/en_US/i/scr/pixel.gif;"
X-XSS-
Protection
These header detect
dangerous HTML
input and either
prevent the site from
loading or remove
potentially malicious
scripts
X-XSS-Protection - Implementation
Syntax:
X-XSS-Protection: 0
1
mode=block
Apache:
Header set X-XSS-Protection "1; mode=block“
Nginx:
add_header X-XSS-Protection "1; mode=block";
Microsoft IIS:
Name: X-XSS-Protection
Value: 1; mode=block
X-Content-Type-Options
• For your seamless experience on the web, MIME
sniffing of resource was introduced.
• Adversely, an attacker can introduce a malicious
executable script such as an image. When acted
on by MIME sniffing could have the script
executed.
X-Content-Type-Options - Implementation
Syntax:
X-Content-Type-Options: nosniff
Apache:
Header set X-Content-Type-Options nosniff
Nginx:
add_header X-Content-Type-Options nosniff;
Microsoft IIS:
Name: X-Content-Type-Options
Value: nosniff
Demo Time
– Clickjacking
– iFrame injection
– Harlem shake
https://127.0.0.1/mutillidae/
Takeaways
• Enforce HTTPS using the Strict-Transport-Security header and add your
domain to Chrome’s preload list.
• Make your web app more robust against XSS by leveraging the X-XSS-
Protection header.
• Block clickjacking using the X-Frame-Options header.
• Leverage Content-Security-Policy to whitelist specific sources and
endpoints.
• Prevent MIME-sniffing attacks using the X-Content-Type-Options header.
Resources / Tools
• Check Website HTTP Response Header
– https://gf.dev/http-headers-test
• Secure Headers Test
– https://gf.dev/secure-headers-test
• Scott Helme – Security Header Scanner
– https://securityheaders.com
• HTTP Headers Reference
– https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
• HTTP Compatibility Among Browsers
– https://caniuse.com
References
• https://www.netsparker.com/whitepaper-http-
security-headers
• https://www.ntu.edu.sg/home/ehchua/programming/
webprogramming/HTTP_Basics.html
• https://owasp.org/www-chapter-ghana/#div-
pastevents
• https://www.keycdn.com/blog/http-security-headers
THANK YOU
Let’s Connect:
@egbordzor
linkedin.com/in/egbordzor
egbordzor@protonmail.com
Questions And Answers

Contenu connexe

Similaire à HTTP_Header_Security.pdf

Content-Security-Policy 2018.0
Content-Security-Policy 2018.0Content-Security-Policy 2018.0
Content-Security-Policy 2018.0Philippe Gamache
 
Csp and http headers
Csp and http headersCsp and http headers
Csp and http headersdevObjective
 
CONFidence 2018: Defense-in-depth techniques for modern web applications and ...
CONFidence 2018: Defense-in-depth techniques for modern web applications and ...CONFidence 2018: Defense-in-depth techniques for modern web applications and ...
CONFidence 2018: Defense-in-depth techniques for modern web applications and ...PROIDEA
 
Top Ten Web Hacking Techniques – 2008
Top Ten Web Hacking Techniques – 2008Top Ten Web Hacking Techniques – 2008
Top Ten Web Hacking Techniques – 2008Jeremiah Grossman
 
Content Security Policy - Lessons learned at Yahoo
Content Security Policy - Lessons learned at YahooContent Security Policy - Lessons learned at Yahoo
Content Security Policy - Lessons learned at YahooBinu Ramakrishnan
 
http security response headers for web security
http security response headers for web securityhttp security response headers for web security
http security response headers for web securityOlatunji Adetunji
 
Defeating Cross-Site Scripting with Content Security Policy (updated)
Defeating Cross-Site Scripting with Content Security Policy (updated)Defeating Cross-Site Scripting with Content Security Policy (updated)
Defeating Cross-Site Scripting with Content Security Policy (updated)Francois Marier
 
Cabeçalhos de Segurança HTTP
Cabeçalhos de Segurança HTTPCabeçalhos de Segurança HTTP
Cabeçalhos de Segurança HTTPIsmael Goncalves
 
Rails and Content Security Policies
Rails and Content Security PoliciesRails and Content Security Policies
Rails and Content Security PoliciesMatias Korhonen
 
D3LDN17 - Recruiting the Browser
D3LDN17 - Recruiting the BrowserD3LDN17 - Recruiting the Browser
D3LDN17 - Recruiting the BrowserImperva Incapsula
 
Why Traditional Web Security Technologies no Longer Suffice to Keep You Safe
Why Traditional Web Security Technologies no Longer Suffice to Keep You SafeWhy Traditional Web Security Technologies no Longer Suffice to Keep You Safe
Why Traditional Web Security Technologies no Longer Suffice to Keep You SafePhilippe De Ryck
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesBrad Hill
 
Content Security Policy - The application security Swiss Army Knife
Content Security Policy - The application security Swiss Army KnifeContent Security Policy - The application security Swiss Army Knife
Content Security Policy - The application security Swiss Army KnifeScott Helme
 
Web Development Security
Web Development SecurityWeb Development Security
Web Development SecurityRafael Monteiro
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesBrad Hill
 
2015-04-25-content-security-policy
2015-04-25-content-security-policy2015-04-25-content-security-policy
2015-04-25-content-security-policySastry Tumuluri
 
[refreshaustin] Adaptive Images in Responsive Web Design
[refreshaustin] Adaptive Images in Responsive Web Design[refreshaustin] Adaptive Images in Responsive Web Design
[refreshaustin] Adaptive Images in Responsive Web DesignChristopher Schmitt
 
DefCamp 2013 - Http header analysis
DefCamp 2013 - Http header analysisDefCamp 2013 - Http header analysis
DefCamp 2013 - Http header analysisDefCamp
 

Similaire à HTTP_Header_Security.pdf (20)

Content-Security-Policy 2018.0
Content-Security-Policy 2018.0Content-Security-Policy 2018.0
Content-Security-Policy 2018.0
 
Csp and http headers
Csp and http headersCsp and http headers
Csp and http headers
 
Csp and http headers
Csp and http headersCsp and http headers
Csp and http headers
 
CONFidence 2018: Defense-in-depth techniques for modern web applications and ...
CONFidence 2018: Defense-in-depth techniques for modern web applications and ...CONFidence 2018: Defense-in-depth techniques for modern web applications and ...
CONFidence 2018: Defense-in-depth techniques for modern web applications and ...
 
Top Ten Web Hacking Techniques – 2008
Top Ten Web Hacking Techniques – 2008Top Ten Web Hacking Techniques – 2008
Top Ten Web Hacking Techniques – 2008
 
Content Security Policy - Lessons learned at Yahoo
Content Security Policy - Lessons learned at YahooContent Security Policy - Lessons learned at Yahoo
Content Security Policy - Lessons learned at Yahoo
 
http security response headers for web security
http security response headers for web securityhttp security response headers for web security
http security response headers for web security
 
Defeating Cross-Site Scripting with Content Security Policy (updated)
Defeating Cross-Site Scripting with Content Security Policy (updated)Defeating Cross-Site Scripting with Content Security Policy (updated)
Defeating Cross-Site Scripting with Content Security Policy (updated)
 
Cabeçalhos de Segurança HTTP
Cabeçalhos de Segurança HTTPCabeçalhos de Segurança HTTP
Cabeçalhos de Segurança HTTP
 
Rails and Content Security Policies
Rails and Content Security PoliciesRails and Content Security Policies
Rails and Content Security Policies
 
HTTP Security Headers
HTTP Security HeadersHTTP Security Headers
HTTP Security Headers
 
D3LDN17 - Recruiting the Browser
D3LDN17 - Recruiting the BrowserD3LDN17 - Recruiting the Browser
D3LDN17 - Recruiting the Browser
 
Why Traditional Web Security Technologies no Longer Suffice to Keep You Safe
Why Traditional Web Security Technologies no Longer Suffice to Keep You SafeWhy Traditional Web Security Technologies no Longer Suffice to Keep You Safe
Why Traditional Web Security Technologies no Longer Suffice to Keep You Safe
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realities
 
Content Security Policy - The application security Swiss Army Knife
Content Security Policy - The application security Swiss Army KnifeContent Security Policy - The application security Swiss Army Knife
Content Security Policy - The application security Swiss Army Knife
 
Web Development Security
Web Development SecurityWeb Development Security
Web Development Security
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realities
 
2015-04-25-content-security-policy
2015-04-25-content-security-policy2015-04-25-content-security-policy
2015-04-25-content-security-policy
 
[refreshaustin] Adaptive Images in Responsive Web Design
[refreshaustin] Adaptive Images in Responsive Web Design[refreshaustin] Adaptive Images in Responsive Web Design
[refreshaustin] Adaptive Images in Responsive Web Design
 
DefCamp 2013 - Http header analysis
DefCamp 2013 - Http header analysisDefCamp 2013 - Http header analysis
DefCamp 2013 - Http header analysis
 

Dernier

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 

Dernier (20)

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 

HTTP_Header_Security.pdf

  • 2. BIO Bug bounty student by night – 1st Private Invite on Hackerone • Emmanuel JK Gbordzor ISO 27001 LI, CISA, CCNA, CCNA-Security, ITILv3, … 11 years in IT – About 2 years In Security Information Security Manager @ PaySwitch Head, Network & Infrastructure @ PaySwitch Head of IT @ Financial Institution
  • 3. Introduction • In this presentation, I will introduce you to HyperText Transfer Protocol (HTTP) response security headers. • By specifying expected and allowable behaviors, we will see how security headers can prevent a number of attacks against websites. • I’ll explain some of the different HTTP response headers that a web server can include in a response, and what impact they can have on the security of the web browser. • How web developers can implement these security headers to make user experience more secure
  • 4. A Simple Look At Web Browsing
  • 5. Snippet At The Request And Response Headers
  • 6. Why Browser Security Headers? Browser Security Headers help: ➢ to define whether a set of security precautions should be activated or deactivated on the web browser. ➢ to reinforce the security of your web browser to fend off attacks and to mitigate vulnerabilities. ➢ in fighting client side (browser) attacks such as clickjacking, injections, Multipurpose Internet Mail Extensions (MIME) sniffing, Cross-Site Scripting (XSS), etc.
  • 7. Content / Context HTTP STRICT TRANSPORT SECURITY (HSTS) X-FRAME-OPTIONS EXPECT-CT CONTENT-SECURITY- POLICY X-XSS-PROTECTION X-CONTENT-TYPE- OPTIONS
  • 8. HTTP Strict Transport Security (HSTS) • HSTS header forces browsers to communicate using secure (HTTPS) connection. • Protects against “downgrade attacks” • When configured with the “Preload” option, it can prevent Man-In-The-Middle (MiTM) attack • “Preload” - https://hstspreload.org/ - from google
  • 10. HTTP Redirection To HTTPS - Continued
  • 11. HTTP Strict Transport Security (HSTS) - Implementation Syntax: Strict-Transport-Security: max-age=<expire-time> includeSubDomains preload Apache: Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload“ Nginx: add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains; preload'; Microsoft IIS: Name: Strict-Transport-Security Value: max-age=31536000; includeSubDomains; preload
  • 12. X-Frame- Options • An iFrame is an element that allows a web app to be nested within a parent web app. • Can be used maliciously for a clickjacking attack or loading a malicious website inside the frame Prevention: • Frame busting • X-Frame-Option Header
  • 13. X-Frame-Options - Implementation Apache: Header always set X-Frame-Options “deny” Nginx: add_header X-Frame-Options “DENY”; WordPress: header('X-Frame-Options: DENY); Microsoft IIS: Name: X-Frame-Options Value: DENY Syntax: X-Frame-Options: deny sameorigin allow-from url (deprecated)
  • 14. Expect-CT • HTTP Public Key Pinning (HPKP) header is being deprecated to Expect-CT • Expect-CT detects certificates issued by rogue Certificate Authorities (CA) or prevents them from doing so • This header prevents MiTM attack against compromised Certificate Authority (CA) and rogue issued certificate
  • 15. Expect-CT - Implementation Apache: Header set Expect-CT 'enforce, max-age=86400, report-uri="https://foo.example/report“’ Nginx: add_header Expect-CT 'max-age=60, report-uri="https://mydomain.com/report"'; Syntax: Expect-CT: max-age enforce report-uri
  • 16. Content-Security-Policy (CSP) When this header is well implemented, there is no need to implement “X-Frame-Options” and “X-XSS- Protection” headers This helps prevents XSS, clickjacking, code injection, etc., attacks This header helps you to whitelist sources of approved content into your browser hence, preventing the browser from loading malicious assets.
  • 17. Content-Security-Policy - Directives Keywords: *, none, self, hosts Content-Security-Policy: default-src Serves as a fallback for the other fetch directives font-src Specifies valid sources for fonts loaded frame-src Sources for nested contexts such as <frame> and <iframe> img-src Sources of images and favicons media-src Valid sources for loading <audio>, <video> & <track> object-src Sources for the <object>, <embed> and <applet> elements script-src Specifies valid sources for JavaScript style-src Specifies valid sources for stylesheets report-uri Reports violations
  • 18. CSP Sample - https://haveibeenpwned.com content-security-policy: default-src 'none';script-src 'self' www.google-analytics.com www.google.com www.gstatic. js.stripe.com ajax.cloudflare.com;style-src 'self' 'unsafe-inline' cdnjs.cloudflare.com;img-src 'self' www.google-analytics.com stats.g.doubleclick.net www.gstatic.com;font-src 'self' cdnjs.cloudflare.com fonts.gstatic.com;base-uri 'self';child-src www.google.com js.stripe.com;frame-ancestors 'none';report-uri https://troyhunt.report- uri.com/r/d/csp/enforce.com/en_US/i/scr/pixel.gif;"
  • 19. X-XSS- Protection These header detect dangerous HTML input and either prevent the site from loading or remove potentially malicious scripts
  • 20. X-XSS-Protection - Implementation Syntax: X-XSS-Protection: 0 1 mode=block Apache: Header set X-XSS-Protection "1; mode=block“ Nginx: add_header X-XSS-Protection "1; mode=block"; Microsoft IIS: Name: X-XSS-Protection Value: 1; mode=block
  • 21. X-Content-Type-Options • For your seamless experience on the web, MIME sniffing of resource was introduced. • Adversely, an attacker can introduce a malicious executable script such as an image. When acted on by MIME sniffing could have the script executed.
  • 22. X-Content-Type-Options - Implementation Syntax: X-Content-Type-Options: nosniff Apache: Header set X-Content-Type-Options nosniff Nginx: add_header X-Content-Type-Options nosniff; Microsoft IIS: Name: X-Content-Type-Options Value: nosniff
  • 23. Demo Time – Clickjacking – iFrame injection – Harlem shake https://127.0.0.1/mutillidae/
  • 24. Takeaways • Enforce HTTPS using the Strict-Transport-Security header and add your domain to Chrome’s preload list. • Make your web app more robust against XSS by leveraging the X-XSS- Protection header. • Block clickjacking using the X-Frame-Options header. • Leverage Content-Security-Policy to whitelist specific sources and endpoints. • Prevent MIME-sniffing attacks using the X-Content-Type-Options header.
  • 25. Resources / Tools • Check Website HTTP Response Header – https://gf.dev/http-headers-test • Secure Headers Test – https://gf.dev/secure-headers-test • Scott Helme – Security Header Scanner – https://securityheaders.com • HTTP Headers Reference – https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers • HTTP Compatibility Among Browsers – https://caniuse.com
  • 26. References • https://www.netsparker.com/whitepaper-http- security-headers • https://www.ntu.edu.sg/home/ehchua/programming/ webprogramming/HTTP_Basics.html • https://owasp.org/www-chapter-ghana/#div- pastevents • https://www.keycdn.com/blog/http-security-headers