Closed
Bug 975387
Opened 11 years ago
Closed 11 years ago
TextComposition should clear mPresContext when the PresContext is destroyed
Categories
(Core :: DOM: UI Events & Focus Handling, defect)
Core
DOM: UI Events & Focus Handling
Tracking
()
RESOLVED
FIXED
mozilla30
| Tracking | Status | |
|---|---|---|
| firefox27 | --- | unaffected |
| firefox28 | --- | unaffected |
| firefox29 | + | fixed |
| firefox30 | + | fixed |
| firefox-esr24 | --- | unaffected |
| b2g-v1.2 | --- | unaffected |
| b2g-v1.3 | --- | unaffected |
| b2g-v1.4 | --- | fixed |
People
(Reporter: masayuki, Assigned: masayuki)
References
Details
(Keywords: csectype-uaf, sec-critical, Whiteboard: [qa-])
Attachments
(2 files, 1 obsolete file)
|
4.74 KB,
patch
|
masayuki
:
review+
abillings
:
sec-approval+
|
Details | Diff | Splinter Review |
|
4.35 KB,
patch
|
masayuki
:
review+
abillings
:
approval-mozilla-aurora+
|
Details | Diff | Splinter Review |
This may be dangerous.
The TextComposition::mPresContext may be referred after destroyed.
We should fix this bug on Aurora too.
Updated•11 years ago
|
Group: dom-core-security, core-security
| Assignee | ||
Comment 1•11 years ago
|
||
Updated•11 years ago
|
Keywords: csectype-uaf,
sec-critical
| Assignee | ||
Comment 2•11 years ago
|
||
I realized this bug when I was writing a patch for another bug. Therefore, I'm not sure this bug actually causes crash or something.
At compositionstart event handler, JS may do something to destroy its presContext. Then, mPresContext may be already released.
However, when this method is called, the caller's PresShell is held by nsViewManager with local variable:
http://mxr.mozilla.org/mozilla-central/source/view/src/nsViewManager.cpp#751
And PresShell::mPresContext must be alive while PresShell instance is alive because its destructor releases mPresContext:
http://mxr.mozilla.org/mozilla-central/source/layout/base/nsPresShell.cpp#769
Although, I don't know the reason why PresShell checks mPresContext at a lot of plases...
So, I think that this is safe, but may not be so in the future. So, we should make a wall with this patch.
Attachment #8379724 -
Attachment is obsolete: true
Attachment #8379751 -
Flags: review?(bugs)
Updated•11 years ago
|
Attachment #8379751 -
Flags: review?(bugs) → review+
| Assignee | ||
Comment 3•11 years ago
|
||
Comment on attachment 8379751 [details] [diff] [review]
Patch
[Security approval request comment]
How easily could an exploit be constructed based on the patch?
As I said in my previous comment, the mPresContext is always held luckily.
Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?
The check-in comment might be so. I'd like you to suggest other commit message if you think it's bad.
Which older supported branches are affected by this flaw?
Aurora has this bug too. Beta and Release don't have this.
If not all supported branches, which bug introduced the flaw?
The referencing code of mPresContext after dispatching an event is added by bug 935821.
Do you have backports for the affected branches? If not, how different, hard to create, and risky will they be?
It's easy. I'll post the patch for Aurora soon.
How likely is this patch to cause regressions; how much testing does it need?
Even if this causes regressions, it's only affected to e10s. But e10s hasn't supported IME completely yet.
Attachment #8379751 -
Flags: sec-approval?
| Assignee | ||
Comment 4•11 years ago
|
||
[Approval Request Comment]
Bug caused by (feature/regressing bug #): Bug 935821
User impact if declined: As far as I researched, this doesn't cause actual trouble. But this makes a wall for the dangerous scenario.
Testing completed (on m-c, etc.): Not yet landed on m-c. Waiting sec-approval.
Risk to taking this patch (and alternatives if risky): No idea. After nsIMEStateManager stops managing TextComposition instances, they shouldn't be used for dispatching any events. (Others cannot retrieve the destroyed instance in expected scenarios)
String or IDL/UUID changes made by this patch: Nothing.
Attachment #8380472 -
Flags: review+
Attachment #8380472 -
Flags: approval-mozilla-aurora?
| Assignee | ||
Comment 5•11 years ago
|
||
Comment on attachment 8379751 [details] [diff] [review]
Patch
Hmm, I'm sorry. I found this patch is not enough.
Attachment #8379751 -
Flags: sec-approval?
Attachment #8379751 -
Flags: review-
Attachment #8379751 -
Flags: review+
| Assignee | ||
Comment 6•11 years ago
|
||
Comment on attachment 8380472 [details] [diff] [review]
Patch for Aurora
cancelling the request because I found that this is not enough.
Attachment #8380472 -
Flags: review-
Attachment #8380472 -
Flags: review+
Attachment #8380472 -
Flags: approval-mozilla-aurora?
| Assignee | ||
Comment 7•11 years ago
|
||
Comment on attachment 8379751 [details] [diff] [review]
Patch
Sorry for the spam. I misunderstood as that nsIMEStateManager::DispatchCompositionEvent() will create new composition with destroyed PresContext. However, I confirmed that my concern is wrong.
So, this patch's wall works as I expected.
Please see comment 3 for the sec-approval.
Attachment #8379751 -
Flags: sec-approval?
Attachment #8379751 -
Flags: review-
Attachment #8379751 -
Flags: review+
| Assignee | ||
Comment 8•11 years ago
|
||
Comment on attachment 8380472 [details] [diff] [review]
Patch for Aurora
Sorry for the spam.
See comment 4 and comment 7. This patch is enough for avoiding the reported bug completely.
Attachment #8380472 -
Flags: review-
Attachment #8380472 -
Flags: review+
Attachment #8380472 -
Flags: approval-mozilla-aurora?
| Assignee | ||
Comment 9•11 years ago
|
||
Anyway, we need to redesign the cases at destroying a document from composition event handlers. Even with these patches, IME state is still confused even in the next focused editor.
Comment 10•11 years ago
|
||
Comment on attachment 8379751 [details] [diff] [review]
Patch
sec-approval+ for trunk. I'm not concerned about the commit message as long as we take this on Aurora as well.
Attachment #8379751 -
Flags: sec-approval? → sec-approval+
Updated•11 years ago
|
Attachment #8380472 -
Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Updated•11 years ago
|
status-b2g-v1.2:
--- → unaffected
status-b2g-v1.3:
--- → unaffected
status-b2g-v1.4:
--- → affected
status-firefox-esr24:
--- → unaffected
| Assignee | ||
Comment 11•11 years ago
|
||
(In reply to Al Billings [:abillings] from comment #10)
> sec-approval+ for trunk. I'm not concerned about the commit message as long
> as we take this on Aurora as well.
Thank you for the sec-review.
You said "sec-approval+ for trunk", but you gives + for approval-mozilla-aurora too. Can I land them now? Or do I need to request sec-review for tha patch for Aurora again?
Flags: needinfo?(abillings)
Comment 12•11 years ago
|
||
Once you have sec-approval for trunk, the patches can be landed anywhere, as long as they go through the usual approval process. So the patch can be landed immediately on trunk and Aurora. The idea is that once a patch lands on any branch, a bad guy could see it, so it doesn't matter much from a security perspective if it lands on other branches, too.
Flags: needinfo?(abillings)
| Assignee | ||
Comment 13•11 years ago
|
||
Thank you, I'll land them after lunch.
| Assignee | ||
Comment 14•11 years ago
|
||
Comment 15•11 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Flags: in-testsuite?
Resolution: --- → FIXED
Target Milestone: --- → mozilla30
Comment 16•11 years ago
|
||
The tree rules are clear that you are not to double-land patches on Aurora and inbound. Please wait until the patch has stuck on trunk before uplifting. Also, when landing on the release branches, please set the status flag appropriately.
| Assignee | ||
Comment 17•11 years ago
|
||
(In reply to Ryan VanderMeulen [:RyanVM UTC-5] from comment #16)
> The tree rules are clear that you are not to double-land patches on Aurora
> and inbound. Please wait until the patch has stuck on trunk before
> uplifting. Also, when landing on the release branches, please set the status
> flag appropriately.
I see. Thank you for your explanation.
Flags: needinfo?(masayuki)
Comment 18•11 years ago
|
||
Yes, generally "sec-approval+" is an approval for trunk landing. After it lands on trunk, you can get approval for any branch patches as necessary. We want it to go green on trunk though.
Updated•11 years ago
|
Group: dom-core-security
Comment 19•11 years ago
|
||
Marking [qa-] due to lack of test case, but feel free to provide one if you'd like verification. Thanks.
Whiteboard: [qa-]
Updated•10 years ago
|
Group: core-security
Updated•6 years ago
|
Component: Event Handling → User events and focus handling
You need to log in
before you can comment on or make changes to this bug.
Description
•