Closed
Bug 1411716
(CVE-2017-7846)
Opened 7 years ago
Closed 7 years ago
TBE-01-014: JavaScript Execution via RSS in mailbox:// origin
Categories
(MailNews Core :: Feed Reader, defect)
Tracking
(thunderbird_esr5257+ fixed, thunderbird57 unaffected, thunderbird58 unaffected)
RESOLVED
FIXED
Thunderbird 58.0
Tracking | Status | |
---|---|---|
thunderbird_esr52 | 57+ | fixed |
thunderbird57 | --- | unaffected |
thunderbird58 | --- | unaffected |
People
(Reporter: BenB, Assigned: alta88)
References
Details
(Keywords: csectype-sop, sec-high)
Attachments
(4 files, 4 obsolete files)
1.42 KB,
patch
|
Details | Diff | Splinter Review | |
15.67 KB,
patch
|
jorgk-bmo
:
review+
|
Details | Diff | Splinter Review |
1008 bytes,
patch
|
alta88
:
review+
|
Details | Diff | Splinter Review |
15.32 KB,
patch
|
Details | Diff | Splinter Review |
In case a user views RSS feeds as a website, e.g. via “View -> Feed article -> Website” or in the standard format of “View -> Feed article -> default format”, it is possible to execute JavaScript in the parsed RSS feed.
When either one of the aforementioned two settings is in place, Thunderbird will check for the presence of a <link> element in a RSS item. It will then fetch and display the specified origin. The remote web page is from then on allowed to execute JavaScript like any normal web page. This is not a straightforward security issue, as the default Same Origin Policy is applied. In case where no <link> element is present, Thunderbird will parse the description element but will forbid JavaScript execution. A possibility to bypass the restriction was uncovered with relation to specifying a data:text/html URL for a <link> element. Thunderbird parses the data: URL and displays the defined HTML page, which then operates in the mailbox:// origin and is allowed to execute JavaScript:
PoC RSS Feed:
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>Feed1</title>
<link>http://example.com</link>
<item>
<title>Feed1</title>
<link>data:text/html,%3ch1%3easdf%3c/h1%3e%3cscript%3ealert(123)
%3c/script%3e</link>
</item>
</channel>
</rss>
It is recommended to only allow HTTP/HTTPS URLs in <link> tags. This ensures that a feed can exclusively specify real remote web pages, therefore being restricted to its own origin.
Reporter | ||
Comment 1•7 years ago
|
||
For the original report as PDF; see bug 1411701.
Disallow all non http* <link> type urls.
Attachment #8922854 -
Flags: review?(mkmelin+mozilla)
Updated•7 years ago
|
Keywords: csectype-sop,
sec-high
Summary: JavaScript Execution via RSS in mailbox:// Origin → TBE-01-014: JavaScript Execution via RSS in mailbox:// Origin
tweaks.
Assignee: nobody → alta88
Attachment #8922854 -
Attachment is obsolete: true
Attachment #8922854 -
Flags: review?(mkmelin+mozilla)
Attachment #8922969 -
Flags: review?(mkmelin+mozilla)
Comment 4•7 years ago
|
||
(In reply to Ben Bucksch (:BenB) from comment #0)
> In case where no <link> element is present, Thunderbird will parse
> the description element but will forbid JavaScript execution. A possibility
> to bypass the restriction was uncovered with relation to specifying a
> data:text/html URL for a <link> element. Thunderbird parses the data: URL
> and displays the defined HTML page, which then operates in the mailbox://
> origin and is allowed to execute JavaScript:
data uris are treated as unique opaque origins and do not inherit their origin, so whatever is happening here, there's some misunderstanding about why it's happening.
Updated•7 years ago
|
Status: NEW → ASSIGNED
Regardless of whether there is a principal/origin problem for a data: url load in this case, I would like the patch to go in.
The parser should not store junk for <link> nor do the feed specs anywhere mention data: as a valid url for <link>, (not even atom's iri spec reference for links), so data: is neither within the law and certainly not within the spirit for what a <link> type tag value should be.
Comment 6•7 years ago
|
||
Ah, the data uris shouldn't inherit origin is for v57 and above (bug 1324406). So, this bug is not a problem for trunk, we just need to handle it in 52.
Comment 7•7 years ago
|
||
And to be clear, this isn't about the principal but only origin. The problem it can cause is potential information disclosure in other mailbox:// uris if the attacker manages to the exact URLs.
Comment 8•7 years ago
|
||
(In reply to alta88 from comment #5)
> The parser should not store junk for <link> nor do the feed specs anywhere
> mention data: as a valid url for <link>, (not even atom's iri spec reference
> for links), so data: is neither within the law and certainly not within the
> spirit for what a <link> type tag value should be.
data uris are perfectly valid iris, so I do think the spec allows them (implicitly).
Comment 9•7 years ago
|
||
We could also just disable JavaScript for data: links.
For 57 and above, it's not needed since there the origin is not inherited. Any script executed there can be compared to one executed for a remote origin.
Assignee | ||
Comment 10•7 years ago
|
||
Without getting into the weeds of either the feed specs or spec for the now long obsolete Content-Base header in the coerced mail message from feed entry, "implicitly" is a big stretch. There is no reason to support data: uris in <link> type tags stored as mail headers.
Allowing a data: uri potentially laden with js, and then creating a policy for it at load time, is not a better practice than simply not allowing data: or other non http to be stored in the first place.
Comment 11•7 years ago
|
||
Comment on attachment 8922969 [details] [diff] [review]
parserLink.patch
Review of attachment 8922969 [details] [diff] [review]:
-----------------------------------------------------------------
Ok let's go with this one. r=mkmelin
::: mailnews/extensions/newsblog/content/feed-parser.js
@@ +908,5 @@
>
> return matchingChildren.length ? matchingChildren : null;
> },
>
> + validLink: function(link)
Please add a short documentation for the method.
@@ +910,5 @@
> },
>
> + validLink: function(link)
> + {
> + if (link && link.startsWith("http"))
Simpler and more bullet proof as
if(/https?:/.test(link))
@@ +1012,5 @@
> options.updates.updateBase = updateBase;
> aFeed.options = options;
> },
>
> + removeUnprintableASCII: function(s)
Here too, add documentation that you're removing ascii control chars such as \n
Attachment #8922969 -
Flags: review?(mkmelin+mozilla) → review+
Updated•7 years ago
|
status-thunderbird52:
--- → affected
status-thunderbird57:
--- → unaffected
status-thunderbird58:
--- → unaffected
Assignee | ||
Comment 12•7 years ago
|
||
updated for comments.
Attachment #8922969 -
Attachment is obsolete: true
Attachment #8926442 -
Flags: sec-approval?
Blocks: CVE-2017-7848
Comment 13•7 years ago
|
||
Does sec-approval even apply to TB only code? This is a gray area.
Flags: needinfo?(dveditz)
Comment 14•7 years ago
|
||
Also, alta88, you need to fill out the sec-approval? template when you set that flag anyway.
Flags: needinfo?(alta88)
Assignee | ||
Comment 15•7 years ago
|
||
Comment on attachment 8926442 [details] [diff] [review]
parserLink.patch
The flag was set because it was requested at first diagnosis. I don't think this patch rises to sec review level. It merely sanitizes a string to prevent non http urls.
Sec can decide if it's review worthy and any input is appreciated. Clearing for now.
Attachment #8926442 -
Flags: sec-approval?
Flags: needinfo?(alta88)
Keywords: checkin-needed
Updated•7 years ago
|
Attachment #8925664 -
Attachment description: bug1411716_feed_data_disable_js.patch → bug1411716_feed_data_disable_js.patch - For demonstration only, not to be landed.
Comment 16•7 years ago
|
||
Comment on attachment 8926442 [details] [diff] [review]
parserLink.patch
No indication on what to land here, so I assume it's this one.
Attachment #8926442 -
Flags: review+
Comment 17•7 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 58.0
![]() |
||
Comment 18•7 years ago
|
||
(In reply to Magnus Melin from comment #11)
> @@ +910,5 @@
> > },
> >
> > + validLink: function(link)
> > + {
> > + if (link && link.startsWith("http"))
>
> Simpler and more bullet proof as
>
> if(/https?:/.test(link))
It seems to me this will match also any "http:" in the middle of the string (e.g. in the Javascript we wanted to disallow).
Should it have been
if (/^https?:\/\//.test(link)) or link.startsWith("http://") || link.startsWith("https://") ?
Assignee | ||
Comment 19•7 years ago
|
||
Of course, thanks for checking aceman.
Attachment #8927088 -
Flags: review+
Keywords: checkin-needed
Assignee | ||
Comment 20•7 years ago
|
||
change status for sheriff search..
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment 21•7 years ago
|
||
Hi the "sheriff developer" here:
Do you really mean: |if (/^https?:\/\//.test(link))|? What is the ? meant to match? Or do you mean |if (/^http?:\/\//.test(link))| where the ? can match an "s"? Looking at the original patch, you mean the latter.
Keywords: checkin-needed
Comment 22•7 years ago
|
||
? means optionally having the preceding s, that is matching http and https
Keywords: checkin-needed
Comment 23•7 years ago
|
||
(In reply to Magnus Melin from comment #22)
> ? means optionally having the preceding s, that is matching http and https
Sorry, that just occurred to me, too. Here we go:
https://hg.mozilla.org/comm-central/rev/3c4fb63620220649e337cf826b3f1afc39824075
Status: REOPENED → RESOLVED
Closed: 7 years ago → 7 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Comment 24•7 years ago
|
||
(In reply to Al Billings [:abillings] from comment #13)
> Does sec-approval even apply to TB only code? This is a gray area.
I'm going to guess not because Tbird isn't supporting multiple branches and don't need to worry as much about 0-daying themselves.
Flags: needinfo?(dveditz)
Updated•7 years ago
|
Group: mail-core-security → core-security-release
Comment 25•7 years ago
|
||
Why are TB 57 and TB 58 "unaffected" and why did nobody request TB 52 uplift?
Flags: needinfo?(mkmelin+mozilla)
Flags: needinfo?(alta88)
Comment 26•7 years ago
|
||
Because for 57 and above the origin is not inherited (mozilla-central tightened security).
Flags: needinfo?(mkmelin+mozilla)
Updated•7 years ago
|
Attachment #8927088 -
Flags: approval-comm-esr52?
Updated•7 years ago
|
Attachment #8927088 -
Flags: approval-comm-esr52? → approval-comm-esr52+
Updated•7 years ago
|
Flags: needinfo?(alta88)
Comment 27•7 years ago
|
||
Comment on attachment 8927088 [details] [diff] [review]
parserLinkRegex.patch
Sadly these
https://hg.mozilla.org/comm-central/rev/98e543540fb6478308915be0849a5217ad2d0db1
https://hg.mozilla.org/comm-central/rev/3c4fb63620220649e337cf826b3f1afc39824075
don't apply to c-esr52 at all, many merge conflicts.
I could try to hand-craft patches for TB 52, but feeds might just break in the middle if I get something wrong.
Flags: needinfo?(alta88)
Attachment #8927088 -
Flags: approval-comm-esr52+
Comment 28•7 years ago
|
||
Hand-made comm-esr52 patch merging the two patches.
Comment 29•7 years ago
|
||
Oops, wrong patch attached.
Attachment #8938350 -
Attachment is obsolete: true
Comment 30•7 years ago
|
||
Removed some contentBase stuff which slipped in from the TB 58 version.
Attachment #8938351 -
Attachment is obsolete: true
Assignee | ||
Comment 31•7 years ago
|
||
Not sure what the needinfo action is. Looks like you have in under control.
Flags: needinfo?(alta88)
Comment 32•7 years ago
|
||
You could check the patch while I'm doing bug 1411699 and bug 1418666.
Assignee | ||
Comment 33•7 years ago
|
||
It looks fine, working around the xmlbase patch is annoying.. The patch in the other bug, on top of this one, also is fine.
Comment 34•7 years ago
|
||
Updated•7 years ago
|
status-thunderbird52:
fixed → ---
status-thunderbird_esr52:
--- → fixed
tracking-thunderbird_esr52:
--- → 57+
Updated•7 years ago
|
Alias: CVE-2017-7846
Summary: TBE-01-014: JavaScript Execution via RSS in mailbox:// Origin → TBE-01-014: JavaScript Execution via RSS in mailbox:// origin
Updated•5 years ago
|
Group: core-security-release
You need to log in
before you can comment on or make changes to this bug.
Description
•