Closed
Bug 1484910
Opened 8 years ago
Closed 7 years ago
Dangerous usage of CheckedInt in mozilla::WidgetQueryContentEvent::Input::MakeOffsetAbsolute
Categories
(Core :: DOM: UI Events & Focus Handling, defect, P2)
Tracking
()
RESOLVED
FIXED
mozilla67
People
(Reporter: pauljt, Assigned: Alex_Gaynor)
Details
(Keywords: sec-low, Whiteboard: [post-critsmash-triage][adv-main67-])
Attachments
(1 external file)
I'm doing some static analysis to look for dangerous usage of the CheckedInt. The following function, MakeOffsetAbsolute[1], adds two integers and then assigns them to a CheckedInt. If I understand CheckedInt correctly, there is a chance that an overflow will happen PRIOR to assigning to checked int:
CheckedInt<uint32_t> absOffset = mOffset + aInsertionPointOffset;
Is there a chance this might overflow PRIOR to being assigned to CheckedInt? As far as I can see[2], the normal idiom should be something like:
CheckedInt<uint32_t> absOffset = CheckedInt<uint32_t>(mOffset) + aInsertionPointOffset;
Am I correct here, or is there some C++ type coercion that makes this safe?
Now is this _actually_ an exploitable security bug, not as far as I can see. It looks the inputs to this function come from the IME on the system, and I can't see any paths that allow these to be controlled by untrusted content. BUt Im not confident of that as TextEvent is pretty complicated. So Im flagging as security sensitive just in case. (and so as not to disclose this pattern, as there are more of these, see the bug that this blocks)
[1] https://searchfox.org/mozilla-central/rev/71ef4447db179639be9eff4471f32a95423962d7/widget/TextEvents.h#1048
[2] https://searchfox.org/mozilla-central/source/mfbt/CheckedInt.h#485
| Reporter | ||
Updated•8 years ago
|
Component: Source Code Analysis → Widget
Product: Firefox Build System → Core
Updated•8 years ago
|
Group: core-security → layout-core-security
Updated•8 years ago
|
Component: Widget → Event Handling
Comment 1•8 years ago
|
||
Yeah, as you said, it comes only from IME or something via native IME event or interface, they must be enough safe. So, it just checks whether coming values make sense or not since we're struggling with odd behavior of a lot of IMEs even in these days. And your suggestion to fix it looks good to me.
Comment 2•8 years ago
|
||
We should fix this, but the security risk seems low if the input is only from the IME.
Keywords: sec-low
Updated•8 years ago
|
Group: layout-core-security → dom-core-security
Updated•8 years ago
|
Priority: -- → P2
| Assignee | ||
Comment 3•7 years ago
|
||
| Assignee | ||
Updated•7 years ago
|
Assignee: nobody → agaynor
| Assignee | ||
Updated•7 years ago
|
Keywords: checkin-needed
Comment 4•7 years ago
|
||
Not sure which static analysis comment 0 refers to, but the in-tree one specifically intended to prevent this sort of lapse, apparently does not. I filed bug 1533623 to do so -- currently hidden because who knows if any other uses, more problematic than this one, exist in the tree.
Comment 5•7 years ago
|
||
https://hg.mozilla.org/integration/autoland/rev/b32055608807968d77af0b75a85e3c7dc49a692f
https://hg.mozilla.org/mozilla-central/rev/b32055608807
Group: dom-core-security → core-security-release
Status: NEW → RESOLVED
Closed: 7 years ago
status-firefox67:
--- → fixed
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla67
Updated•7 years ago
|
Updated•7 years ago
|
Component: Event Handling → User events and focus handling
Updated•7 years ago
|
Flags: qe-verify-
Whiteboard: [post-critsmash-triage]
Updated•7 years ago
|
Whiteboard: [post-critsmash-triage] → [post-critsmash-triage][adv-main67-]
Updated•6 years ago
|
Group: core-security-release
You need to log in
before you can comment on or make changes to this bug.
Description
•