CSP bypass: self + 'unsafe-inline' with Iframes
Last updated
Last updated
Učite i vežbajte AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Učite i vežbajte GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Konfiguracija kao što je:
Prohibits usage of any functions that execute code transmitted as a string. For example: eval, setTimeout, setInterval
will all be blocked because of the setting unsafe-eval
Any content from external sources is also blocked, including images, CSS, WebSockets, and, especially, JS
It's observed that modern browsers convert images and texts into HTML to enhance their display (e.g., setting backgrounds, centering, etc.). Consequently, if an image or text file, such as favicon.ico
or robots.txt
, is opened via an iframe
, it's rendered as HTML. Notably, these pages often lack CSP headers and may not include X-Frame-Options, enabling the execution of arbitrary JavaScript from them:
Slično, odgovori sa greškama, poput tekstualnih fajlova ili slika, obično dolaze bez CSP zaglavlja i mogu izostaviti X-Frame-Options. Greške se mogu izazvati da se učitaju unutar iframe-a, omogućavajući sledeće radnje:
Nakon aktiviranja bilo kojeg od pomenutih scenarija, izvršavanje JavaScript-a unutar iframe-a je moguće na sledeći način:
Učite i vežbajte AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Učite i vežbajte GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)