Closed
Bug 894370
(CVE-2013-1739)
Opened 12 years ago
Closed 12 years ago
Assertion failure: inputLen >= spec->mac_size, at c:/work/mozilla/builds/beta/mozilla/security/nss/lib/ssl/ssl3con.c:2057
Categories
(NSS :: Libraries, defect, P1)
Tracking
(firefox24 wontfix, firefox25+ fixed, firefox26 fixed, firefox27 fixed, firefox-esr1725+ fixed, firefox-esr2425+ fixed, b2g1825+ fixed, b2g-v1.1hd fixed, b2g-v1.2 fixed)
People
(Reporter: cbook, Assigned: agl)
References
Details
(Keywords: assertion, regression, sec-moderate, Whiteboard: [adv-main25+][adv-esr24-1+][adv-esr1710+])
Attachments
(2 files, 1 obsolete file)
5.65 KB,
text/plain
|
Details | |
3.08 KB,
patch
|
wtc
:
review+
wtc
:
checked-in+
|
Details | Diff | Splinter Review |
Happens in beta and nightly debug builds on all platforms according to bughunter
Assertion failure: inputLen >= spec->mac_size, at c:/work/mozilla/builds/beta/mozilla/security/nss/lib/ssl/ssl3con.c:2057
Will try to generate a testcase
Steps to repoduce is to load https://sc.lcsd.gov.hk/uniS/webcat.hkpl.gov.hk/lib/item;jsessionid=1414DB917107CA0666E4352692442460?id=chamo:3207909&theme=WEB&copies-sort=3%2Basc in a debug build and nearly crash on load
Reporter | ||
Updated•12 years ago
|
Product: Firefox → Core
Reporter | ||
Comment 1•12 years ago
|
||
note, there seems to be a problem with this site. While trying to use wget to create the testcase i got:
Connecting to sc.lcsd.gov.hk (sc.lcsd.gov.hk)|202.53.141.71|:443... connected.
GnuTLS: Key usage violation in certificate has been detected.
Unable to establish SSL connection.
Updated•12 years ago
|
Assignee: nobody → nobody
Component: Security → Libraries
Product: Core → NSS
Version: unspecified → 3.15.1
Updated•12 years ago
|
Version: 3.15.1 → 3.15
Comment 2•12 years ago
|
||
Seems to refer to:
ssl3_ComputeRecordMACConstantTime(
...
PORT_Assert(inputLen >= spec->mac_size);
I cannnot reproduce the assertion using a debug build of tstclnt and settings that are probably close to what firefox beta with NSS 3.15 uses:
tstclnt -d . -p 443 -h sc.lcsd.gov.hk -o -T -v -V ssl3:tls1.1 -f -O < req.txt
cat req.txt:
GET / HTTP/1.1
Host: sc.lcsd.gov.hk
Comment 3•12 years ago
|
||
(In reply to Carsten Book [:Tomcat] from comment #1)
> note, there seems to be a problem with this site. While trying to use wget
> to create the testcase i got:
>
> Connecting to sc.lcsd.gov.hk (sc.lcsd.gov.hk)|202.53.141.71|:443...
> connected.
> GnuTLS: Key usage violation in certificate has been detected.
> Unable to establish SSL connection.
Works for me, wget reports a 404, on Fedora 19 and also another distribution.
Your wget uses GnuTLS. Which Linux distribution do you use?
Reporter | ||
Comment 4•12 years ago
|
||
(In reply to Kai Engert (:kaie) from comment #3)
> Works for me, wget reports a 404, on Fedora 19 and also another distribution.
>
> Your wget uses GnuTLS. Which Linux distribution do you use?
This was with the Version from cygwin
Assignee | ||
Comment 5•12 years ago
|
||
I cannot reproduce the crash from the given URL, but I can see the bug from the code because it's my fault.
The code checks the size of the input, but it assumes that decryption doesn't alter the size of the data. This is incorrect for case of a block cipher in NSS - the decryption may result in zero bytes of output if the input isn't a multiple of the block size.
The issue is around this line:
/* decrypt from cText buf to plaintext. */
rv = crSpec->decode(
»·······crSpec->decodeContext, plaintext->buf, (int *)&plaintext->len,
»·······plaintext->space, cText->buf->buf + ivLen, cText->buf->len - ivLen);
plaintext->len can end up zero.
However, I cannot see a way to exploit this (although others are better at that sort of thing than I). Both ssl_RemoveSSLv3CBCPadding and ssl_RemoveTLSCBCPadding will reject the length immediately so the good flag will be cleared.
The danger lies in ssl3_ComputeRecordMACConstantTime and ssl_CBCExtractMAC. Dealing with the latter first, because it's shorter, the main loop will exit immediately because originalLength is zero and |i < originalLength| will be false.
In ssl_ComputeRecordMACConstantTime, |inputLen| and |originalLen| will be zero (triggering the assertion in debug mode). |recordLength| will underflow, but it's only used to update a couple of bytes |header| and it doesn't matter that they'll be nonsense.
There there are two paths: ssl_ComputeRecordMAC in the fallback case (when NSS and libssl have version skew) and the constant time MAC. For the former, it gets a negative length and passes that to PK11_DigestOp and the like. This will either do nothing, or will try to hash all of memory and crash.
For the constant time code we have to go to lib/freebl/hmacct.c. Here, maxMACBytes will underflow but the calculation in numBlocks will push it positive again. It'll hash a little uninitialised data, but it doesn't go crazy.
Back in ssl3_HandleRecord, plaintext->len will be updated and will underflow, which is very dangerous, but the good flag must be false and so the function will send a fatal alert and return.
To test I updated a server to trigger this problem and commented the assertions to see what happened with a debug build of Chrome and it resulted in a connection error without crashing.
To address that I think the decryption failure should be handled synchronously. The code is security-sensitive-constant-time but the length of the ciphertext is public information and so it's ok to have different behaviour based on that. Additionally, some decryptions may not set the output length at all if they return an error.
I'll upload a patch to that effect in a sec.
Assignee | ||
Comment 6•12 years ago
|
||
Patch. Not yet tested at all so no r? flags.
Comment 7•12 years ago
|
||
I'm marking this sec-moderate because from comment 5 this doesn't sound bad. Feel free to adjust up or down as desired.
Keywords: sec-moderate
Assignee | ||
Comment 8•12 years ago
|
||
This is the patch that I ended up committing to Chromium for this issue.
Attachment #778609 -
Attachment is obsolete: true
Attachment #785022 -
Flags: review?(wtc)
Comment 9•12 years ago
|
||
Comment on attachment 785022 [details] [diff] [review]
patch
r=wtc. Patch checked in on the NSS trunk:
https://hg.mozilla.org/projects/nss/rev/56436aa3463f
Attachment #785022 -
Flags: review?(wtc)
Attachment #785022 -
Flags: review+
Attachment #785022 -
Flags: checked-in+
Comment 10•12 years ago
|
||
Marked the bug fixed.
The code in question was added in NSS 3.14.3 to fix bug 822365.
Assignee: nobody → agl
Status: NEW → RESOLVED
Closed: 12 years ago
OS: Mac OS X → All
Priority: -- → P1
Hardware: x86 → All
Resolution: --- → FIXED
Target Milestone: --- → 3.15.2
Version: 3.15 → 3.14.3
Comment 11•11 years ago
|
||
This appears fixed in Firefox nightly and aurora (Firefox 26, 27), but not beta or release (Firefox 24, 25).
status-firefox24:
--- → affected
status-firefox25:
--- → affected
status-firefox26:
--- → fixed
status-firefox27:
--- → fixed
Updated•11 years ago
|
Blocks: CVE-2013-1620
Keywords: regression
Updated•11 years ago
|
status-firefox-esr17:
--- → affected
Comment 13•11 years ago
|
||
We should fix this in Firefox 25 and the corresponding Firefox ESR-24 by upgrading from NSS 3.15.1 to 3.15.2
It is not severe enough to be worth upgrading the last ESR 17 release from NSS 3.14.3
status-b2g18:
--- → affected
status-firefox-esr24:
--- → affected
tracking-firefox25:
--- → +
tracking-firefox-esr17:
--- → ?
tracking-firefox-esr24:
--- → 25+
Comment 14•11 years ago
|
||
Adding Elio for picking up the patch.
Comment 15•11 years ago
|
||
NSS for mozilla-beta was updated to 3.15.2 in https://hg.mozilla.org/releases/mozilla-beta/rev/ee766b7c606e (bug 921090).
Comment 16•11 years ago
|
||
(In reply to Daniel Veditz [:dveditz] from comment #13)
> It is not severe enough to be worth upgrading the last ESR 17 release from
> NSS 3.14.3
Same for b2g18?
Comment 17•11 years ago
|
||
Who is doing the ESR24 patch for this since it is tracking+ for the next ESR24 release in the next two weeks?
Updated•11 years ago
|
Whiteboard: [adv-main25+]
Comment 18•11 years ago
|
||
Al, this bug has been fixed in NSS 3.15.2
It seems the ESR24 branch has already been updated to use NSS 3.15.2 in the meantime:
http://hg.mozilla.org/releases/mozilla-esr24/file/default/security/nss/TAG-INFO
Comment 19•11 years ago
|
||
Changing flags to mark ESR24 as fixed.
Whiteboard: [adv-main25+] → [adv-main25+][adv-esr24-1+]
Comment 20•11 years ago
|
||
NSS 3.14.4 was created for ESR 17 so this is fixed there now, too.
Updated•11 years ago
|
Whiteboard: [adv-main25+][adv-esr24-1+] → [adv-main25+][adv-esr24-1+][adv-esr1710+]
Updated•11 years ago
|
tracking-b2g18:
--- → 25+
Updated•11 years ago
|
Updated•10 years ago
|
Group: core-security
You need to log in
before you can comment on or make changes to this bug.
Description
•