Closed
Bug 1257765
Opened 9 years ago
Closed 8 years ago
[Mac] Obj-C exception: [NSInvalidArgumentException: *** -[_NSConcreteUserNotification setUserInfo:]. UserInfo too big. Encoded data greater than 16k....]
Categories
(Core :: Widget: Cocoa, defect)
Tracking
()
People
(Reporter: jruderman, Assigned: jaas)
References
Details
(Keywords: assertion, sec-high, testcase, Whiteboard: [post-critsmash-triage][adv-main48+][adv-esr45.3+])
Attachments
(4 files, 2 obsolete files)
(deleted),
text/html
|
Details | |
(deleted),
text/plain
|
Details | |
(deleted),
patch
|
spohl
:
review+
ritu
:
approval-mozilla-aurora+
ritu
:
approval-mozilla-beta+
abillings
:
sec-approval+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
ritu
:
approval-mozilla-esr45+
|
Details | Diff | Splinter Review |
1. Load the testcase
2. Reload
2016-03-17 23:13:28.512 firefox[3164:7228384] Mozilla has caught an Obj-C exception [NSInvalidArgumentException: *** -[_NSConcreteUserNotification setUserInfo:]. UserInfo too big. Encoded data greater than 16k. (32835 bytes)]
###!!! ASSERTION: This is unsafe! Fix the caller!: 'Error', file dom/events/EventDispatcher.cpp, line 553
Reporter | ||
Comment 1•9 years ago
|
||
Reporter | ||
Comment 2•9 years ago
|
||
(Are there two bugs here? One that we trip the Obj-C exception, and one that we recover incorrectly?)
Updated•9 years ago
|
Component: DOM → Widget: Cocoa
Reporter | ||
Comment 3•9 years ago
|
||
I split off the "recovering incorrectly" part into bug 1258945.
Summary: [Mac] "###!!! ASSERTION: This is unsafe! Fix the caller!" after caught Obj-C exception → [Mac] Obj-C exception: [NSInvalidArgumentException: *** -[_NSConcreteUserNotification setUserInfo:]. UserInfo too big. Encoded data greater than 16k....]
The exception here is being thrown in this line in 'OSXNotificationCenter::ShowAlertWithIconData':
notification.userInfo = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:alertName, nil]
forKeys:[NSArray arrayWithObjects:@"name", nil]];
The exception is:
UserInfo too big. Encoded data greater than 16k. (32835 bytes)
The basic fix would be to limit the size of the name being assigned to userInfo. Pretty simple.
When the exception is thrown it should be caught by these macros which wrap the contents of 'OSXNotificationCenter::ShowAlertWithIconData':
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
...
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
These macros are defined in 'xpcom/base/nsObjCExceptions.h':
#define NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT @try {
#define NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT } @catch(NSException *_exn) { \
nsObjCExceptionLog(_exn); \
} \
return NS_ERROR_FAILURE;
This will catch the exception, log it, try to log stack info only if in a debug build, and return NS_ERROR_FAILURE from the C++ method.
This limits the length of notification strings to 10k characters. Limits it before we waste time converting to NSString. Was able to repro the exception without this patch, it goes away with this patch.
The exception, when I repro'd, seemed to be handled properly. I didn't look very closely though.
Attachment #8733930 -
Flags: review?(spohl.mozilla.bugs)
Comment 7•9 years ago
|
||
Comment on attachment 8733930 [details] [diff] [review]
fix v1.0
Review of attachment 8733930 [details] [diff] [review]:
-----------------------------------------------------------------
::: widget/cocoa/OSXNotificationCenter.mm
@@ +344,5 @@
> }
> nsAutoString name;
> rv = aAlert->GetName(name);
> + // Don't let an alert name be more than 10,000 characters. More than that shouldn't be necessary
> + // and userInfo (assigned to below) has a length limit of 16k. Exception thrown if limit exceded.
nit: s/exceded/exceeded/
Attachment #8733930 -
Flags: review?(spohl.mozilla.bugs) → review+
Fixes comment typo, makes literal a named macro, reduces max len from 10k to 5k chars.
Attachment #8733930 -
Attachment is obsolete: true
Attachment #8734170 -
Flags: review?(spohl.mozilla.bugs)
Comment 9•9 years ago
|
||
Comment on attachment 8734170 [details] [diff] [review]
fix v1.1
Review of attachment 8734170 [details] [diff] [review]:
-----------------------------------------------------------------
::: widget/cocoa/OSXNotificationCenter.mm
@@ +345,5 @@
> }
> }
> nsAutoString name;
> rv = aAlert->GetName(name);
> + // Don't let an alert name be more than 10,000 characters. More than that shouldn't be necessary
nit: this comment still refers to 10,000 characters
@@ +346,5 @@
> }
> nsAutoString name;
> rv = aAlert->GetName(name);
> + // Don't let an alert name be more than 10,000 characters. More than that shouldn't be necessary
> + // and userInfo (assigned to below) has a length limit of 16k. Exception thrown if limit exceeded.
nit: both lines of this comment exceed 80 characters
Attachment #8734170 -
Flags: review?(spohl.mozilla.bugs) → review+
Assignee | ||
Comment 10•9 years ago
|
||
Nits fixed, ready for checkin.
Comment 11•9 years ago
|
||
Comment on attachment 8734212 [details] [diff] [review]
fix v1.2
Thank you!
Attachment #8734212 -
Flags: review+
Updated•9 years ago
|
Attachment #8734170 -
Attachment is obsolete: true
Updated•9 years ago
|
Keywords: checkin-needed
Reporter | ||
Comment 12•9 years ago
|
||
Per bug 1017685, a lower limit is needed for older versions of OS X. Sorry for missing this connection earlier.
There should be a comment explaining why it's safe to check for 5000 sixteen-bit code units (not "characters"!) instead of 10000 eight-bit units.
I'd really like to understand why this can result in "ASSERTION: This is unsafe! Fix the caller!", despite the @catch being in OSXNotificationCenter::ShowAlertWithIconData. Were you ever able to reproduce that? Btw, that assertion only happened for me when reloading the testcase, while the ObjC exception itself only required loading it once.
Keywords: checkin-needed
Assignee | ||
Comment 13•9 years ago
|
||
I tested with unpatched opt and debug builds.
In the opt build I see the assertion print to the console, but that's all I see even after reloading the test case a few times. Firefox continues to work fine.
In the debug build Firefox hangs up permanently when I load the test case. The assertion prints to the console, followed by information about trying to capture a stack trace.
I've never sees anything like "ASSERTION: This is unsafe! Fix the caller!".
As far as I can tell there is something wrong with our attempt to capture a stack trace in debug builds but the rest is fixed by the patch here.
Comment 14•9 years ago
|
||
What should the security rating for this bug be? Is there an actual security issue here?
Comment 15•9 years ago
|
||
In bug 1258945, Jesse reports that this exception crashes and puts the stack pointer in a random location. Seems at least sec-high to me.
It's unclear whether the giant string in this bug is the overflow condition that causes bug 1258945 or if there's something else at play here.
Assignee | ||
Comment 16•9 years ago
|
||
We need to know if Jesse is just seeing the crash in debug builds due to the attempt to get a stack trace, or if he can reproduce the issue in an opt build. If he can't reproduce in an opt build (I can't) then there is probably no security issue here. My hunch is that the problems he's seeing come from the attempt to get a stack trace in debug builds.
Comment 17•9 years ago
|
||
Jesse, per comment 16, can you reproduce this in an opt build?
Flags: needinfo?(jruderman)
Reporter | ||
Comment 18•9 years ago
|
||
For this testcase, I'm now seeing:
* Debug: shows ObjC exception, hangs with low CPU (instead of crashing)
* ASan: shows ObjC exception, shows the desktop notification, continues fine
For the testcase in bug 1258945, I'm now seeing:
* Debug: shows ObjC exception, "Assertion failure: activation->isInterpreter()"
* ASan: shows ObjC exception, crashes [@ js::SavedStacks::insertFrames]
So yes, I can reproduce "ObjC exception seems to lead to bad things happening" in non-debug builds.
Flags: needinfo?(jruderman)
Reporter | ||
Comment 19•9 years ago
|
||
Ordinary opt build crashes [@ js::gc::GCRuntime::updateMallocCounter]
https://archive.mozilla.org/pub/firefox/tinderbox-builds/mozilla-central-macosx64/1461837738/
Updated•9 years ago
|
Group: dom-core-security → layout-core-security
Comment 20•9 years ago
|
||
Please request sec-approval to land the patch.
Let's handle the general Obj-C exception catching issue in bug 1258945.
Flags: needinfo?(jaas)
Comment 21•8 years ago
|
||
Stephen, can you take care of requesting sec-approval and landing the patch please?
Flags: needinfo?(spohl.mozilla.bugs)
Comment 22•8 years ago
|
||
I don't currently have permission to access bug 1258945 and there seems to be quite a bit of overlap between the two. Also, just like Josh (comment 16), I can't reproduce the issue that Jesse mentions in comment 18 and comment 19. I don't feel very comfortable requesting sec-approval under these circumstances. Do you want me to proceed anyway?
Flags: needinfo?(spohl.mozilla.bugs) → needinfo?(mats)
Comment 23•8 years ago
|
||
> I don't currently have permission to access bug 1258945
Sorry, didn't realize that. I've CC:ed you there.
>Do you want me to proceed anyway?
Yes, please. As the reviewer you know more about this code than I do so you can
probably give better answers to sec-approval questions than me.
Flags: needinfo?(mats)
Comment 24•8 years ago
|
||
Comment on attachment 8734212 [details] [diff] [review]
fix v1.2
[Security approval request comment]
How easily could an exploit be constructed based on the patch?
Unknown
Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?
Yes, we added a comment that makes it very clear why we've added a limitation on the string lengths for OSX notifications.
Which older supported branches are affected by this flaw?
This issue affects central, aurora, beta, release and esr45.
If not all supported branches, which bug introduced the flaw?
Native OSX notifications were introduced in bug 852648.
Do you have backports for the affected branches? If not, how different, hard to create, and risky will they be?
The patch applies successfully on central, aurora, beta and release. I've created a separate patch for esr45 in case it is desired.
How likely is this patch to cause regressions; how much testing does it need?
Unlikely to cause regressions and only straightforward testing required since it is minimally invasive.
Attachment #8734212 -
Flags: sec-approval?
Comment 25•8 years ago
|
||
Comment 26•8 years ago
|
||
This is too late to go into 47, which means we need to delay checkin until two weeks into the next cycle. So I'm giving sec-approval but only for checkin on June 21 or later.
status-firefox47:
--- → wontfix
status-firefox49:
--- → affected
status-firefox-esr45:
--- → affected
Whiteboard: [checkin on 6/21]
Updated•8 years ago
|
Attachment #8734212 -
Flags: sec-approval? → sec-approval+
Comment 27•8 years ago
|
||
We'll want branch patches made and nominated once this is on trunk as well.
status-firefox50:
--- → affected
tracking-firefox48:
--- → +
tracking-firefox49:
--- → +
tracking-firefox50:
--- → +
tracking-firefox-esr45:
--- → 48+
Comment 28•8 years ago
|
||
Stephen, please land the patch.
Flags: needinfo?(jaas) → needinfo?(spohl.mozilla.bugs)
Updated•8 years ago
|
Flags: needinfo?(spohl.mozilla.bugs)
Keywords: checkin-needed
Comment 29•8 years ago
|
||
Keywords: checkin-needed
Whiteboard: [checkin on 6/21]
Updated•8 years ago
|
Flags: in-testsuite?
Comment 30•8 years ago
|
||
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
Updated•8 years ago
|
Group: layout-core-security → core-security-release
Hello Josh, could you please nominate patches for uplift to Beta, Aurora and ESR45? Thanks!
Flags: needinfo?(jaas)
Comment 32•8 years ago
|
||
Comment on attachment 8734212 [details] [diff] [review]
fix v1.2
Approval Request Comment
[Feature/regressing bug #]: Native OSX notifications were introduced in bug 852648.
[User impact if declined]: Security issue
[Describe test coverage new/current, TreeHerder]: local testing
[Risks and why]: Unlikely to cause regressions and only straightforward testing required since it is minimally invasive.
[String/UUID change made/needed]: none
Flags: needinfo?(jaas)
Attachment #8734212 -
Flags: approval-mozilla-beta?
Attachment #8734212 -
Flags: approval-mozilla-aurora?
Comment 33•8 years ago
|
||
Comment on attachment 8757142 [details] [diff] [review]
Patch for ESR45
Approval Request Comment
[Feature/regressing bug #]: Native OSX notifications were introduced in bug 852648.
[User impact if declined]: Security issue
[Describe test coverage new/current, TreeHerder]: local testing
[Risks and why]: Unlikely to cause regressions and only straightforward testing required since it is minimally invasive.
[String/UUID change made/needed]: none
Attachment #8757142 -
Flags: approval-mozilla-esr45?
Comment on attachment 8734212 [details] [diff] [review]
fix v1.2
Sec-high issue, Aurora49+, Beta48+
Attachment #8734212 -
Flags: approval-mozilla-beta?
Attachment #8734212 -
Flags: approval-mozilla-beta+
Attachment #8734212 -
Flags: approval-mozilla-aurora?
Attachment #8734212 -
Flags: approval-mozilla-aurora+
Comment on attachment 8757142 [details] [diff] [review]
Patch for ESR45
Sec-high issues meet the ESR45 uplift bar.
Attachment #8757142 -
Flags: approval-mozilla-esr45? → approval-mozilla-esr45+
Comment 36•8 years ago
|
||
Comment 37•8 years ago
|
||
Comment 38•8 years ago
|
||
Updated•8 years ago
|
Whiteboard: [post-critsmash-triage]
Updated•8 years ago
|
Whiteboard: [post-critsmash-triage] → [post-critsmash-triage][adv-main48+][adv-esr45.3+]
Updated•8 years ago
|
Group: core-security-release
You need to log in
before you can comment on or make changes to this bug.
Description
•