Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Send cryptographically secure nonce with login request, verify on token receipt #7

Open
isaacs opened this issue Nov 15, 2019 · 2 comments

Comments

@isaacs
Copy link
Contributor

isaacs commented Nov 15, 2019

Why

While the web login design is more secure than the CouchDB style login, it still is potentially vulnerable to a MITM where an attacker injects a malicious token.

The current flow works like this:

cli                                           registry
------------------------------------------------------
  POST /-/v1/login {} -->
                           <-- 200 {doneUrl, loginUrl}

(opens $loginUrl in web browser)

  GET $doneUrl -->


              (possible "retry"/state-change update)
                           <-- 202 retry-after
  (wait $retry-after seconds)
  GET $doneUrl -->

                           <-- 200 {token}

Proposal

Include a cryptographically secure nonce in the initial request.

If provided in the initial request, the registry MUST repeat the nonce back in the final token response.

cli                                           registry
------------------------------------------------------
  POST /-/v1/login {nonce} -->
                           <-- 200 {doneUrl, loginUrl}

(opens $loginUrl in web browser)

  GET $doneUrl -->


              (possible "retry"/state-change update)
                           <-- 202 retry-after
  (wait $retry-after seconds)
  GET $doneUrl -->

                           <-- 200 {token, nonce}
(verify nonce, fail if missing or not matching)

This will have to be implemented on the registry (and in npmE) first, and only incorporated into this library once supported.

Registry MUST accept requests without a nonce, and not include a nonce if the initial request did not include one.

Threat Model Improvement

An attacker must MITM the entire transaction (or at least, the initial POST) in order to provide a malicious token, whereas currently, they only have to get in front of the final 200 response.

@isaacs
Copy link
Contributor Author

isaacs commented Nov 16, 2019

cc: @wraithgar @nlf @djsauble, tangential to our conversations on extending login and rolling out web login for all.

@isaacs
Copy link
Contributor Author

isaacs commented Nov 16, 2019

Consensus seems to be that UUID v4 is fine as a nonce. Use that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant