Skip to content

this library is "insecure" to CSRF by default, security mechanisms confusing to use and enable #164

@joshribakoff-sm

Description

@joshribakoff-sm

Our security team flagged that we were missing CSRF protection, which was surprising because we chose a open source library that is widely used, assuming that it would be secure by default if it was so widely used.

In #138 support for state param was added. It states that you can pass true to enable CSRF protection; however my team found that even after setting it to true, the library did not append any state pram to the redirect URL.

Finally we were able to store a token into our session manually and then pass it as the state param to passport.authenticate()'s 2nd argument. This isn't even documented in the README for the project.

There is also this issue that is related from five years ago that has gone unaddressed where another user flagged that the library is insecure [by default] and could not figure out how to enable the security. #74

Is there any reason to not have CSRF protection either on by default, or always on? At the very least there should be more prominent warnings logged to stderr or in your a big warning in your README so that people know that they are not running a production ready set up when they choose this library, without further efforts.

An example of an "attack" is that an attacker can stop their own login flow and send a URL with their code to a victim, upon clicking the link the victim is logged in as the attacker. This is a security problem because the victim could unintentionally pay the attacker's bill, or could enter their social security number into a form that gets saved to the account that the attacker controls, etc..

It is also required to have CSRF protection on both the client and the server, according to the Oauth2 spec

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions