Skip to content

Replacing hashing password scheme with something more robust #3576

Closed as not planned

Description

@jsjoeio

While hashing is a major step forward, the problem with this approach is that it still allows attackers who have access to the hash to just submit it as-is and gain access to code-server - effectively not very different from storing it in plaintext.

We should definitely look into replacing this with something more robust so that password hashing isn't just a placebo.

As security expert @oxy points out, our current approach for hashing the password and storing it in a cookie is more like a placebo-effect than a real security approach.

#3422 (comment)

Related:

Activity

  1. added this to the On Deck milestone on Jun 8, 2021
  2. oxy commented on Jun 9, 2021

    @oxy

    One possible route forward is to generate a token when code-server is started, and then return that token if authentication was successful - this means that you'd need to re-auth if you restart code-server, but I think its an acceptable middle ground between security and ease-of-use.

  3. jsjoeio commented on Jun 9, 2021

    @jsjoeio
    ContributorAuthor

    this means that you'd need to re-auth if you restart code-server, but I think its an acceptable middle ground between security and ease-of-use

    Agreed! I like the sound of that approach.

  4. Livven commented on Jun 11, 2021

    @Livven

    If I understand correctly the password hash is directly set as a cookie, instead of using some kind of session token, which is why a leak of the password hash on the server would allow attackers to authenticate with the password hash without knowing the original password, right?

    In that case what you could do is to store sha256(argon2(password)) on the server and set argon2(password) as a cookie. This way, if an attacker steals sha256(argon2(password)) from the server, they would still not be able to authenticate.

    Note that a simple sha256 is adequate here since argon2 already takes care of the key stretching.

    As a bonus, you could even offload argon2 computation to the client as server relief, thanks to the additional sha256 on the server.

  5. jsjoeio commented on Jun 11, 2021

    @jsjoeio
    ContributorAuthor

    If I understand correctly the password hash is directly set as a cookie, instead of using some kind of session token, which is why a leak of the password hash on the server would allow attackers to authenticate with the password hash without knowing the original password, right?

    Exactly!

    In that case what you could do is to store sha256(argon2(password)) on the server and set argon2(password) as a cookie. This way, if an attacker steals sha256(argon2(password)) from the server, they would still not be able to authenticate.

    Wow, this seems very straightforward to implement (and test too). Thanks so much for the suggestion and the tips! 🙌 Really appreciate it.

  6. jsjoeio commented on Jan 3, 2022

    @jsjoeio
    ContributorAuthor

    Note to self: we may actually move away from argon2. It requires native binaries and has caused a lot of problems with Termux, Raspberry Pi and other devices/environments.

  7. jsjoeio commented on Jan 3, 2022

    @jsjoeio
    ContributorAuthor

    We've also talked about moving to a session token which I believe VS Code has built-in support for.

  8. jsjoeio commented on Jan 3, 2022

    @jsjoeio
    ContributorAuthor

    node-rs now publishes an argon2 package. Might help here: https://github.com/napi-rs/node-rs/tree/main/packages/argon2

  9. code-asher commented on Jul 13, 2024

    @code-asher
    Member

    Merging with #3546

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSome improvement that isn't a featuresecuritySecurity related

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions