Last Comment Bug 646460 - Don't allow to override after treating certificates as revoked
: Don't allow to override after treating certificates as revoked
Status: RESOLVED FIXED
[qa-examined-192] [qa-needs-STR]
:
Product: Core
Classification: Components
Component: Security: PSM (show other bugs)
: Trunk
: All All
: -- normal (vote)
: ---
Assigned To: Kai Engert (:kaie)
:
: David Keeler [:keeler] (use needinfo?)
Mentors:
Depends on:
Blocks: 642395 642815
  Show dependency treegraph
 
Reported: 2011-03-30 07:14 PDT by Kai Engert (:kaie)
Modified: 2011-06-10 05:02 PDT (History)
16 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---
-
fixed
-
wanted
.18+
.18-fixed
.20+
.20-fixed


Attachments
Patch v1 (783 bytes, patch)
2011-03-30 07:20 PDT, Kai Engert (:kaie)
no flags Details | Diff | Splinter Review
Patch v1 with comment fixed (783 bytes, patch)
2011-04-11 13:36 PDT, Kai Engert (:kaie)
no flags Details | Diff | Splinter Review
Patch v1 with comment fixed (for real this time) (756 bytes, patch)
2011-04-11 13:41 PDT, Kai Engert (:kaie)
no flags Details | Diff | Splinter Review
Patch v3 - more and better comments (938 bytes, patch)
2011-04-20 12:13 PDT, Kai Engert (:kaie)
brian: review+
sayrer: approval‑mozilla‑aurora+
dveditz: approval2.0+
dveditz: approval1.9.2.18+
dveditz: approval1.9.1.20+
Details | Diff | Splinter Review

Description Kai Engert (:kaie) 2011-03-30 07:14:18 PDT
Bug 642395 added code which decides the application level (PSM) that a cert is revoked.

The NSS SSL code does not expect this error code, and decides to call into the application again, asking how to handle the error.

PSM's bad cert handler checks for the errors returned by NSS, which says "not trusted", and concludes, we should allow to override.


The fix is:
In the beginning of the bad-cert-handler, check whether the error status is "revoked". If it is, avoid any override handling, but exit the bad-cert-handler immediately.


This was found when using code from bug 642815, which blacklists certs at the NSS level.
Comment 1 Kai Engert (:kaie) 2011-03-30 07:20:34 PDT
Created attachment 523002 [details] [diff] [review]
Patch v1

Brian, we had previously attempted to fix a similar issue in bug 642395 comment 36 to 40.

Here is a fix that should work with both scenarios.

Calling cancel_and_failure is not necessary, and would be wrong, because it suppresses error reporting.
Comment 2 Brian Smith (:briansmith, :bsmith, use NEEDINFO?) 2011-03-30 11:29:09 PDT
(In reply to comment #1)
> Calling cancel_and_failure is not necessary, and would be wrong,
> [for errors other than the ones explicitly handled below,] 
> because it suppresses error reporting.

Please add this comment to top of the function so that we don't make the mistake we made in https://bugzilla.mozilla.org/attachment.cgi?id=520017&action=diff again. r+
Comment 3 Daniel Veditz [:dveditz] 2011-03-30 16:51:48 PDT
I wonder if we should store a list of certs/fingerprints we've found which have been positively revoked. The user visited that site once and might try again, and next time might be on a network where revocation checking is blocked. Is there ever a legitimate case where a cert is revoked and then un-revoked? Maybe a revocation by accident? Even then it may be better to issue a replacement cert.

I suppose this is completely off-topic for this bug. When I first read the summary this is what I thought you were talking about.
Comment 4 Brian Smith (:briansmith, :bsmith, use NEEDINFO?) 2011-03-30 17:09:49 PDT
(In reply to comment #3)
> I wonder if we should store a list of certs/fingerprints we've found
> which have been positively revoked. ... I suppose this is completely
> off-topic for this bug. When I first read the summary this is what
> I thought you were talking about.

That's not what this bug report is about, but it is a good idea. I have incorporated it into my notes regarding the proposed improvements to revocation checking.
Comment 5 Robert Relyea 2011-03-30 18:29:53 PDT
Dan,

There are 2 types of 'revocation' statuses:

Revoked.
On Hold.

The latter can be turned off (it's used in cases where someone has lost their token and then latter safely recovered it). 

On Hold is usually marked in an extension (the normal status is revoked for both). NSS currently does not parse that extension. The use of on hold is exceedingly rare in all but the token scenario.

bob
Comment 6 Wan-Teh Chang 2011-04-08 12:39:13 PDT
Comment on attachment 523002 [details] [diff] [review]
Patch v1

> static SECStatus
> nsNSSBadCertHandler(void *arg, PRFileDesc *sslSocket)
> {
>+  // if other code decided that cert was revoked, don't do anything else
>+  if (PR_GetError() == SEC_ERROR_REVOKED_CERTIFICATE)
>+    return SECFailure;

Nit: replace "other code" by "AuthCertificateCallback".
I would simply remove "other code decided that".

You should also remove SEC_ERROR_UNTRUSTED_ISSUER from
the switch statement in nsNSSBadCertHandler:
http://mxr.mozilla.org/mozilla-central/source/security/manager/ssl/src/nsNSSIOLayer.cpp?mark=3429#3425
Comment 7 Kai Engert (:kaie) 2011-04-11 13:34:24 PDT
> Nit: replace "other code" by "AuthCertificateCallback".
> I would simply remove "other code decided that".

Ok.


> You should also remove SEC_ERROR_UNTRUSTED_ISSUER from
> the switch statement in nsNSSBadCertHandler:
> http://mxr.mozilla.org/mozilla-central/source/security/manager/ssl/src/nsNSSIOLayer.cpp?mark=3429#3425


You are proposing a semantic change, but in my opinion this semantic changes is not apprproiate for stable branches.

Given that I would like this fix on the stable branch, I would like to discuss this potential change elsewhere.
Comment 8 Kai Engert (:kaie) 2011-04-11 13:35:43 PDT
> 
> > You should also remove SEC_ERROR_UNTRUSTED_ISSUER from
> > the switch statement in nsNSSBadCertHandler:
> > http://mxr.mozilla.org/mozilla-central/source/security/manager/ssl/src/nsNSSIOLayer.cpp?mark=3429#3425
> 
> 
> You are proposing a semantic change, but in my opinion this semantic changes is
> not apprproiate for stable branches.
> 
> Given that I would like this fix on the stable branch, I would like to discuss
> this potential change elsewhere.


And I'm not convinced this is the right change, because a comment in NSS claims, error code SEC_ERROR_UNTRUSTED_ISSUER can be seen with self signed certs, and we do want to allow people to override that.
Comment 9 Kai Engert (:kaie) 2011-04-11 13:36:56 PDT
Created attachment 525152 [details] [diff] [review]
Patch v1 with comment fixed
Comment 10 Kai Engert (:kaie) 2011-04-11 13:39:45 PDT
It would be great if we could get this r+ and approved today,
in order to be in time for 3.6.17,
because Fedora would like to ship an updated NSS that blacklists the roots for all applications,
but Firefox needs this patch to make sure users won't be able to override.
Thanks!
Comment 11 Kai Engert (:kaie) 2011-04-11 13:41:02 PDT
Created attachment 525154 [details] [diff] [review]
Patch v1 with comment fixed (for real this time)
Comment 12 Kai Engert (:kaie) 2011-04-14 20:33:26 PDT
Brian, I think you might have confused SEC_ERROR_UNTRUSTED_CERT with SEC_ERROR_UNTRUSTED_ISSUER.

I'm OK to remove SEC_ERROR_UNTRUSTED_CERT from mozilla-central, but I propose to do that in another bug, as this patch here should land into 4.0.x
Comment 13 Daniel Veditz [:dveditz] 2011-04-20 10:34:54 PDT
Comment on attachment 525154 [details] [diff] [review]
Patch v1 with comment fixed (for real this time)

Waiting for review before looking at approval requests
Comment 14 Brian Smith (:briansmith, :bsmith, use NEEDINFO?) 2011-04-20 10:57:47 PDT
My understanding (from email with Kai) is that Kai will upload another patch with the comment fixed "really for real". (see comment 2) ;)
Comment 15 Asa Dotzler [:asa] 2011-04-20 11:51:30 PDT
Dan, can you tell us what this gets us and what the risks are?
Comment 16 Kai Engert (:kaie) 2011-04-20 12:09:56 PDT
Asa, this patch is helpful when Firefox is running with blacklisted sources from two different sources.

The first source is the Firefox builtin blacklist.
The second source is an NSS builtin blacklist.

Linux distributions want to ship an NSS with a builtin blacklist, in order to allow other NSS-based applications to benefit from the blacklist, too.

Unfortunately, the NSS based blacklist gives a weaker signal, it only says "untrusted", because right now, NSS is not yet able to embed "cert is revoked".

Unfortunately, Firefox/PSM has a bug.

When both blacklist sources are available, the NSS decision wins. Firefox will say "cert is untrusted".

This is unfortunate, because we really want it to say "revoked", not allowing a user to override.


The patch here fixes that bug.

The patch here ensures, that when both blacklists are available, the "revoked" status wins, and the other source is not able to weaken that decision.
Comment 17 Kai Engert (:kaie) 2011-04-20 12:13:48 PDT
Created attachment 527348 [details] [diff] [review]
Patch v3 - more and better comments
Comment 18 Brian Smith (:briansmith, :bsmith, use NEEDINFO?) 2011-04-20 12:55:44 PDT
Comment on attachment 527348 [details] [diff] [review]
Patch v3 - more and better comments

r+
Comment 19 Robert Relyea 2011-04-20 16:03:56 PDT
> When both blacklist sources are available, the NSS decision wins. Firefox will
> say "cert is untrusted".

Also, this error is subtly different from the error you get if you just don't chain to a trusted cert (like the case of self-signed certs, or a cert chaining to an unknown issuer). The latter 2 cases are still overridable.

This only the case were a leaf cert (soon to include any type of cert) has been explicitly marked as 'do not trust'.

bob
Comment 20 JP Rosevear [:jpr] 2011-04-26 15:20:10 PDT
I think 6 extra weeks delay here will not make a big difference.  A better approach in the short term is to loop in the linux distros so they pick up this patch for all their releases.  Need debian and ubuntu contacts too if someone knows them.
Comment 21 Robert Sayre 2011-04-27 11:59:02 PDT
Comment on attachment 527348 [details] [diff] [review]
Patch v3 - more and better comments

We're going to take this on Aurora, since it might land on 3.5 and 3.6, and we don't want to regress users that upgrade. The patch is also very small.
Comment 23 Kai Engert (:kaie) 2011-05-04 03:19:46 PDT
I think a checkin to mozilla-aurora means: I must set status-firefox5 to fixed.
Comment 24 Kai Engert (:kaie) 2011-05-04 06:02:12 PDT
backed out from trunk (no problem with this patch, just backed out everything I did today). will reland soon
Comment 25 Peter van der Woude [:Peter6] 2011-05-04 09:19:21 PDT
Kai, it looks like you didn't backout this one from mozilla-aurora
Comment 26 Kai Engert (:kaie) 2011-05-04 09:28:00 PDT
yes. it worked on aurora, I didn't see a need to backout there. The reason for my backout wasn't related to this bug, just some other things broke that I happened to land at the same time to mozilla-central.
Comment 27 Kai Engert (:kaie) 2011-05-04 13:58:13 PDT
Comment on attachment 527348 [details] [diff] [review]
Patch v3 - more and better comments

Dan explained to me that blocking+ is not sufficient to land on 1.9.1/1.9.2 branches.

Requesting explicit approval for those branches.
Comment 28 Kai Engert (:kaie) 2011-05-05 14:05:26 PDT
(In reply to comment #24)
> backed out from trunk (no problem with this patch, just backed out everything I
> did today). will reland soon

relanded 

http://hg.mozilla.org/mozilla-central/rev/92d5e760e0c0
Comment 29 Daniel Veditz [:dveditz] 2011-05-09 15:05:39 PDT
Comment on attachment 527348 [details] [diff] [review]
Patch v3 - more and better comments

Approved for 1.9.2.18 and 1.9.1.20, a=dveditz for release-drivers

Mozilla is not planning on releasing a 3.5.20 but if you want to land on the 1.9.1 branch you've got permission to do so.

Clearing the mozilla-2.0 request as we don't plan any further releases from that branchlet.
Comment 31 Cameron Kaiser [:spectre] 2011-05-21 16:35:33 PDT
Per security group discussion, requesting landing on mozilla-2.0.
Comment 32 Kai Engert (:kaie) 2011-05-22 04:21:17 PDT
Comment on attachment 527348 [details] [diff] [review]
Patch v3 - more and better comments

I think Cameron intended to set the approval2.0 ? flag
Comment 33 Daniel Veditz [:dveditz] 2011-06-03 16:49:54 PDT
Comment on attachment 527348 [details] [diff] [review]
Patch v3 - more and better comments

Approved for the mozilla2.0 repository, a=dveditz for release-drivers

When landed please add a link to the changeset and flip the status2.0 field to ".x-fixed"
Comment 34 Al Billings [:abillings] 2011-06-09 12:28:37 PDT
Kai, is there a good STR for this? Do you have a site that can be used for testing with a cert for this?
Comment 35 Brian Smith (:briansmith, :bsmith, use NEEDINFO?) 2011-06-10 00:09:16 PDT
Al, I think we should be able to write an automated test for this. Re-opening because we don't have the test.
Comment 36 Kai Engert (:kaie) 2011-06-10 05:02:10 PDT
I would prefer to keep bugs closed for issued that are clearly solved.
Keeping solved issues open often causes confusion.
Please open a separate bug for getting a test added, if you think it's necessary.
(I'm not convinced it's necessary.)

The issue is difficult to reproduce, because if requires a special mix of Firefox and NSS.

Mozilla has never shipped a mix that shows the issue.

On Fedora we have prevented the issue by applying a fix locally.

So in order to reproduce the failure, you would have to artifically create a broken environment, by e.g. using a Firefox lacking this fix, combining it with a NSS 3.12.0

Note You need to log in before you can comment on or make changes to this bug.