Closed Bug 964762 Opened 7 years ago Closed 7 years ago

Stack buffer overflow in content/media/webm/EbmlComposer.cpp

Categories

(Core :: Audio/Video, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 966044
Tracking Status
firefox27 --- unaffected
firefox28 --- unaffected
firefox29 --- affected
firefox-esr24 --- unaffected

People

(Reporter: padenot, Assigned: padenot)

References

Details

(Keywords: sec-low)

Attachments

(1 file, 1 obsolete file)

15:07.96 In file included from /usr/include/string.h:638:0,
15:07.96                  from ../../../dist/system_wrappers/string.h:3,
15:07.96                  from ../../../dist/include/nsTArray.h:16,
15:07.96                  from /home/padenot/src/trees/mozilla-inbound/content/media/webm/EbmlComposer.h:8,
15:07.96                  from /home/padenot/src/trees/mozilla-inbound/content/media/webm/EbmlComposer.cpp:6,
15:07.96                  from /home/padenot/src/trees/mozilla-inbound/obj-x86_64-unknown-linux-gnu/content/media/webm/Unified_cpp_content_media_webm0.cpp:2:
15:07.96 In function ‘char* strcpy(char*, const char*)’,
15:07.96     inlined from ‘void mozilla::EbmlComposer::GenerateHeader()’ at /home/padenot/src/trees/mozilla-inbound/content/media/webm/EbmlComposer.cpp:50:43:
15:07.96 /usr/include/x86_64-linux-gnu/bits/string3.h:104:86: error: call to char* __builtin___strcpy_chk(char*, const char*, long unsigned int) will always overflow destination buffer [-Werror]

"A_VORBIS" is 9 char long (because of the \0). Maybe we don't want the '\0' in the container, in which case we can just put a "- 1" on the size.
Attached patch length-fix (obsolete) — Splinter Review
Attachment #8366634 - Flags: review?(giles)
Attached patch possible patchSplinter Review
gahh, forgot to qref.
Attachment #8366634 - Attachment is obsolete: true
Attachment #8366634 - Flags: review?(giles)
Attachment #8366635 - Flags: review?(giles)
Duplicate of this bug: 964761
Comment on attachment 8366635 [details] [diff] [review]
possible patch

Review of attachment 8366635 [details] [diff] [review]:
-----------------------------------------------------------------

Whoops, thanks for the fix.

The spec is unclear whether the codec_id field should have a terminating null or not; it seems to be optional. However the libmkv writer we're using depends on being able to call strlen() on the string we pass in (and then strips it before writing) so we need 9 bytes here.
Attachment #8366635 - Flags: review?(giles) → review+
Comment on attachment 8366635 [details] [diff] [review]
possible patch

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

Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?
The problem is obvious. Merely compiling the code shows the issue if enough warning flags are enabled.

Which older supported branches are affected by this flaw?
Nightly only.

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

Do you have backports for the affected branches? If not, how different, hard to create, and risky will they be?
N/A, nightly only.

How likely is this patch to cause regressions; how much testing does it need?
This is super obvious.
Attachment #8366635 - Flags: sec-approval?
If this is trunk only, it doesn't need sec-approval+ to go in.

That said, it would be good to get a security rating on this.
This has not been re-fixed in public bug 966044, so I think we can grant sec-approval and open this bug.
Can we use static_assert and MOZ_ARRAY_LENGTH to get a compile time assertion that cid_string is big enough?
I looked at that, but it we'd have to promote the strings to constants so we could reference them more than once. That would be fine but I like efaust's fix of just passing string constants directly better, no problematic allocation needed.
As far as rating goes, I think it's sec-low. The overflow is one byte past the last thing allocated on the stack. Assuming the compiler doesn't rearrange any variables that shouldn't corrupt anything, just crash if we overflow the stack.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 966044
Since this is a sec-low, it doesn't need approval (that only applies to higher rated issues, see https://wiki.mozilla.org/Security/Bug_Approval_Process). 

I'll clear the request. I'm glad it is fixed though!
Keywords: sec-low
Attachment #8366635 - Flags: sec-approval?
No longer blocks: 891705
Group: core-security → core-security-release
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.