Softoken CBC padding removal might have a timing side channel
Categories
(NSS :: Libraries, defect, P2)
Tracking
(Not tracked)
People
(Reporter: mt, Assigned: deian)
References
Details
(Keywords: csectype-side-channel, sec-moderate)
Attachments
(3 files, 4 obsolete files)
Updated•7 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Assignee | ||
Comment 1•5 years ago
|
||
Seems like NSC_Decrypt
(non Final) has the same issue here:
if (padding > context->blockSize || !padding) { // <-- treated as public
crv = CKR_ENCRYPTED_DATA_INVALID;
} else {
unsigned int i;
unsigned int badPadding = 0; /* used as a boolean */
for (i = 0; i < padding; i++) { // <-- treated as public
badPadding |= (unsigned int)pData[outlen - 1 - i] ^ padding; // <-- treated as if secret
}
Assignee | ||
Comment 2•5 years ago
|
||
Updated•5 years ago
|
Comment 3•5 years ago
|
||
Assignee | ||
Comment 4•5 years ago
|
||
That was lingering code for testing the parts of the function as I was porting it to CT. Should not have been there, sorry.
Comment 5•5 years ago
•
|
||
Assignee | ||
Comment 6•5 years ago
|
||
clang-format, carrying r+
Comment 7•5 years ago
|
||
Try push failed on Windows, cannot land. (https://treeherder.mozilla.org/#/jobs?repo=nss-try&revision=08aee908a2c4)
c:/Users/task_1570825892/nss/lib/softoken/pkcs11c.c(1623): warning C4146: unary minus operator applied to unsigned type, result still unsigned
Furthermore, I have a review comment, sorry that I didn't review this sooner than now:
As changed, the NSC_DecryptFinal
function modifies pulLastPartLen
even on crv
being a failure, which we generally try to avoid. Due to different construction NSC_Decrypt
still appears to behave that way. We shouldn't regress that behavior for NSC_DecryptFinal
Comment 8•5 years ago
|
||
I've already tagged NSS_3_47_BETA1
but I will be happy to take this for NSS_3_47_BETA2
.
Assignee | ||
Comment 9•5 years ago
|
||
-
Since we just want
CT_NOT_ZERO(X)
to give us all-zeros for 0 and all-ones otherwise, I just replaced-(x)
with(0-x)
in the macro. Not sure if there is a different convention elsewhere in the codebase to follow though. -
Fixed
NSC_DecryptFinal
; copied a helper function from ssl3con.c. May be nice to share some of these helper functions/macros.
Assignee | ||
Comment 10•5 years ago
|
||
Due to different construction NSC_Decrypt still appears to behave that way.
With refactoring of the padding code out it's pretty easy to fix this too. Should we just do it in this patch?
Comment 11•5 years ago
|
||
I don't feel strongly either way on expanding this patch. Kevin?
Comment 12•5 years ago
|
||
Comment 13•5 years ago
|
||
Comment 15•5 years ago
|
||
Comment 16•5 years ago
|
||
This breaks u2f soft tokens in Firefox.
Comment 17•5 years ago
|
||
I'm shortly going to back this back out for a BETA3 to keep our uplift train moving. We can make a BETA4 as necessary.
Comment 18•5 years ago
|
||
Assignee | ||
Comment 19•5 years ago
|
||
u2f tests passes and all nss tests pass
Comment 20•5 years ago
|
||
Assignee | ||
Comment 21•5 years ago
|
||
Assignee | ||
Comment 22•5 years ago
|
||
This patch adds more test vectors for AES-CBC and 2DES-CBC padding.
Comment 23•5 years ago
|
||
Updated•5 years ago
|
Comment 24•5 years ago
|
||
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•2 years ago
|
Description
•