Closed
Bug 221428
Opened 21 years ago
Closed 18 years ago
[FIX]Define security policy for stylesheets [was: Security check for same-origin access mistreats data: URIs]
Categories
(Core :: Security, defect, P2)
Core
Security
Tracking
()
RESOLVED
FIXED
mozilla1.9alpha3
People
(Reporter: bzbarsky, Assigned: bzbarsky)
References
(Blocks 1 open bug)
Details
(Keywords: testcase)
Attachments
(2 files, 2 obsolete files)
311 bytes,
text/html
|
Details | |
64.83 KB,
patch
|
Details | Diff | Splinter Review |
Testcase coming up. The short story is that the fix for bug 135267 makes it
impossible to script a stylesheet loaded via a data: uri, since that in fact has
a different origin than the page.
I'm not sure how CheckSameOrigin() should work exactly and whether it would be
safe for it to succeed when the uri is a data: uri (since presumably cases when
data: is running script would use the principal, and data: should inherit the
page principal).
Assignee | ||
Comment 1•21 years ago
|
||
Comment 2•21 years ago
|
||
Shouldn't the origin of the data: URL be the origin of the page that references
it via an attribute value; or if it was set dynamicly, the origin of the script
that set it?
/be
Assignee | ||
Comment 3•21 years ago
|
||
That's also possible, yes... the problem is that there is no way to get that
information from a URI object...
Comment 4•21 years ago
|
||
shouldn't you have a reference to the nsIChannel used to load the document?
Assignee | ||
Comment 5•21 years ago
|
||
Perhaps, but how does that help here? The data: url can come from a stylesheet
(eg @import) too...
Comment 6•21 years ago
|
||
bz: well, since nsIChannel::owner holds a reference to the nsIPrincipal, if you
can get ahold of the nsIChannel for the document from which the data: URL was
extracted, then you can just use the principal from that nsIChannel to set the
principal on the nsDataChannel. (i don't know off hand if the principal's can
be shared, or if a new principal must be constructed with the same origin, but
that detail should be inconsequential i would think.)
Assignee | ||
Comment 7•21 years ago
|
||
Like I said, the data: can come from a stylesheet, not a document.... And from
the data: uri itself I don't see how I can get at the principal.
I suppose stylesheets could keep a pointer to their principal, but that may be a
little wasteful of memory..
Comment 8•21 years ago
|
||
i was using "document" loosely to include the stylesheet "document" ;-)
>I suppose stylesheets could keep a pointer to their principal, but that may be a
>little wasteful of memory..
this seems like the right solution to me. is it really that bloaty to keep a
reference in the stylesheet to the nsIPrincipal used when loading the stylesheet?
Assignee | ||
Comment 9•18 years ago
|
||
So I think we _do_ want to have stylesheets store their principal... Just need to do it.
Assignee | ||
Comment 10•18 years ago
|
||
What about stylesheets with javascript: URIs? Should that script run with the loader's principal? Or will that be a problem for myspace and company?
Updated•18 years ago
|
Assignee: security-bugs → dveditz
QA Contact: carosendahl → toolkit
Assignee | ||
Comment 11•18 years ago
|
||
Another question. When doing a security check for a stylesheet load, should we use the principal of the stylesheet, or the principal of the document that loaded the stylesheet? Or some intersection (meet in brendan's terms)? Or should we simply set the principal of the sheet to the intersection to start with, except for user/ua sheets?
Note that bug 204140 and bug 310165 are basically requesting that we use the sheet's principal.
Requesting blocking, since this bug is sort of turning into a "define a security policy for stylesheets" bug, which is something I think we should absolutely do for 1.9.
Assignee | ||
Comment 12•18 years ago
|
||
Patch will depend on bug 369244 to not execute JS...
Depends on: 369244
Assignee | ||
Comment 13•18 years ago
|
||
Attached patch basically works; once the dependencies land I'll write some tests and then look for reviews.
Propagating the principal to the non-@import loads is going to be a separate bug (like bug 204140 and bug 310165). For now I'm just trying to get the principal for the stylesheet right without allowing "@import url('javascript:...');" to execute.
Boris, since you started working on this you win the grand price :)
Assignee: dveditz → bzbarsky
Flags: blocking1.9? → blocking1.9-
Whiteboard: [wanted-1.9]
Assignee | ||
Comment 15•18 years ago
|
||
Again, first-come, first-served. ;)
Summary of changes:
- Add a principal to style sheet inners
- Make stylesheets always have inners and principals and remove null checks
- Propagate principals through the CSSLoader
- Change the CSSLoader's "same URI means it's the same sheet" setup to match on
both URI and originating principal. Not that the latter should really change
much...
Attachment #253932 -
Attachment is obsolete: true
Attachment #256892 -
Flags: superreview?(jonas)
Attachment #256892 -
Flags: review?(peterv)
Assignee | ||
Updated•18 years ago
|
Priority: -- → P2
Summary: Define security policy for stylesheets [was: Security check for same-origin access mistreats data: URIs] → [FIX]Define security policy for stylesheets [was: Security check for same-origin access mistreats data: URIs]
Target Milestone: --- → mozilla1.9alpha3
Comment 16•18 years ago
|
||
I have started reviewing.
Updated•18 years ago
|
Attachment #256892 -
Flags: review?(peterv) → review+
Assignee | ||
Comment 17•18 years ago
|
||
Peter, should I count that as an r+sr? Or do you want Jonas to look at this too?
Comment 18•18 years ago
|
||
Comment on attachment 256892 [details] [diff] [review]
Ready for review
Yeah, I can do r+sr.
Attachment #256892 -
Flags: superreview?(jonas) → superreview+
Assignee | ||
Comment 19•18 years ago
|
||
Attachment #256892 -
Attachment is obsolete: true
Assignee | ||
Comment 20•18 years ago
|
||
Checked in.
Status: NEW → RESOLVED
Closed: 18 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Updated•17 years ago
|
Flags: wanted1.9+
Whiteboard: [wanted-1.9]
You need to log in
before you can comment on or make changes to this bug.
Description
•