Closed Bug 1269246 Opened 8 years ago Closed 8 years ago

Possible use-after-free in nsCollationMacUC::AllocateRawSortKey

Categories

(Core :: Internationalization, defect)

All
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla49
Tracking Status
firefox49 --- fixed

People

(Reporter: m_kato, Assigned: m_kato)

References

Details

(Keywords: csectype-uaf, sec-other, Whiteboard: [post-critsmash-triage][adv-main49-])

Attachments

(1 file)

https://dxr.mozilla.org/mozilla-central/rev/1461a4071341c282afcf7b72e33036412d2251d4/intl/locale/mac/nsCollationMacUC.cpp#178

NS_IMETHODIMP nsCollationMacUC::AllocateRawSortKey(int32_t strength, const nsAString& stringIn,
                                                   uint8_t** key, uint32_t* outLen)
...
  const UChar* str = (const UChar*)PromiseFlatString(stringIn).get();

  int32_t keyLength = ucol_getSortKey(mCollatorICU, str, stringInLen, nullptr, 0);

str is already free when using it at ucol_getSortKey if stringIn isn't null-terminated string.
I believe that this isn't critical because AllocateRawSortKey isn't scriptable and this method is used on xpath only (xpath uses nsString that is null-terminated)
1045958
Unnecessary to use PromiseFlatString.  ICU don't require null terminated string that has length parameter.
Attachment #8747592 - Flags: review?(hsivonen)
Attachment #8747592 - Attachment is patch: true
Depends on: 1045958
Attachment #8747592 - Flags: review?(hsivonen) → review+
Group: core-security → dom-core-security
Summary: Possible use-after-tree in nsCollationMacUC::AllocateRawSortKey → Possible use-after-free in nsCollationMacUC::AllocateRawSortKey
It sounds like this is not a danger right now, so I'm going to mark it sec-other.
Keywords: sec-other
Comment on attachment 8747592 [details] [diff] [review]
Remove unnecessary PromiseFlatString. r?hsivonen

[Security approval request comment]
How easily could an exploit be constructed based on the patch?

This is possible use-after-free.  But this interface doesn't export to extensions and web, so I think that attacker cannot create exploit code via this issue.

Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?

This code causes possible use-after-free.
const UChar* str = (const UChar*)PromiseFlatString(stringIn).get();

It means
{
  PromiseFlatString nullstr(stringIn);
  const UChar* str = (const UChar*)nullstr.get();
}
...

If stringIn isn't null terminated nsAString, it causes use-after-free.  But This method uses from XPath only now, then it uses nsString that is null-terminated.  So use-after-free won't occur on real situation.


Which older supported branches are affected by this flaw?
This code is from bug 1045958.  So all branches has this bug.

If not all supported branches, which bug introduced the flaw?

Do you have backports for the affected branches? If not, how different, hard to create, and risky will they be?
Yet.  But we can port this to branches by same patch.

How likely is this patch to cause regressions; how much testing does it need?
Too low.  This code is used for XPath only.  xpath's test code covers this.
Attachment #8747592 - Flags: sec-approval?
This is a sec-other, which doesn't need sec-approval to go in. Is there a specific reason you're asking for sec-approval?

https://wiki.mozilla.org/Security/Bug_Approval_Process
Flags: needinfo?(m_kato)
(In reply to Al Billings [:abillings] from comment #6)
> This is a sec-other, which doesn't need sec-approval to go in. Is there a
> specific reason you're asking for sec-approval?
> 
> https://wiki.mozilla.org/Security/Bug_Approval_Process

Ah, OK,  This is no reason for sec-approval.
Flags: needinfo?(m_kato)
Attachment #8747592 - Flags: sec-approval?
https://bugzilla.mozilla.org/show_bug.cgi?id=1269246
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
Group: dom-core-security → core-security-release
Whiteboard: [post-critsmash-triage]
Whiteboard: [post-critsmash-triage] → [post-critsmash-triage][adv-main49-]
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: