New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 806642 link

Starred by 2 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac
Pri: 2
Type: Bug

Blocked on:
issue 431618



Sign in to add a comment

Credential API not working with self-signed certificates

Reported by mgr...@rosey.io, Jan 29 2018

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.119 Safari/537.36

Steps to reproduce the problem:
# Running this on https://google.com returns expected behavior:
# Chrome prompts you to save your credentials

# This also works if you spin up an http server i.e: `python -m SimpleHTTPServer`
# and run it in your console.

# However running on https://localhost results in a silent failure
# where the success function fires but you are not prompted.
# Easy way to spin up a simple https server is: https://gist.github.com/dergachev/7028596

var creds = new PasswordCredential({
	id: "test@test.com",
	password:"password1"
});

navigator.credentials.store(creds).then(function(){
	console.log("Done saving credentials");
});

What is the expected behavior?
Chrome would prompt the user on https://localhost the same way it does on http://localhost or https://non-localhost-site

What went wrong?
The credentials store fails silently, doesn't prompt the user but calls the success function

Did this work before? No 

Does this work in other browsers? N/A

Chrome version: 64.0.3282.119  Channel: stable
OS Version: OS X 10.13.1
Flash Version: 

I wrote out an example case here: https://gist.github.com/MichaelScript/1ea27fe211fe55f278108816f0c8754a#file-credential-api-not-working-on-https-localhost
 

Comment 1 by b...@chromium.org, Jan 29 2018

Components: UI>Browser>Passwords
Labels: Needs-Triage-M64

Comment 3 by vabr@chromium.org, Jan 30 2018

Cc: vasi...@chromium.org
Labels: Needs-Feedback
Thanks for the report.

Does saving work for a simple HTML form (like on https://rsolomakhin.github.io/autofill/) hosted on https://localhost?

Does Chrome report any certificate errors with https://localhost? (Check the left-hand corner of the URL bar).

Could you please open a second tab with chrome://password-manager-internals/ when you reproduce this issue and share its contents?

Also adding Vasilii, who has more insight into CM API.
I actually can't reproduce it locally because Chrome returns a certificate error.
Thus, in addition to Comment #3 I'm also curious how you deceived Chrome?

Comment 5 by mgr...@rosey.io, Jan 30 2018

You're saying you get a certificate error from the promise correct? Yeah
that's not happening for me. I'm also not getting any error on
https://expired.badssl.com, the promise still succeeds but no error is
thrown and you aren't prompted for your credentials it just fails silently.
I reset all my chrome flags to the defaults and I still get the same
behavior regardless on the validity of the SSL cert.
Project Member

Comment 6 by sheriffbot@chromium.org, Jan 30 2018

Cc: vabr@chromium.org
Labels: -Needs-Feedback
Thank you for providing more feedback. Adding requester "vabr@chromium.org" to the cc list and removing "Needs-Feedback" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 7 by mgr...@rosey.io, Jan 30 2018

Here is the output from the chrome://password-manager-internals/

```
------------------------------
CM API save a credential: origin=https://localhost/,
CredentialType=CredentialType::CREDENTIAL_TYPE_PASSWORD
------------------------------
SSL errors present: true
```

I was expecting it to work on https://localhost however it only works on
http://localhost

Here is the output from running on http://localhost

```
CM API save a credential: origin=http://localhost:8000/,
CredentialType=CredentialType::CREDENTIAL_TYPE_PASSWORD
------------------------------
SSL errors present: false
------------------------------
IsPasswordManagementEnabledForCurrentPage: true
------------------------------
Message: FormFetcherImpl::Fetch
------------------------------
FormFetcherImpl::state_: 1
------------------------------
Message: FormFetcherImpl::Fetch
------------------------------
FormFetcherImpl::state_: 0
------------------------------
Message: FormFetcherImpl::Fetch
------------------------------
FormFetcherImpl::state_: 1
------------------------------
Message: FormFetcherImpl::OnGetPasswordStoreResults
------------------------------
Number of results from the password store: 0
------------------------------
Message: PasswordFormManager::ProcessMatches
------------------------------
The new state of the UI: 1
```

So the expected behavior would be for it to work on https://localhost as it
does with http://localhost however even weirder is that some sort of error
should be thrown or the promise should be rejected if it is not able to
store the credentials, it shouldn't fail silently as it does now.

Thank you for your help it's really awesome to get such immediate feedback!
Labels: Needs-Feedback
I meant that Chrome doesn't allow me to load the page because the certificate is invalid. Your flow is the same due to "SSL errors present: true". The API doesn't work because the certificate is invalid and it's expected. Am I missing something?

Comment 9 by mgr...@rosey.io, Jan 31 2018

Yes but if you're testing on localhost you should still be able to test
with an invalid cert similar to how you are able to do so with other HTTPs
only APIs such as navigator.geolocation. I realize these work on
http://localhost but I just don't understand why it wouldn't behave the
same way as other HTTPs restricted APIs do on localhost.
Project Member

Comment 10 by sheriffbot@chromium.org, Jan 31 2018

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding requester "vasilii@chromium.org" to the cc list and removing "Needs-Feedback" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Cc: mkwst@chromium.org
Mike, what does the spec say about this case?

We are using the same code as for password autofill. I'm hesitant to change it. Can developers somehow test with a "valid" local certificate?
Cc: battre@chromium.org
> Mike, what does the spec say about this case?

The secure context spec says that `https://localhost` is a secure context assuming that it's "HTTPS state" is "modern". Fetch leaves a good deal of wiggle room for browsers to decide what exactly that means (see the note at https://fetch.spec.whatwg.org/#concept-https-state-value).

I think I agree with the reporter that it's strange for us to accept the user's decision to trust a given context for the purposes of some subset of restricted APIs (geolocation, getUserMedia, etc), and not for others (autofill, credential management).

> We are using the same code as for password autofill. I'm hesitant to
> change it.

+battre@, who I think has a doc on this somewhere?
If https://localhost is secure then Chrome shouldn't pop up the red interstitial page with "Privacy violated" message. currently one can't get to the page without dismissing the warning. If the security team changes it then the API would work fine.


> If https://localhost is secure then Chrome shouldn't pop up the red interstitial page with "Privacy violated" message. currently one can't get to the page without dismissing the warning. If the security team changes it then the API would work fine.

`https://localhost` is Totally Secure(tm) if the user installs the root cert used to sign the `localhost` cert into their OS's trust store. In that case, the user wouldn't receive an interstitial, and wouldn't need to click through anything, because the locally-installed root would confer trust on the origin.

In most cases, though, the web-facing notion of a "secure context" doesn't particularly care whether trust is established implicitly by chaining up to a trusted root cert, or explicitly by the user clicking through an interstitial. We'd consider the origin Secure Enough(tm) in either case to allow geolocation access, for instance.

Autofill and the password manager have an additional check on top of the "Was this delivered via a TLS connection the user chose in some way to trust" that web-facing features generally use, which additionally enforces the constraint that the TLS connection can't have had an interstitial which the user bypassed. It's not clear to me that we have a defensible threat model there. That said, I also haven't thought a ton about it, so. :)
Ok, couple of statements I believe in
- If a developer makes the localhost certificate trusted then the API works fine. Thus, they are not blocked with testing their sites today.
- CM API and password autofill should have the same security properties. In particular, there should be no way that CM API works on X but autofill doesn't.
- There is a project to allow password saving/filing on self-signed origins. When it's done we can tweak the CM API to work the same way on those sites.

Thus, I think we shouldn't patch our code to work in a special way just on https://localhost. Please correct me if I missed something.

Dominic, do you agree?

Comment 16 by mgr...@rosey.io, Feb 1 2018

I didn't really expect this much discussion, *thank you all for looking
into this*. I'll just configure my machine to allow the certificate as a
work around. I think the only issue is the inconsistency between the APIs
which isn't necessarily a problem, it was just difficult to find out why it
was failing because there was no error and no differentiation between what
is considered secure context when testing locally within any of the
documentation I read.

Comment 17 by vabr@chromium.org, Feb 2 2018

And just for reference, the bug tracking the general changes to working on pages with broken HTTPS is issue 431618.
Blockedon: 431618
Labels: -Needs-Triage-M64 OS-Android OS-Chrome OS-iOS OS-Linux OS-Windows
Status: Available (was: Unconfirmed)
Summary: Credential API not working with self-signed certificates (was: Credential API not working on https localhost)
All right. Let's fix this bug once the password manager supports the self-signed certificates.
Labels: -OS-iOS
Cc: -vabr@chromium.org
vabr going hobby only -> reducing involvement.
Please contact me directly in urgent matters.

Sign in to add a comment