Closed
Bug 820410
Opened 12 years ago
Closed 12 years ago
Audit/Clean up buffer handling in nICEr STUN code
Categories
(Core :: WebRTC: Networking, defect)
Core
WebRTC: Networking
Tracking
()
RESOLVED
FIXED
mozilla20
Tracking | Status | |
---|---|---|
firefox17 | --- | unaffected |
firefox18 | - | disabled |
firefox19 | - | disabled |
firefox20 | + | fixed |
firefox-esr10 | --- | unaffected |
firefox-esr17 | --- | unaffected |
People
(Reporter: abr, Assigned: abr)
Details
(Keywords: sec-audit, Whiteboard: [WebRTC][nICEr][blocking-webrtc+][qa-][adv-main20-])
Attachments
(1 file, 1 obsolete file)
9.94 KB,
patch
|
jesup
:
review+
abillings
:
sec-approval+
jesup
:
checkin+
|
Details | Diff | Splinter Review |
The nICEr STUN implementation has been identified as having potentially safe buffer handling. It should, in general, be audited for common errors such as potential buffer overflows and string null-termination hygiene.
Assignee | ||
Comment 1•12 years ago
|
||
s/potentially safe/potentially unsafe/
Assignee | ||
Comment 2•12 years ago
|
||
Assignee | ||
Updated•12 years ago
|
Assignee: nobody → adam
Assignee | ||
Updated•12 years ago
|
Attachment #691144 -
Flags: review?(ekr)
Assignee | ||
Updated•12 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Updated•12 years ago
|
Attachment #691144 -
Flags: review?(ekr) → review?(rjesup)
Assignee | ||
Updated•12 years ago
|
Whiteboard: [WebRTC][nICEr]
Updated•12 years ago
|
Whiteboard: [WebRTC][nICEr] → [WebRTC][nICEr][blocking-webrtc+]
Comment 3•12 years ago
|
||
Comment on attachment 691144 [details] [diff] [review]
Buffer handling safety checks
Review of attachment 691144 [details] [diff] [review]:
-----------------------------------------------------------------
r- for the snprintf() thing and the strlcpy args
::: media/mtransport/third_party/nICEr/src/ice/ice_candidate.c
@@ +221,5 @@
> goto next;
> if(cand->stun_server != foundation->stun_server)
> goto next;
>
> + snprintf(fnd,sizeof(fnd),"%d",i);
snprintf doesn't guarantee null-termination. Need to use an alternative that does (see signaling and other places, PR_snprintf, etc), or insert a null at the end of the buffer as a backstop, or be certain the string can't be as large as the buffer (which makes strnxxx irrelevant basically), but may need an assertion or kickout.
@@ +238,5 @@
> foundation->type=cand->type;
> foundation->stun_server=cand->stun_server;
> STAILQ_INSERT_TAIL(&ctx->foundations,foundation,entry);
>
> + snprintf(fnd,sizeof(fnd),"%d",i);
ditto
::: media/mtransport/third_party/nICEr/src/stun/addrs.c
@@ +151,5 @@
> struct rt_addrinfo info;
> struct sockaddr_in *sin;
>
> ifr.ifr_addr.sa_family = AF_INET;
> + strlcpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
()'s on sizeof
@@ +300,5 @@
> #ifdef _UNICODE
> mbstowcs_s(&converted_chars, adapter_GUID_tchar, strlen(adapter_GUID)+1,
> adapter_GUID, _TRUNCATE);
> #else
> + strlcpy(adapter_GUID_tchar, _NR_MAX_NAME_LENGTH, adapter_GUID);
This was wrong before, and still is - length comes last
::: media/mtransport/third_party/nICEr/src/stun/stun_server_ctx.c
@@ +391,5 @@
> }
>
> STAILQ_FOREACH(clnt, &ctx->clients, entry) {
> + if (!strncmp(clnt->username, attr->u.username,
> + sizeof(attr->u.username)))
I assume u.username is null-terminated, so it will kick out there even if clnt->username is much longer, so this isn't *strictly) needed, but it's not a problem.
::: media/mtransport/third_party/nICEr/src/stun/turn_client_ctx.c
@@ +115,5 @@
> ++(ctx->phase);
> + if (ctx->phase > NUMBER_OF_STUN_CTX) {
> + ABORT(R_INTERNAL);
> + }
> +
trailing spaces
Attachment #691144 -
Flags: review?(rjesup) → review-
Assignee | ||
Comment 4•12 years ago
|
||
Assignee | ||
Updated•12 years ago
|
Attachment #691144 -
Attachment is obsolete: true
Assignee | ||
Comment 5•12 years ago
|
||
New patch fixes parameter ordering issue for windows, cosmetic flaws.
Summary of IRC conversation with jesup: Windows does not provide an snprintf function, and the similarly-named Windows function _snprintf does not guarantee null termination. Within the nICEr (ice) code, snprintf for Windows is defined in terms of Microsoft's vsnprintf_s function, which *does* provide null termination. See http://mxr.mozilla.org/mozilla-central/source/media/mtransport/third_party/nrappkit/src/util/util.c#555 for the Windows implementation of snprintf used by the nICEr code.
Assignee | ||
Updated•12 years ago
|
Attachment #691941 -
Flags: review?(rjesup)
Updated•12 years ago
|
Attachment #691941 -
Flags: review?(rjesup) → review+
Assignee | ||
Comment 6•12 years ago
|
||
Comment on attachment 691941 [details] [diff] [review]
Buffer handling safety checks
[Security approval request comment]
> How easily can the security issue be deduced from the patch?
Figuring out how to overflow the particular buffers in question would be a very difficult task. I'm not certain any of these are actually exploitable; for the most part, this patch replaces potentially unsafe constructs with safe variants.
> Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?
No.
> Which older supported branches are affected by this flaw?
FF 18 and 19 contain this code. However, this code is only executed as part of WebRTC handling. WebRTC is preffed off by default in these builds, so exposure in 18 and 19 is very limited.
> If not all supported branches, which bug introduced the flaw?
https://bugzilla.mozilla.org/show_bug.cgi?id=790517
> Do you have backports for the affected branches? If not, how different, hard to create, and risky will they be?
The source file in question does not appear to have been changed since its introduction. The patch should apply cleanly to all branches.
> How likely is this patch to cause regressions; how much testing does it need?
The chance of these changes causing regressions is quite low: the changes consist primarily of replacing potentially unsafe functions with equivalent, but safer, functions.
Attachment #691941 -
Flags: sec-approval?
Updated•12 years ago
|
Attachment #691941 -
Flags: sec-approval? → sec-approval+
Comment 7•12 years ago
|
||
sec-approval+.
Please check this into trunk. Release Management can determine if they really need it for 18 or 19.
status-firefox-esr10:
--- → unaffected
status-firefox18:
--- → disabled
status-firefox19:
--- → disabled
status-firefox20:
--- → affected
status-firefox-esr17:
--- → unaffected
tracking-firefox18:
--- → ?
tracking-firefox19:
--- → ?
tracking-firefox20:
--- → +
Updated•12 years ago
|
status-firefox17:
--- → unaffected
Comment 8•12 years ago
|
||
Given where we are in the cycle, no need to take fixes of this nature for pref'd off features.
Assignee | ||
Updated•12 years ago
|
Attachment #691941 -
Flags: checkin?(rjesup)
Comment 9•12 years ago
|
||
Target Milestone: --- → mozilla20
Updated•12 years ago
|
Attachment #691941 -
Flags: checkin?(rjesup) → checkin+
Comment 10•12 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 11•12 years ago
|
||
Landed on resiprocate trunk r9911: http://svn.resiprocate.org/viewsvn/resiprocate?diff_format=l&view=revision&revision=9911
Updated•12 years ago
|
Whiteboard: [WebRTC][nICEr][blocking-webrtc+] → [WebRTC][nICEr][blocking-webrtc+][qa-]
Updated•12 years ago
|
Whiteboard: [WebRTC][nICEr][blocking-webrtc+][qa-] → [WebRTC][nICEr][blocking-webrtc+][qa-][adv-main20-]
Updated•10 years ago
|
Group: core-security
You need to log in
before you can comment on or make changes to this bug.
Description
•