Skip to content

How can I differentiate a tampered signed cookie from a false JSON cookie? #168

@the-can-of-soup

Description

@the-can-of-soup

Forewarning: I am extremely new to Node.js and NPM.

From reading the documentation of cookieParser, it appears that cookies that are signed but fail validation are assigned false in the req.signedCookies object.

Signed cookies that fail signature validation will have the value false instead of the tampered value.

Also, cookies prefixed with j: are automatically parsed with JSON.parse.

In addition, this module supports special "JSON cookies". These are cookie where the value is prefixed with j:. When these values are encountered, the value will be exposed as the result of JSON.parse.

However, the string 'false' is valid JSON, so it should get parsed to false. I also found no option to disable the built-in JSON parser. How can I differentiate a valid signed j:'false' cookie from an invalid signed cookie?

If this is not possible, I request that this be relabeled to a bug report or feature request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions