SlideShare a Scribd company logo
@BruntyCSP: Let’s Break Stuff
CONTENT SECURITY POLICIES
LET’S BREAK STUFF
@BruntyCSP: Let’s Break Stuff
BECAUSE YOU ALL TOTALLY CARE ABOUT THIS, RIGHT?!
ABOUT ME
▸ Senior Software Engineer at Viva IT

(that group always in orange hoodies at conferences)
▸ @Brunty
▸ @PHPem
▸ mfyu.co.uk
▸ matt@mfyu.co.uk
@BruntyCSP: Let’s Break Stuff
BECAUSE YOU ALL TOTALLY CARE ABOUT THIS, RIGHT?!
THINGS I DO
▸ Fly fast & acrobatic first-person-view quadcopters
▸ Dungeon master for D&D campaigns with friends
▸ Mentor, lead & teach apprentices and junior developers
▸ Run & organise PHP East Midlands
▸ Speak at user groups and conferences
▸ Break production sites with incorrectly configured
content security policies
@BruntyCSP: Let’s Break Stuff
WHY DO WE NEED
CSP?
@BruntyCSP: Let’s Break Stuff
FIRST, SOME BACKGROUND
WHAT IS CROSS-SITE-SCRIPTING (XSS)?
▸ XSS enables an attacker to inject client-side scripts into
non-malicious web pages viewed by other users
▸ In 2016 there was a 61% likelihood of a browser-based
vulnerability being found in a web application
▸ Of those browser based vulnerabilities, 86% were found to
be XSS related
▸ That’s just over 52% of all web application vulnerabilities

https://www.edgescan.com/assets/docs/reports/2016-edgescan-stats-report.pdf
@BruntyCSP: Let’s Break Stuff
FIRST, SOME BACKGROUND
WHAT CAN BE DONE WITH XSS?
▸ Anything a site owner can do in JS can be done in an XSS
attack
▸ Make modifications to the DOM (you could replace an
entire page and control data going in/out)
▸ Use XMLHttpRequest to send HTTP requests
▸ Access HTML5 APIs - webcam, microphone, geolocation
▸ Steal cookies (and therefore steal session cookies)
@BruntyCSP: Let’s Break Stuff
FIRST, SOME BACKGROUND
WELL KNOWN XSS ATTACKS
▸ Twitter self-retweeting tweet

https://www.youtube.com/watch?v=zv0kZKC6GAM
▸ Samy worm

https://en.wikipedia.org/wiki/Samy_(computer_worm)
▸ Facebook XSS attacks

http://theharmonyguy.com/oldsite/2011/04/21/recent-facebook-xss-attacks-show-increasing-
sophistication/
▸ And so many more…
@BruntyCSP: Let’s Break Stuff
TYPES OF XSS ATTACK
STORED XSS (AKA PERSISTENT OR TYPE I)
▸ Occurs when input is stored - generally in a server-side
database, but not always
▸ This could also be within a HTML5 database, thus never
being sent to the server at all
▸ who.is was a site Rickrolled by a TXT record in the DNS of
a website (yes, really)
@BruntyCSP: Let’s Break Stuff
TYPES OF XSS ATTACK
REFLECTED XSS (AKA NON-PERSISTENT OR TYPE II)
▸ Occurs when user input provided in the request is
immediately returned - such as in an error message, search
string etc
▸ Data is not stored, and in some instances, may not even
reach the server (see the next type of XSS)
@BruntyCSP: Let’s Break Stuff
TYPES OF XSS ATTACK
DOM-BASED XSS (AKA TYPE-0)
▸ The entire flow of the attack takes place within the browser
▸ For example, if JavaScript in the site takes input, and uses
something like document.write based on that input, it can
be vulnerable to a DOM-based XSS attack
@BruntyCSP: Let’s Break Stuff
TYPES OF XSS ATTACK
SELF XSS
▸ Social-engineering form of XSS
▸ Requires the user to execute code in the browser
▸ Doing so via the console can’t be protected by a lot of
methods
▸ Not considered a ‘true’ XSS attack due to requiring the
user to execute the code
@BruntyCSP: Let’s Break Stuff
@BruntyCSP: Let’s Break Stuff
console.log("%cStop!", "font: 5em sans-serif; font-weight: bold; color: red;");
@BruntyCSP: Let’s Break Stuff
STOP THE HACKERS
LET’S FIGHT BACK
@BruntyCSP: Let’s Break Stuff
HTTP RESPONSE HEADER TO
HELP REDUCE XSS RISKS
WHAT IS A CSP?
@BruntyCSP: Let’s Break Stuff
DECLARES WHAT RESOURCES
ARE ALLOWED TO LOAD
HOW DOES A CSP WORK?
@BruntyCSP: Let’s Break Stuff
WHAT CAN WE
PROTECT?
@BruntyCSP: Let’s Break Stuff
DEFAULT-SRC
@BruntyCSP: Let’s Break Stuff
SCRIPT-SRC
@BruntyCSP: Let’s Break Stuff
STYLE-SRC
@BruntyCSP: Let’s Break Stuff
UPGRADE-
INSECURE-REQUESTS
@BruntyCSP: Let’s Break Stuff
FORM-ACTION
@BruntyCSP: Let’s Break Stuff
WORKER-SRC

BASE-URI

PLUGIN-TYPES

SANDBOX

FRAME-ANCESTORS

CONNECT-SRC

CHILD-SRC

AND MANY MORE…
@BruntyCSP: Let’s Break Stuff
FULL REFERENCE:https://content-security-policy.com

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
@BruntyCSP: Let’s Break Stuff
A FEW EXAMPLES
OF DIRECTIVES
@BruntyCSP: Let’s Break Stuff
IMG-SRC *
WILDCARD, ALLOWS ANY
URL EXCEPT DATA: BLOB:
FILESYSTEM: SCHEMES.
@BruntyCSP: Let’s Break Stuff
OBJECT-SRC 'NONE'
DON’T LOAD RESOURCES
FROM ANY SOURCE
@BruntyCSP: Let’s Break Stuff
STYLE-SRC ‘SELF'
ALLOW LOADING FROM
SAME ORIGIN (SAME
SCHEME, HOST AND PORT)
@BruntyCSP: Let’s Break Stuff
SCRIPT-SRC 'UNSAFE-INLINE'
ALLOWS USE OF INLINE
SOURCE ELEMENTS SUCH AS
STYLE ATTRIBUTE, ONCLICK,
OR SCRIPT TAG BODIES
@BruntyCSP: Let’s Break Stuff
DON’T USE
UNSAFE-INLINE
@BruntyCSP: Let’s Break Stuff
<script nonce="$RANDOM">...</script>
script-src 'self' 'nonce-$RANDOM'
@BruntyCSP: Let’s Break Stuff
Content-Security-Policy: default-src: 'none'; script-src
'self' https://*.google.com 'nonce-
pahsbdlensudsmslnaf7adn'; style-src ‘self'; img-src:
'self'; upgrade-insecure-requests; form-action ‘http://
mysite.com'; report-uri https://mfyu.report-uri.io/r/
default/csp/reportOnly;
@BruntyCSP: Let’s Break Stuff
I BROKE PRODUCTION WITH A
BAD CSP
LEARN FROM MY MISTAKES
@BruntyCSP: Let’s Break Stuff
DON’T DO WHAT I
DID
@BruntyCSP: Let’s Break Stuff
IMPLEMENTATION
ADVICE
@BruntyCSP: Let’s Break Stuff
REPORT-URI
@BruntyCSP: Let’s Break Stuff
WHEN A POLICY FAILURE
OCCURS, THE BROWSER SENDS
A JSON PAYLOAD TO THAT URL
@BruntyCSP: Let’s Break Stuff
{
"csp-report": {
"blocked-uri": "self",
"document-uri": "https://mysite.com",
"line-number": 1,
"original-policy": "script-src 'self'",
"script-sample": "try { for(var lastpass_iter=0; lastpass...",
"source-file": "https://mysite.com",
"violated-directive": "script-src 'self'"
}
}
@BruntyCSP: Let’s Break Stuff
HTTP://REPORT-URI.IO
@BruntyCSP: Let’s Break Stuff
REPORT-ONLY
@BruntyCSP: Let’s Break Stuff
Content-Security-Policy-Report-Only: script-src 'self'
https://*.google.com; style-src 'self'; report-uri
https://mfyu.report-uri.io/r/default/csp/reportOnly;
@BruntyCSP: Let’s Break Stuff
TRIAL STUFF
BEFORE ENFORCING
@BruntyCSP: Let’s Break Stuff
USE REPORT-ONLY
@BruntyCSP: Let’s Break Stuff
LOVE REPORT-ONLY
@BruntyCSP: Let’s Break Stuff
HATE REPORT-ONLY
@BruntyCSP: Let’s Break Stuff
BUT THERE WILL BE
NOISE, LOTS OF NOISE
@BruntyCSP: Let’s Break Stuff
WAYS TO REMOVE BARRIERS IN DEVELOPMENT
NONCES
▸ Don’t generate multiple nonces in the same request (but
do generate a new nonce on each separate request)
▸ If using a templating engine (such as twig) - add the nonce
as a global so it’s available in every template by default
▸ Write a helper to generate tags with a nonce if it’s
available
@BruntyCSP: Let’s Break Stuff
WAYS TO MAKE DEALING WITH A CSP EASIER
TIPS
▸ Have an easy and quick way to disable the CSP in
production if required
▸ Better yet, have a way to switch it from enforced to report
only so you can get violations reported to help you debug
▸ Add the CSP at an application level if you need a nonce -
be careful with doing it at a vhost config level (as changes
require web server config reload)
@BruntyCSP: Let’s Break Stuff
BROWSER
SUPPORT
@BruntyCSP: Let’s Break Stuff
@BruntyCSP: Let’s Break Stuff
DEMO
@BruntyCSP: Let’s Break Stuff
@SCOTT_HELME
(HE KNOWS HIS STUFF!)
(THIS ISN’T ME)
@BruntyCSP: Let’s Break Stuff
HOMEWORK TIME!
LINKS & FURTHER READING
▸ https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)
▸ https://content-security-policy.com
▸ https://report-uri.io
▸ https://scotthelme.co.uk/just-how-much-traffic-can-you-generate-using-csp/
▸ https://www.edgescan.com/assets/docs/reports/2016-edgescan-stats-report.pdf
▸ http://theharmonyguy.com/oldsite/2011/04/21/recent-facebook-xss-attacks-show-
increasing-sophistication/
▸ https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
▸ https://github.com/Brunty/csp-demo
@BruntyCSP: Let’s Break Stuff
FEEDBACK:
https://joind.in/talk/d914f
@BruntyCSP: Let’s Break Stuff
THANK YOU
@BruntyCSP: Let’s Break Stuff
QUESTIONS?

More Related Content

Viewers also liked

BDD - telling stories through code for PHPem
BDD - telling stories through code for PHPemBDD - telling stories through code for PHPem
BDD - telling stories through code for PHPem
Matt Brunt
 
BDD: Telling stories through code [For TechNotts]
BDD: Telling stories through code [For TechNotts]BDD: Telling stories through code [For TechNotts]
BDD: Telling stories through code [For TechNotts]
Matt Brunt
 
PHPNW16 Matt Brunt - BDD & Behat
PHPNW16 Matt Brunt - BDD & BehatPHPNW16 Matt Brunt - BDD & Behat
PHPNW16 Matt Brunt - BDD & Behat
Matt Brunt
 
BDD & Behat
BDD & BehatBDD & Behat
BDD & Behat
Matt Brunt
 
BDD & Behat for Srijan Technologies
BDD & Behat for Srijan TechnologiesBDD & Behat for Srijan Technologies
BDD & Behat for Srijan Technologies
Matt Brunt
 
CSP - What? Why? How? PHPNW16
CSP - What? Why? How? PHPNW16CSP - What? Why? How? PHPNW16
CSP - What? Why? How? PHPNW16
Matt Brunt
 
BDD in Action – principles, practices and real-world application
BDD in Action – principles, practices and real-world applicationBDD in Action – principles, practices and real-world application
BDD in Action – principles, practices and real-world application
John Ferguson Smart Limited
 

Viewers also liked (8)

BDD - telling stories through code for PHPem
BDD - telling stories through code for PHPemBDD - telling stories through code for PHPem
BDD - telling stories through code for PHPem
 
BDD: Telling stories through code [For TechNotts]
BDD: Telling stories through code [For TechNotts]BDD: Telling stories through code [For TechNotts]
BDD: Telling stories through code [For TechNotts]
 
PHPNW16 Matt Brunt - BDD & Behat
PHPNW16 Matt Brunt - BDD & BehatPHPNW16 Matt Brunt - BDD & Behat
PHPNW16 Matt Brunt - BDD & Behat
 
BDD & Behat
BDD & BehatBDD & Behat
BDD & Behat
 
BDD & Behat for Srijan Technologies
BDD & Behat for Srijan TechnologiesBDD & Behat for Srijan Technologies
BDD & Behat for Srijan Technologies
 
CSP - What? Why? How? PHPNW16
CSP - What? Why? How? PHPNW16CSP - What? Why? How? PHPNW16
CSP - What? Why? How? PHPNW16
 
Intro to Gulp
Intro to GulpIntro to Gulp
Intro to Gulp
 
BDD in Action – principles, practices and real-world application
BDD in Action – principles, practices and real-world applicationBDD in Action – principles, practices and real-world application
BDD in Action – principles, practices and real-world application
 

Similar to Content Security Policies: Let's Break Stuff

Chaos Driven Development (Bruce Wong)
Chaos Driven Development (Bruce Wong)Chaos Driven Development (Bruce Wong)
Chaos Driven Development (Bruce Wong)
Future Insights
 
Chaos Driven Development
Chaos Driven DevelopmentChaos Driven Development
Chaos Driven Development
Bruce Wong
 
Prototyping: Helping to take away the suck
Prototyping: Helping to take away the suckPrototyping: Helping to take away the suck
Prototyping: Helping to take away the suck
Harvard Web Working Group
 
DrupalCamp London 2017 - Web site insecurity
DrupalCamp London 2017 - Web site insecurity DrupalCamp London 2017 - Web site insecurity
DrupalCamp London 2017 - Web site insecurity
George Boobyer
 
20160816 amlight popbahia_rnp_ansp
20160816 amlight popbahia_rnp_ansp20160816 amlight popbahia_rnp_ansp
20160816 amlight popbahia_rnp_ansp
University of Twente
 
Building Better Responsive Websites
Building Better Responsive WebsitesBuilding Better Responsive Websites
Building Better Responsive Websites
Holger Bartel
 
Beyond Mirai: The new age of MDDoS attacks
Beyond Mirai: The new age of MDDoS attacksBeyond Mirai: The new age of MDDoS attacks
Beyond Mirai: The new age of MDDoS attacks
APNIC
 
Happy Browser, Happy User! WordSesh 2019
Happy Browser, Happy User! WordSesh 2019Happy Browser, Happy User! WordSesh 2019
Happy Browser, Happy User! WordSesh 2019
Katie Sylor-Miller
 
Smart mobile storytelling christy robinson - denver news train - april 11-1...
Smart mobile storytelling   christy robinson - denver news train - april 11-1...Smart mobile storytelling   christy robinson - denver news train - april 11-1...
Smart mobile storytelling christy robinson - denver news train - april 11-1...
News Leaders Association's NewsTrain
 
Github github-github
Github github-githubGithub github-github
Github github-githubfusion2011
 
TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기
TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기
TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기
Heejong Ahn
 
Skynet vs planet of apes
Skynet vs planet of apesSkynet vs planet of apes
Skynet vs planet of apes
Adrien Blind
 
HTTP For the Good or the Bad
HTTP For the Good or the BadHTTP For the Good or the Bad
HTTP For the Good or the Bad
Xavier Mertens
 
Modern Web Security, Lazy but Mindful Like a Fox
Modern Web Security, Lazy but Mindful Like a FoxModern Web Security, Lazy but Mindful Like a Fox
Modern Web Security, Lazy but Mindful Like a Fox
C4Media
 
Anastasia Vixentael - Don't Waste Time on Learning Cryptography: Better Use I...
Anastasia Vixentael - Don't Waste Time on Learning Cryptography: Better Use I...Anastasia Vixentael - Don't Waste Time on Learning Cryptography: Better Use I...
Anastasia Vixentael - Don't Waste Time on Learning Cryptography: Better Use I...
OWASP Kyiv
 
Bastion jump hosts with Teleport
Bastion jump hosts with TeleportBastion jump hosts with Teleport
Bastion jump hosts with Teleport
Faelix Ltd
 
The Original Hypertext Preprocessor
The Original Hypertext PreprocessorThe Original Hypertext Preprocessor
The Original Hypertext Preprocessor
Drew McLellan
 
Enhance system transparency and truthfulness with request tracing
Enhance system transparency and truthfulness with request tracingEnhance system transparency and truthfulness with request tracing
Enhance system transparency and truthfulness with request tracing
Sam Keen
 
Juraj vysvader - Python developer's CV
Juraj vysvader - Python developer's CVJuraj vysvader - Python developer's CV
Juraj vysvader - Python developer's CV
Juraj Vysvader
 
Metasepi team meeting #16: Safety on ATS language + MCU
Metasepi team meeting #16: Safety on ATS language + MCUMetasepi team meeting #16: Safety on ATS language + MCU
Metasepi team meeting #16: Safety on ATS language + MCU
Kiwamu Okabe
 

Similar to Content Security Policies: Let's Break Stuff (20)

Chaos Driven Development (Bruce Wong)
Chaos Driven Development (Bruce Wong)Chaos Driven Development (Bruce Wong)
Chaos Driven Development (Bruce Wong)
 
Chaos Driven Development
Chaos Driven DevelopmentChaos Driven Development
Chaos Driven Development
 
Prototyping: Helping to take away the suck
Prototyping: Helping to take away the suckPrototyping: Helping to take away the suck
Prototyping: Helping to take away the suck
 
DrupalCamp London 2017 - Web site insecurity
DrupalCamp London 2017 - Web site insecurity DrupalCamp London 2017 - Web site insecurity
DrupalCamp London 2017 - Web site insecurity
 
20160816 amlight popbahia_rnp_ansp
20160816 amlight popbahia_rnp_ansp20160816 amlight popbahia_rnp_ansp
20160816 amlight popbahia_rnp_ansp
 
Building Better Responsive Websites
Building Better Responsive WebsitesBuilding Better Responsive Websites
Building Better Responsive Websites
 
Beyond Mirai: The new age of MDDoS attacks
Beyond Mirai: The new age of MDDoS attacksBeyond Mirai: The new age of MDDoS attacks
Beyond Mirai: The new age of MDDoS attacks
 
Happy Browser, Happy User! WordSesh 2019
Happy Browser, Happy User! WordSesh 2019Happy Browser, Happy User! WordSesh 2019
Happy Browser, Happy User! WordSesh 2019
 
Smart mobile storytelling christy robinson - denver news train - april 11-1...
Smart mobile storytelling   christy robinson - denver news train - april 11-1...Smart mobile storytelling   christy robinson - denver news train - april 11-1...
Smart mobile storytelling christy robinson - denver news train - april 11-1...
 
Github github-github
Github github-githubGithub github-github
Github github-github
 
TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기
TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기
TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기
 
Skynet vs planet of apes
Skynet vs planet of apesSkynet vs planet of apes
Skynet vs planet of apes
 
HTTP For the Good or the Bad
HTTP For the Good or the BadHTTP For the Good or the Bad
HTTP For the Good or the Bad
 
Modern Web Security, Lazy but Mindful Like a Fox
Modern Web Security, Lazy but Mindful Like a FoxModern Web Security, Lazy but Mindful Like a Fox
Modern Web Security, Lazy but Mindful Like a Fox
 
Anastasia Vixentael - Don't Waste Time on Learning Cryptography: Better Use I...
Anastasia Vixentael - Don't Waste Time on Learning Cryptography: Better Use I...Anastasia Vixentael - Don't Waste Time on Learning Cryptography: Better Use I...
Anastasia Vixentael - Don't Waste Time on Learning Cryptography: Better Use I...
 
Bastion jump hosts with Teleport
Bastion jump hosts with TeleportBastion jump hosts with Teleport
Bastion jump hosts with Teleport
 
The Original Hypertext Preprocessor
The Original Hypertext PreprocessorThe Original Hypertext Preprocessor
The Original Hypertext Preprocessor
 
Enhance system transparency and truthfulness with request tracing
Enhance system transparency and truthfulness with request tracingEnhance system transparency and truthfulness with request tracing
Enhance system transparency and truthfulness with request tracing
 
Juraj vysvader - Python developer's CV
Juraj vysvader - Python developer's CVJuraj vysvader - Python developer's CV
Juraj vysvader - Python developer's CV
 
Metasepi team meeting #16: Safety on ATS language + MCU
Metasepi team meeting #16: Safety on ATS language + MCUMetasepi team meeting #16: Safety on ATS language + MCU
Metasepi team meeting #16: Safety on ATS language + MCU
 

Recently uploaded

De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 

Recently uploaded (20)

De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 

Content Security Policies: Let's Break Stuff

  • 1. @BruntyCSP: Let’s Break Stuff CONTENT SECURITY POLICIES LET’S BREAK STUFF
  • 2. @BruntyCSP: Let’s Break Stuff BECAUSE YOU ALL TOTALLY CARE ABOUT THIS, RIGHT?! ABOUT ME ▸ Senior Software Engineer at Viva IT
 (that group always in orange hoodies at conferences) ▸ @Brunty ▸ @PHPem ▸ mfyu.co.uk ▸ matt@mfyu.co.uk
  • 3. @BruntyCSP: Let’s Break Stuff BECAUSE YOU ALL TOTALLY CARE ABOUT THIS, RIGHT?! THINGS I DO ▸ Fly fast & acrobatic first-person-view quadcopters ▸ Dungeon master for D&D campaigns with friends ▸ Mentor, lead & teach apprentices and junior developers ▸ Run & organise PHP East Midlands ▸ Speak at user groups and conferences ▸ Break production sites with incorrectly configured content security policies
  • 4. @BruntyCSP: Let’s Break Stuff WHY DO WE NEED CSP?
  • 5. @BruntyCSP: Let’s Break Stuff FIRST, SOME BACKGROUND WHAT IS CROSS-SITE-SCRIPTING (XSS)? ▸ XSS enables an attacker to inject client-side scripts into non-malicious web pages viewed by other users ▸ In 2016 there was a 61% likelihood of a browser-based vulnerability being found in a web application ▸ Of those browser based vulnerabilities, 86% were found to be XSS related ▸ That’s just over 52% of all web application vulnerabilities
 https://www.edgescan.com/assets/docs/reports/2016-edgescan-stats-report.pdf
  • 6. @BruntyCSP: Let’s Break Stuff FIRST, SOME BACKGROUND WHAT CAN BE DONE WITH XSS? ▸ Anything a site owner can do in JS can be done in an XSS attack ▸ Make modifications to the DOM (you could replace an entire page and control data going in/out) ▸ Use XMLHttpRequest to send HTTP requests ▸ Access HTML5 APIs - webcam, microphone, geolocation ▸ Steal cookies (and therefore steal session cookies)
  • 7. @BruntyCSP: Let’s Break Stuff FIRST, SOME BACKGROUND WELL KNOWN XSS ATTACKS ▸ Twitter self-retweeting tweet
 https://www.youtube.com/watch?v=zv0kZKC6GAM ▸ Samy worm
 https://en.wikipedia.org/wiki/Samy_(computer_worm) ▸ Facebook XSS attacks
 http://theharmonyguy.com/oldsite/2011/04/21/recent-facebook-xss-attacks-show-increasing- sophistication/ ▸ And so many more…
  • 8. @BruntyCSP: Let’s Break Stuff TYPES OF XSS ATTACK STORED XSS (AKA PERSISTENT OR TYPE I) ▸ Occurs when input is stored - generally in a server-side database, but not always ▸ This could also be within a HTML5 database, thus never being sent to the server at all ▸ who.is was a site Rickrolled by a TXT record in the DNS of a website (yes, really)
  • 9. @BruntyCSP: Let’s Break Stuff TYPES OF XSS ATTACK REFLECTED XSS (AKA NON-PERSISTENT OR TYPE II) ▸ Occurs when user input provided in the request is immediately returned - such as in an error message, search string etc ▸ Data is not stored, and in some instances, may not even reach the server (see the next type of XSS)
  • 10. @BruntyCSP: Let’s Break Stuff TYPES OF XSS ATTACK DOM-BASED XSS (AKA TYPE-0) ▸ The entire flow of the attack takes place within the browser ▸ For example, if JavaScript in the site takes input, and uses something like document.write based on that input, it can be vulnerable to a DOM-based XSS attack
  • 11. @BruntyCSP: Let’s Break Stuff TYPES OF XSS ATTACK SELF XSS ▸ Social-engineering form of XSS ▸ Requires the user to execute code in the browser ▸ Doing so via the console can’t be protected by a lot of methods ▸ Not considered a ‘true’ XSS attack due to requiring the user to execute the code
  • 13. @BruntyCSP: Let’s Break Stuff console.log("%cStop!", "font: 5em sans-serif; font-weight: bold; color: red;");
  • 14. @BruntyCSP: Let’s Break Stuff STOP THE HACKERS LET’S FIGHT BACK
  • 15. @BruntyCSP: Let’s Break Stuff HTTP RESPONSE HEADER TO HELP REDUCE XSS RISKS WHAT IS A CSP?
  • 16. @BruntyCSP: Let’s Break Stuff DECLARES WHAT RESOURCES ARE ALLOWED TO LOAD HOW DOES A CSP WORK?
  • 17. @BruntyCSP: Let’s Break Stuff WHAT CAN WE PROTECT?
  • 18. @BruntyCSP: Let’s Break Stuff DEFAULT-SRC
  • 19. @BruntyCSP: Let’s Break Stuff SCRIPT-SRC
  • 20. @BruntyCSP: Let’s Break Stuff STYLE-SRC
  • 21. @BruntyCSP: Let’s Break Stuff UPGRADE- INSECURE-REQUESTS
  • 22. @BruntyCSP: Let’s Break Stuff FORM-ACTION
  • 23. @BruntyCSP: Let’s Break Stuff WORKER-SRC
 BASE-URI
 PLUGIN-TYPES
 SANDBOX
 FRAME-ANCESTORS
 CONNECT-SRC
 CHILD-SRC
 AND MANY MORE…
  • 24. @BruntyCSP: Let’s Break Stuff FULL REFERENCE:https://content-security-policy.com
 https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
  • 25. @BruntyCSP: Let’s Break Stuff A FEW EXAMPLES OF DIRECTIVES
  • 26. @BruntyCSP: Let’s Break Stuff IMG-SRC * WILDCARD, ALLOWS ANY URL EXCEPT DATA: BLOB: FILESYSTEM: SCHEMES.
  • 27. @BruntyCSP: Let’s Break Stuff OBJECT-SRC 'NONE' DON’T LOAD RESOURCES FROM ANY SOURCE
  • 28. @BruntyCSP: Let’s Break Stuff STYLE-SRC ‘SELF' ALLOW LOADING FROM SAME ORIGIN (SAME SCHEME, HOST AND PORT)
  • 29. @BruntyCSP: Let’s Break Stuff SCRIPT-SRC 'UNSAFE-INLINE' ALLOWS USE OF INLINE SOURCE ELEMENTS SUCH AS STYLE ATTRIBUTE, ONCLICK, OR SCRIPT TAG BODIES
  • 30. @BruntyCSP: Let’s Break Stuff DON’T USE UNSAFE-INLINE
  • 31. @BruntyCSP: Let’s Break Stuff <script nonce="$RANDOM">...</script> script-src 'self' 'nonce-$RANDOM'
  • 32. @BruntyCSP: Let’s Break Stuff Content-Security-Policy: default-src: 'none'; script-src 'self' https://*.google.com 'nonce- pahsbdlensudsmslnaf7adn'; style-src ‘self'; img-src: 'self'; upgrade-insecure-requests; form-action ‘http:// mysite.com'; report-uri https://mfyu.report-uri.io/r/ default/csp/reportOnly;
  • 33. @BruntyCSP: Let’s Break Stuff I BROKE PRODUCTION WITH A BAD CSP LEARN FROM MY MISTAKES
  • 34. @BruntyCSP: Let’s Break Stuff DON’T DO WHAT I DID
  • 35. @BruntyCSP: Let’s Break Stuff IMPLEMENTATION ADVICE
  • 36. @BruntyCSP: Let’s Break Stuff REPORT-URI
  • 37. @BruntyCSP: Let’s Break Stuff WHEN A POLICY FAILURE OCCURS, THE BROWSER SENDS A JSON PAYLOAD TO THAT URL
  • 38. @BruntyCSP: Let’s Break Stuff { "csp-report": { "blocked-uri": "self", "document-uri": "https://mysite.com", "line-number": 1, "original-policy": "script-src 'self'", "script-sample": "try { for(var lastpass_iter=0; lastpass...", "source-file": "https://mysite.com", "violated-directive": "script-src 'self'" } }
  • 39. @BruntyCSP: Let’s Break Stuff HTTP://REPORT-URI.IO
  • 40. @BruntyCSP: Let’s Break Stuff REPORT-ONLY
  • 41. @BruntyCSP: Let’s Break Stuff Content-Security-Policy-Report-Only: script-src 'self' https://*.google.com; style-src 'self'; report-uri https://mfyu.report-uri.io/r/default/csp/reportOnly;
  • 42. @BruntyCSP: Let’s Break Stuff TRIAL STUFF BEFORE ENFORCING
  • 43. @BruntyCSP: Let’s Break Stuff USE REPORT-ONLY
  • 44. @BruntyCSP: Let’s Break Stuff LOVE REPORT-ONLY
  • 45. @BruntyCSP: Let’s Break Stuff HATE REPORT-ONLY
  • 46. @BruntyCSP: Let’s Break Stuff BUT THERE WILL BE NOISE, LOTS OF NOISE
  • 47. @BruntyCSP: Let’s Break Stuff WAYS TO REMOVE BARRIERS IN DEVELOPMENT NONCES ▸ Don’t generate multiple nonces in the same request (but do generate a new nonce on each separate request) ▸ If using a templating engine (such as twig) - add the nonce as a global so it’s available in every template by default ▸ Write a helper to generate tags with a nonce if it’s available
  • 48. @BruntyCSP: Let’s Break Stuff WAYS TO MAKE DEALING WITH A CSP EASIER TIPS ▸ Have an easy and quick way to disable the CSP in production if required ▸ Better yet, have a way to switch it from enforced to report only so you can get violations reported to help you debug ▸ Add the CSP at an application level if you need a nonce - be careful with doing it at a vhost config level (as changes require web server config reload)
  • 49. @BruntyCSP: Let’s Break Stuff BROWSER SUPPORT
  • 52. @BruntyCSP: Let’s Break Stuff @SCOTT_HELME (HE KNOWS HIS STUFF!) (THIS ISN’T ME)
  • 53. @BruntyCSP: Let’s Break Stuff HOMEWORK TIME! LINKS & FURTHER READING ▸ https://www.owasp.org/index.php/Cross-site_Scripting_(XSS) ▸ https://content-security-policy.com ▸ https://report-uri.io ▸ https://scotthelme.co.uk/just-how-much-traffic-can-you-generate-using-csp/ ▸ https://www.edgescan.com/assets/docs/reports/2016-edgescan-stats-report.pdf ▸ http://theharmonyguy.com/oldsite/2011/04/21/recent-facebook-xss-attacks-show- increasing-sophistication/ ▸ https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy ▸ https://github.com/Brunty/csp-demo
  • 54. @BruntyCSP: Let’s Break Stuff FEEDBACK: https://joind.in/talk/d914f
  • 55. @BruntyCSP: Let’s Break Stuff THANK YOU
  • 56. @BruntyCSP: Let’s Break Stuff QUESTIONS?