Closed
Bug 1007634
Opened 11 years ago
Closed 10 years ago
CSP allows local Worker construction with only 'unsafe-inline' set
Categories
(Core :: DOM: Security, defect, P2)
Tracking
()
RESOLVED
FIXED
mozilla46
| Tracking | Status | |
|---|---|---|
| firefox46 | --- | fixed |
People
(Reporter: mozilla, Assigned: kmckinley)
References
(Blocks 1 open bug)
Details
Attachments
(1 file, 1 obsolete file)
|
1.42 KB,
patch
|
kmckinley
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0 (Beta/Release)
Build ID: 20140428193838
Steps to reproduce:
Serve an HTML file with the header Content-Security-Policy: default-src 'none'; script-src 'unsafe-inline'.
Inside that file, use an inline script block to attempt to construct a Worker from a file:
<script>
var worker = new Worker("/worker.js");
worker.onmessage = function(event) {
alert("Received " + event.data);
}
worker.postMessage("ping");
</script>
Where worker.js simply contains the following:
this.onmessage = function(event) {
postMessage("pong");
}
Actual results:
"pong" alert is shown. This means the Worker construction has been allowed from /worker.js, as the worker has replied to the message sent to it.
Expected results:
Construction of worker from /worker.js should be blocked by CSP.
See test pages at:
http://csp.charlie.ht/worker-incorrectly-allowed.html
http://csp.charlie.ht/worker-correctly-allowed.html
worker-incorrectly-allowed.html is served with the same HTML/header combination described in "steps to reproduce". The "pong" alert is shown, when I believe it shouldn't be. There is no directive stating that /worker.js is an allowed script source.
worker-correctly-allowed.html has the same HTML, yet is served with script-src 'self' 'unsafe-inline'. In this case, I expect the Worker construction to be allowed, which is what happens.
Note that this is similar to bug 929292 that I reported yesterday.
Updated•11 years ago
|
Comment 1•11 years ago
|
||
(In reply to Charlie Hothersall-Thomas from comment #0)
> Note that this is similar to bug 929292 that I reported yesterday.
Didn't you mean bug 1007205 ?
| Reporter | ||
Comment 2•11 years ago
|
||
(In reply to Paul Silaghi, QA [:pauly] from comment #1)
> (In reply to Charlie Hothersall-Thomas from comment #0)
> > Note that this is similar to bug 929292 that I reported yesterday.
> Didn't you mean bug 1007205 ?
Yes, sorry, must have pasted the wrong one!
Comment 3•11 years ago
|
||
Thanks for reporting this! It is definitely a bug. CSP should be enforced on loading worker scripts by the Content Policy check in dom/workers/ScriptLoader.cpp::ChannelFromScriptURL, but it looks like there's a bug in there.
For future reference, note that CSP 1.0 uses script-src to control the loading of worker script (which this bug illustrates), while CSP 1.1 introduces a new directive, child-src, that controls the loading of Workers separately from script-src.
Updated•11 years ago
|
Assignee: nobody → grobinson
Updated•11 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Linux → All
Hardware: x86_64 → All
Comment 4•11 years ago
|
||
Garrett: I'm going to unassign this (please take it back if you plan to continue working on it).
Assignee: garrett.f.robinson+mozilla → nobody
Priority: -- → P3
Comment 5•10 years ago
|
||
Likely needs some form of docs coverage once this is fixed, since it may change behavior.
Keywords: dev-doc-needed
Updated•10 years ago
|
Priority: P3 → P2
| Assignee | ||
Updated•10 years ago
|
Assignee: nobody → kmckinley
| Assignee | ||
Comment 6•10 years ago
|
||
Worker construction is now handled by the child-src CSP directive, as implemented in 1045891 and currently on Firefox 45.
Added test to verify that script-src no longer governs Worker construction.
Attachment #8710274 -
Flags: review?(mozilla)
Attachment #8710274 -
Flags: review?(dveditz)
Updated•10 years ago
|
Status: NEW → ASSIGNED
Comment 7•10 years ago
|
||
Comment on attachment 8710274 [details] [diff] [review]
Add a test to show that Worker construction is no longer dependent on CSP script-src
Review of attachment 8710274 [details] [diff] [review]:
-----------------------------------------------------------------
Thanks Kate, r=me
Attachment #8710274 -
Flags: review?(mozilla) → review+
| Assignee | ||
Comment 8•10 years ago
|
||
Attachment #8710274 -
Attachment is obsolete: true
Attachment #8710274 -
Flags: review?(dveditz)
Attachment #8710789 -
Flags: review+
| Assignee | ||
Updated•10 years ago
|
Keywords: checkin-needed
Keywords: checkin-needed
Comment 10•10 years ago
|
||
| bugherder | ||
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
status-firefox46:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla46
Updated•9 years ago
|
Keywords: dev-doc-needed
You need to log in
before you can comment on or make changes to this bug.
Description
•