Closed
Bug 790083
Opened 14 years ago
Closed 13 years ago
libsrtp reads past the end of a key buffer when setting up the internal prng (used in testing)
Categories
(Core :: WebRTC: Networking, defect)
Core
WebRTC: Networking
Tracking
()
RESOLVED
FIXED
mozilla19
| Tracking | Status | |
|---|---|---|
| firefox18 | --- | affected |
People
(Reporter: jesup, Assigned: jesup)
References
Details
(Whiteboard: [WebRTC], [blocking-webrtc+] [qa-])
Attachments
(3 files)
|
1.76 KB,
patch
|
ekr
:
review+
derf
:
review+
|
Details | Diff | Splinter Review |
|
1.30 KB,
patch
|
Details | Diff | Splinter Review | |
|
2.14 KB,
patch
|
ekr
:
review+
|
Details | Diff | Splinter Review |
Found via ASAN. Ironically, the code documents that it reads 2 bytes past the end of the buffer.
Also ironically, Google (in their Android version of libsrtp) carries a patch for this exact problem. I have my own, but it may make more sense to take theirs if it has the same characteristics -- and I'm not sure their patch is 100% safe in all cases, though in all current cases it probably is.
We will plan to upstream this (or google's) patch. I'm a libsrtp maintainer, so I can update the master source as well.
| Assignee | ||
Comment 1•14 years ago
|
||
| Assignee | ||
Updated•14 years ago
|
Attachment #659874 -
Flags: review?(ekr)
Updated•14 years ago
|
Whiteboard: [WebRTC]
Updated•14 years ago
|
Whiteboard: [WebRTC] → [WebRTC], [blocking-webrtc+]
| Assignee | ||
Comment 2•14 years ago
|
||
This applies on top of the patches in bug 792325 - direct import of srtp into netwerk
| Assignee | ||
Comment 3•14 years ago
|
||
Note this also 'fixes' a case where passing certain non multiple-of-16-plus-14 sized buffers might cause it to use random stack garbage for a key. Really that's a bad case anyways, this just stops it from doing something unpredictable.
| Assignee | ||
Updated•14 years ago
|
Attachment #659874 -
Flags: review?(tterribe)
Comment 4•14 years ago
|
||
Comment on attachment 659874 [details] [diff] [review]
Patch for past-end-of-key read
Review of attachment 659874 [details] [diff] [review]:
-----------------------------------------------------------------
::: media/webrtc/trunk/third_party/libsrtp/srtp/crypto/cipher/aes_icm.c
@@ +174,4 @@
> else
> return err_status_bad_param;
>
> + /*
Adds trailing whitespace.
@@ +182,5 @@
> + v128_set_to_zero(&c->offset);
> +
> + copy_len = key_len - base_key_len;
> + /* force last two octets of the offset to be left zero (for srtp compatibility) */
> + if (copy_len > 14)
By my reading of the code at the top of this function, key_len may have the values 17...30, 38, or 46, and the corresponding base_key_len has the values 16, 24, or 32, respectively. So key_len - base_key_len is never larger than 14, and this check should be unnecessary.
Harmless to leave it in, of course (unless you wanted to do branch coverage analysis some day). Unfortunately libsrtp doesn't appear to use asserts, or I'd recommend just replacing it with one of those to guard against future changes to the code.
Attachment #659874 -
Flags: review?(tterribe) → review+
| Assignee | ||
Comment 6•13 years ago
|
||
ekr: waiting for a review from you on this...
Comment 7•13 years ago
|
||
Comment on attachment 662570 [details] [diff] [review]
Fix over-read in srtp (m-c direct import version)
Review of attachment 662570 [details] [diff] [review]:
-----------------------------------------------------------------
::: netwerk/srtp/src/crypto/cipher/aes_icm.c
@@ +173,5 @@
> base_key_len = key_len - 14;
> else
> return err_status_bad_param;
>
> + /*
NIt: trailing whitespac.e
Attachment #662570 -
Flags: review+
| Assignee | ||
Comment 8•13 years ago
|
||
Comment 9•13 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/3b1ee99a8e61
Should this have a test?
Status: NEW → RESOLVED
Closed: 13 years ago
Flags: in-testsuite?
Resolution: --- → FIXED
Comment 10•13 years ago
|
||
Without this fix, any execution of libsrtp under ASAN fails. Is that enough?
| Assignee | ||
Comment 11•13 years ago
|
||
We can't easily test ASAN issues in non-ASAN builds. As this was an already-known safe read-past (with no security impact) unless the allocation happened to be at the end of a page followed by an unmapped page, there's really nothing to test.
Flags: in-testsuite? → in-testsuite-
Updated•13 years ago
|
status-firefox19:
affected → ---
Updated•13 years ago
|
Whiteboard: [WebRTC], [blocking-webrtc+] → [WebRTC], [blocking-webrtc+] [qa-]
Comment 12•13 years ago
|
||
Comment on attachment 659874 [details] [diff] [review]
Patch for past-end-of-key read
Review of attachment 659874 [details] [diff] [review]:
-----------------------------------------------------------------
Cleaning up unfinished reviews
Attachment #659874 -
Flags: review?(ekr) → review+
| Assignee | ||
Comment 13•13 years ago
|
||
FYI, this patch has been upstreamed on the new github master for libsrtp (it's Issue 7 there)
You need to log in
before you can comment on or make changes to this bug.
Description
•