Closed
Bug 1465186
Opened 8 years ago
Closed 8 years ago
Destruction of uninitialized pointers in sftkdb_DecryptAttribute()
Categories
(NSS :: Libraries, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
3.38
People
(Reporter: mozillabugs, Assigned: franziskus)
Details
(Keywords: csectype-uninitialized, reporter-external, sec-low)
Attachments
(1 external file)
In an error case, sftkdb_DecryptAttribute() (security\nss\lib\softoken\sftkpwd.c) destroys the objects pointed to by two uninitialized pointers.
The bug is that line 229, below, does not initialize |ciphervalue.param| and |ciphervalue.arena|.
If line 232 fails inside sftkdb_decodeCipherText() on line 141-44 (as with an OOM) it also does not initialize |ciphervalue->param| and |ciphervalue->arena|. This causes control to reach lines 244 et seq., with line 246 attempting to destroy the "object" pointed to by |ciphervalue.param| (which devolves to destroying an "arena" somewhere in hyperspace) and line 249 attempting to destroy the "arena" pointed to by |ciphervalue.arena|.
225: SECStatus
226: sftkdb_DecryptAttribute(SECItem *passKey, SECItem *cipherText, SECItem **plain)
227: {
228: SECStatus rv;
229: sftkCipherValue cipherValue;
230:
231: /* First get the cipher type */
232: rv = sftkdb_decodeCipherText(cipherText, &cipherValue);
233: if (rv != SECSuccess) {
234: goto loser;
235: }
...
244: loser:
245: if (cipherValue.param) {
246: nsspkcs5_DestroyPBEParameter(cipherValue.param);
247: }
248: if (cipherValue.arena) {
249: PORT_FreeArena(cipherValue.arena, PR_FALSE);
250: }
251: return rv;
252: }
134: static SECStatus
135: sftkdb_decodeCipherText(SECItem *cipherText, sftkCipherValue *cipherValue)
136: {
137: PLArenaPool *arena = NULL;
138: SFTKDBEncryptedDataInfo edi;
139: SECStatus rv;
140:
141: arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
142: if (arena == NULL) {
143: return SECFailure;
144: }
145: cipherValue->arena = NULL;
146: cipherValue->param = NULL;
...
171: }
I'll attempt a POC.
| Reporter | ||
Updated•8 years ago
|
Flags: needinfo?(mozillabugs)
| Reporter | ||
Comment 1•8 years ago
|
||
There is also a similar bug in sftkdb_VerifyAttribute() in the same module, where |signvalue| is not initialized.
| Reporter | ||
Comment 2•8 years ago
|
||
Here's a POC.
Start FF, ensuring that soft-token support is enabled. Now attach a debugger to it (you might need to attach to several processes if E10S is enabled), and set a BP on line 232. Visit https://ipv.sx/u2f and click "U2F Register".
When the BP fires, step into sftkdb_decodeCipherText() and skip line 141 to simulate an OOM. Step out and to line 246. Observe how |cipherValue| is uninitialized. Step into nsspkcs5_DestroyPBEParameter() and watch it attempt to destroy an "arena" somewhere in hyperspace. I got a read access-violation at address 0x10000002; you'll probably get something different.
Flags: needinfo?(mozillabugs)
Updated•8 years ago
|
Flags: sec-bounty?
Comment 3•8 years ago
|
||
(In reply to mozillabugs from comment #2)
> Here's a POC.
Nit: That's "Steps to Reproduce" (STR) not a POC. Useful, but not the same thing.
Comment 4•8 years ago
|
||
Maybe sec-moderate because there might be ways to make that function fail besides an unlikely-timed OOM.
Keywords: csectype-uninitialized,
sec-moderate
| Reporter | ||
Comment 5•8 years ago
|
||
(In reply to Daniel Veditz [:dveditz] from comment #3)
> (In reply to mozillabugs from comment #2)
> > Here's a POC.
>
> Nit: That's "Steps to Reproduce" (STR) not a POC. Useful, but not the same
> thing.
Nit noted.
| Assignee | ||
Updated•8 years ago
|
Assignee: nobody → franziskuskiefer
Comment 6•8 years ago
|
||
Comment 7•8 years ago
|
||
Comment on attachment 8983336 [details]
Bug 1465186 - null cipherValue pointers
Martin Thomson [:mt:] has approved the revision.
https://phabricator.services.mozilla.com/D1554
Attachment #8983336 -
Flags: review+
| Assignee | ||
Comment 8•8 years ago
|
||
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → 3.38
Updated•8 years ago
|
Group: crypto-core-security → core-security-release
Comment 9•8 years ago
|
||
I don't see any realistic way to force an OOM at exactly this point with useful uninitialized values in the cipherValue param.
Flags: sec-bounty? → sec-bounty-
Keywords: sec-moderate → sec-low
| Reporter | ||
Comment 10•8 years ago
|
||
FWIW, sftkdb_DecryptAttribute() is also called during startup while loading the "NSS Internal PKCS #11 Module". You can use the same procedure as in the second paragraph of https://bugzilla.mozilla.org/show_bug.cgi?id=1465186#c2 to cause FF to use the uninitialized variables.
Updated•7 years ago
|
Group: core-security-release
Updated•2 years ago
|
Keywords: reporter-external
You need to log in
before you can comment on or make changes to this bug.
Description
•