Skip to content

Moving away about pwstore-fast? #204

@galenhuntington

Description

@galenhuntington

Snap uses pwstore-fast for its password hashing needs in the authentication snaplet. That package however is troubling in many ways:

  1. It appears abandoned. The last commit was almost four years ago, with issues and PRs going unanswered for about as long. Worryingly, there is an open issue (pbkdf2 seems to generate a wrong hash PeterScott/pwstore#12) about one function possibly giving wrong results.

  2. It by default uses the obsolete and less secure PBKDF1, which is superseded by PBKDF2. The latter is (maybe) supported in pwstore-fast, but the snaplet uses the default. PBKDF1 should not be used for new applications (RFC 2898).

  3. It uses a custom format for storing the password hash, as opposed to established and portable formats such as bcrypt or MCF generally or PHC. While this is not necessarily a problem, a lack of vetting means stuff can be missed, and indeed the format fails to encode the derivation function. So, while an app can increase strength or change hashing functions for new users, as these are encoded, it cannot readily switch to PBKDF2 without locking out old users.

  4. It uses System.Random to generate salts, which is not cryptographically secure. This is a minor weakness, but several Haskell packages offer secure RNGs that could be used instead.

  5. It depends on the deprecated and unmaintained cryptohash package, which is thus pulled in and installed, and also whose module names conflict with its replacement cryptonite.

The ideal would be to just switch to a new algorithm; there's PBKDF2 and bcrypt and scrypt and Argon2 and so on. But that would break production uses of Snap auth.

There may be a backwards-compatible way to revise hashing while avoiding the above problems. Alternatively, auth could be modularized off into its own packages, so (e.g.) snaplet-old-auth and snaplet-auth-?? can coexist.

There should also be a way to customize the cost parameter(s), as the appropriate value changes (increases) over time.

I have never used the auth snaplet, and in fact removed those modules from my local install, for these reasons, so I don't have an informed opinion on what to do with it. But pinning to dated tech seems a bad option.

(Some of these issues were brought up in #85, which seems to have gone stale.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions