Closed
Bug 890853
(CVE-2013-1726)
Opened 12 years ago
Closed 11 years ago
MAR signature bypass in Updater could lead to downgrade
Categories
(Toolkit :: Application Update, defect)
Tracking
()
RESOLVED
FIXED
mozilla25
Tracking | Status | |
---|---|---|
firefox22 | --- | wontfix |
firefox23 | + | wontfix |
firefox24 | + | fixed |
firefox25 | + | verified |
firefox-esr17 | 24+ | fixed |
b2g18 | --- | unaffected |
b2g-v1.1hd | --- | unaffected |
b2g-v1.2 | --- | unaffected |
People
(Reporter: sebbity, Assigned: bbondy)
References
Details
(4 keywords, Whiteboard: [reporter-external][adv-main24+][adv-esr1709+] local attack by low-privileged user account)
Attachments
(2 files)
6.11 KB,
application/zip
|
Details | |
1.39 KB,
patch
|
robert.strong.bugs
:
review+
bajaj
:
approval-mozilla-aurora+
lsblakk
:
approval-mozilla-beta-
bajaj
:
approval-mozilla-esr17+
abillings
:
sec-approval+
|
Details | Diff | Splinter Review |
The updater doesn't write-lock the user-supplied MAR file while it is using it. This leads to a race condition between the MAR file's signatures being validated and the actual access of data within the file.
If an attacker can change the file after the MAR signatures are validated, but before data is read, the attacker supplied MAR data will be what the updater uses. The proof-of-concept uses this to replace the version string which allows us to downgrade Firefox to a vulnerable version (at which point an attacker could use a previous vulnerability such as #888314 to execute arbitrary code).
I'd imagine with further investigation into the MAR file format an attacker could feasibly have the updater extract and run their own files as part of the update process as well. This all runs as the SYSTEM user.
Proof-of-concept is attached. It expects the current directory to hold an update.original.mar file (tested with http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/20.0/update/win32/en-GB/firefox-20.0.complete.mar), which it will use to downgrade the Firefox installation in c:\Program Files (x86)\Mozilla Firefox\.
As with race conditions, timing can be a little finicky. On my PC (Win7 x64, updater.exe 22.0.0.4917) I find there's a 200ms window between ~250-450ms. Given no arguments, the PoC will start at 200ms and work its way up to 1000ms in 10ms increments until it succeeds.
![]() |
||
Updated•12 years ago
|
Flags: sec-bounty?
Whiteboard: [reporter-external]
Assignee | ||
Comment 1•12 years ago
|
||
We did take special care to make sure the MAR file was opened before verifying its signature and using it, without closing it in between.
Unfortunately it looks like mar_open maps to _wfopen which allows file sharing rights by default. see:
http://mxr.mozilla.org/mozilla-central/source/modules/libmar/src/mar_read.c#181
We can simply change this to use _wfopen_s and the problem should be fixed.
_wfopen_s doesn't allow any file sharing rights.
i.e. _wfopen uses CreateFile's FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE
_wfopen_s uses none of those flags.
VS2005's SDK's CRT and above supports it so I think we can use it.
Note: the new code that was added which protects replacing updater.exe uses CreateFile directly so doesn't specify the sharing flags. The mar_open code predates the maintenance service, but we haven't verified signatures until the same time.
Also note that this problem is equally a problem without the maintenance service since we verify signatures on the MAR file without the maintenance service as well. It just landed close to the maintenance service.
Assignee | ||
Updated•12 years ago
|
Assignee: nobody → netzen
Assignee | ||
Comment 2•12 years ago
|
||
See last comment.
Attachment #772027 -
Flags: review?(robert.bugzilla)
Assignee | ||
Updated•12 years ago
|
Summary: MAR signature bypass in Updater → MAR signature bypass in Updater could lead to downgrade
Assignee | ||
Updated•12 years ago
|
Attachment #772027 -
Attachment is patch: true
Attachment #772027 -
Attachment mime type: text/x-patch → text/plain
![]() |
||
Updated•12 years ago
|
Attachment #772027 -
Flags: review?(robert.bugzilla) → review+
Assignee | ||
Comment 3•12 years ago
|
||
Comment on attachment 772027 [details] [diff] [review]
Patch v1.
There is no security rating yet so I thought I'd request sec-approval just in case.
[Security approval request comment]
How easily could an exploit be constructed based on the patch?
There is one attache to this bug, somewhat easily but you need physical access to the machine.
Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?
I don't think it's very well known that _wfopen_s doesn't allow sharing but _wfopen does, so I don't think it points a bulls-eye on the problem.
Which older supported branches are affected by this flaw?
All, it's worth noting that old versions of Firefox before the maintenance service didn't even try to protect against spoofed MAR files. So we lived with this in the past.
If not all supported branches, which bug introduced the flaw?
Bug 699700 but we didn't have MAR verification at all before that.
Do you have backports for the affected branches? If not, how different, hard to create, and risky will they be?
The patches should be the same.
How likely is this patch to cause regressions; how much testing does it need?
Low, I'll be pushing to oak first to manually test.
Attachment #772027 -
Flags: sec-approval?
Updated•12 years ago
|
Keywords: csec-priv-escalation,
sec-high
Whiteboard: [reporter-external] → [reporter-external] local attack by low-privileged user account
Comment 4•12 years ago
|
||
Adding release management before sec-approval as we'll need to take this on ESR, where it is more of a concern.
Dan pointed out that the only diff in the patch is a change to a _s version of an api that was created as a _s variant specifically for security reasons but the patch itself is trivial.
Updated•12 years ago
|
Flags: needinfo?(release-mgmt)
Updated•12 years ago
|
status-firefox22:
--- → wontfix
status-firefox23:
--- → affected
status-firefox24:
--- → affected
status-firefox25:
--- → affected
status-firefox-esr17:
--- → affected
tracking-firefox23:
--- → ?
tracking-firefox24:
--- → ?
tracking-firefox25:
--- → +
tracking-firefox-esr17:
--- → ?
Updated•12 years ago
|
Updated•12 years ago
|
Flags: needinfo?(release-mgmt)
Comment 5•12 years ago
|
||
Comment on attachment 772027 [details] [diff] [review]
Patch v1.
sec-approval+ since release management plussed it for branches.
Attachment #772027 -
Flags: sec-approval? → sec-approval+
Updated•12 years ago
|
Flags: needinfo?(release-mgmt)
Updated•12 years ago
|
Flags: sec-bounty? → sec-bounty+
Comment 7•12 years ago
|
||
Let's get an uplift nomination here so we can land this before tomorrow's beta and get qa around the updater code.
Flags: needinfo?(netzen)
Keywords: verifyme
Assignee | ||
Comment 10•12 years ago
|
||
This hasn't landed on m-c yet, I'll request uplift once it does, and once it is on there for a couple days. This will not make tomorrow's beta.
Assignee | ||
Updated•12 years ago
|
Flags: needinfo?(netzen)
Comment 11•12 years ago
|
||
This should land asap - we have to give QA a chance to test it - so please ensure this is landed to central and nominated for uplift in the next day or so in order to make our second-to-last beta which goes to build Thursday morning.
Flags: needinfo?(netzen)
Assignee | ||
Comment 12•12 years ago
|
||
I understand the importance and urgency. This will land as soon as it is safe to do so, and as soon as I verify it and its duped PoCs.
Flags: needinfo?(netzen)
Assignee | ||
Comment 13•12 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/896cdd92608d
I can't successfully reproduce with the PoC but the reported problem makes sense and the fix is what needs to be done. I'd appreciate help verifying this on mozilla-central after it lands there please Seb Patane.
I couldn't reproduce with the duped bug PoCs either. It's just a hard timing thing to get right I think.
Assignee | ||
Comment 14•12 years ago
|
||
Comment on attachment 772027 [details] [diff] [review]
Patch v1.
[Approval Request Comment]
Bug caused by (feature/regressing bug #): Bug 699700 added mar signing, but before that we didn't even do mar signing. We never locked the Mar during updates either.
User impact if declined: User that has physical access to a machine, if unelevated can extract files to an elevated location. They can downgrade firefox.
Testing completed (on m-c, etc.): I tested on oak to make sure updates didn't break. I couldn't reproduce the PoC problem though so I hope the original reporter can help with that.
Risk to taking this patch (and alternatives if risky): Low
String or IDL/UUID changes made by this patch: None
Attachment #772027 -
Flags: approval-mozilla-esr17?
Attachment #772027 -
Flags: approval-mozilla-beta?
Attachment #772027 -
Flags: approval-mozilla-aurora?
Reporter | ||
Comment 15•12 years ago
|
||
Sure thing Brian, let me know when it makes it into a nightly and I'll check.
Comment 16•12 years ago
|
||
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla25
Comment 17•12 years ago
|
||
Let's wait to take this on any branches until it's confirmed to fix the problem on Nightly, and doesn't cause regressions. This means we may not take a fix until FF24, given this is an update change.
When approved last week we expected a quick landing.
Assignee | ||
Comment 18•12 years ago
|
||
(In reply to Alex Keybl [:akeybl] from comment #17)
> When approved last week we expected a quick landing.
A patch was provided and r+ed 07-08, but there was no approval given until a week after that. Had the sec-approval (which was waiting on release management) been given earlier, then this would have landed much earlier. There is a real cost of context switching when waiting a week after a patch is provided and r+ed. Please set expectations to match turnarounds that you can also match. Thanks.
Comment 19•12 years ago
|
||
Brian, we've been working out some of the kinks between branch approvals and sec-approvals. Things should go more quickly in the future.
That said, there *was* as much time waiting for checkin as you were waiting for approval and the branch patch did only show up yesterday. We can't take certain things too late in the cycle and the cycle is only six weeks long. We'll be faster in the future but things need to go in fairly quickly when they do get approval.
Assignee | ||
Comment 20•12 years ago
|
||
(In reply to Al Billings [:abillings] from comment #19)
> Brian, we've been working out some of the kinks between branch approvals and
> sec-approvals. Things should go more quickly in the future.
> That said, there *was* as much time waiting for checkin as you were waiting
> for approval and the branch patch did only show up yesterday. We can't take
> certain things too late in the cycle and the cycle is only six weeks long.
> We'll be faster in the future
My complaint was not about the length of time taken, it was about uneven expectations and blame mentioned in Comment 17.
> but things need to go in fairly quickly when they do get approval.
I test updater related changes on oak and run through several manual tests first. This takes extra time compared to normal approvals which can go in with no extra work after approval. I also have a large queue of other things I'm working on. My average check-in time after approval I'm sure is a day. That being said, the statement is understood and already followed.
Assignee | ||
Comment 21•12 years ago
|
||
Hi Seb Patane, could you give thi build a try?
http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/2013-07-24-03-02-04-mozilla-central/firefox-25.0a1.en-US.win32.installer.exe
Updated•12 years ago
|
Reporter | ||
Comment 22•12 years ago
|
||
Hi Brian, the proof of concept fails consistently with the nightly build - the updater returns error code 6 instead of successfully exploiting.
Updated•12 years ago
|
Attachment #772027 -
Flags: approval-mozilla-beta? → approval-mozilla-beta-
Comment 24•12 years ago
|
||
Approving on aurora given the nightly verification.
Updated•12 years ago
|
Attachment #772027 -
Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Comment 25•12 years ago
|
||
Updated•12 years ago
|
Whiteboard: [reporter-external] local attack by low-privileged user account → [reporter-external][adv-main24+] local attack by low-privileged user account
Comment 26•12 years ago
|
||
This has been waiting for ESR17 patch approval for a month. Release management, can you give it please?
Alias: CVE-2013-1726
Flags: needinfo?(release-mgmt)
Updated•12 years ago
|
Updated•12 years ago
|
Attachment #772027 -
Flags: approval-mozilla-esr17? → approval-mozilla-esr17+
Comment 27•12 years ago
|
||
(In reply to Al Billings [:abillings] from comment #26)
> This has been waiting for ESR17 patch approval for a month. Release
> management, can you give it please?
Approved ! Clearing the needinfo.
Also adding checkin-needed and cc'ing Ryan so this can get landed on the esr17 branch.
Flags: needinfo?(release-mgmt)
Updated•12 years ago
|
Keywords: checkin-needed
Comment 28•11 years ago
|
||
Keywords: checkin-needed
Updated•11 years ago
|
Whiteboard: [reporter-external][adv-main24+] local attack by low-privileged user account → [reporter-external][adv-main24+][adv-esr1709+] local attack by low-privileged user account
Comment 29•11 years ago
|
||
Hi Seb, we'd like to know if two other branches also pass your verification. They should.
ftp://ftp.mozilla.org/pub/mozilla.org/firefox/candidates/17.0.9esr-candidates/build1/win32/
ftp://ftp.mozilla.org/pub/mozilla.org/firefox/candidates/24.0-candidates/build1/win32/
If you have time to check out one or both of the above, we'd really appreciate it.
Thanks.
Status: VERIFIED → RESOLVED
Closed: 12 years ago → 11 years ago
Updated•11 years ago
|
status-b2g18:
--- → unaffected
status-b2g-v1.1hd:
--- → unaffected
status-b2g-v1.2:
--- → unaffected
Updated•11 years ago
|
Group: core-security
Updated•9 months ago
|
Keywords: reporter-external
You need to log in
before you can comment on or make changes to this bug.
Description
•