Closed Bug 1276052 Opened 8 years ago Closed 8 years ago

nsPrefetchService using NS_ConvertUTF16toUTF8 unsafely

Categories

(Core :: Networking, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla50
Tracking Status
firefox49 --- fixed
firefox50 --- fixed

People

(Reporter: mconley, Assigned: u408661)

References

Details

(Keywords: sec-low, Whiteboard: [necko-active][post-critsmash-triage][adv-main49-])

Attachments

(1 file)

This happens here: https://dxr.mozilla.org/mozilla-central/rev/8d0aadfe7da782d415363880008b4ca027686137/uriloader/prefetch/nsPrefetchService.cpp#827

See: https://dxr.mozilla.org/mozilla-central/source/xpcom/string/nsTPromiseFlatString.h#35

We ran into something like this in bug 1276013 - essentially, this pattern:

const char* buffer = NS_ConvertUTF16toUTF8(aStr).get();

results in buffer being a dangling pointer that is use-after-freeable.

One needs to fiddle a pref in order to get to this chunk of the code, so it's probably not a huge deal. Still, we probably should plug this.
Blocks: 1213443
Is this only enabled in nightly right now? (Based on bug 1016628) Or does this also affect other branches?
Flags: needinfo?(mconley)
nsPrefetchService has nothing to do with the stuff in bug 1016628, this has been in the tree since 44. Again, requires a particular pref to be flipped while running to even be a potential issue, but even a potential issue bears fixing :)
Flags: needinfo?(mconley)
Group: core-security → network-core-security
Keywords: sec-audit
Comment on attachment 8757418 [details] [diff] [review]
Fix NS_ConvertUTF16toUTF8 usage.

Ignore the r=bz in the patch, I'll fix that up after r+ (don't want to fight bugzilla trying to get it so bz can review this).
Attachment #8757418 - Flags: review?(bugs)
Assignee: nobody → hurley
Status: NEW → ASSIGNED
Whiteboard: [necko-active]
Comment on attachment 8757418 [details] [diff] [review]
Fix NS_ConvertUTF16toUTF8 usage.

NS_ConvertUTF16toUTF8 is a class, so you could also do
NS_ConvertUTF16toUTF8 converted(aData);
But up to you.

Nit, * goes with the type, not with variable name, so char* pref
Attachment #8757418 - Flags: review?(bugs) → review+
Keywords: sec-low
https://hg.mozilla.org/mozilla-central/rev/5e5914f11000
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
Comment on attachment 8757418 [details] [diff] [review]
Fix NS_ConvertUTF16toUTF8 usage.

Approval Request Comment
[Feature/regressing bug #]: bug 1213443
[User impact if declined]: potential uaf security risk when changing one pref
[Describe test coverage new/current, TreeHerder]: on m-c
[Risks and why]: low/none
[String/UUID change made/needed]: none
Attachment #8757418 - Flags: approval-mozilla-aurora?
Group: network-core-security → core-security-release
Comment on attachment 8757418 [details] [diff] [review]
Fix NS_ConvertUTF16toUTF8 usage.

Based on comment 2 sounds like a good idea to bring this up at least to aurora to prevent potential UAF.
Attachment #8757418 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Whiteboard: [necko-active] → [necko-active][post-critsmash-triage]
Whiteboard: [necko-active][post-critsmash-triage] → [necko-active][post-critsmash-triage][adv-main49-]
Group: core-security-release
Is it possible to prevent such usage by static analysis or something?
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: