Skip to content

Don't use req.body to store parsed auth context #407

@slifty

Description

@slifty

The shape of req.body is defined by an API caller which makes it a potentially dangerous place to store auth context since a user could construct a body that contains auth information.

If we (1) have auth logic looking at that object and then (2) somehow fail to sanitize the user input then someone could inject permissions they don't have.

The solution here is to use something that does not get written by express / is ONLY populated by our auth middleware, (e.g. req.auth).

A happy side effect of this is that it allows us to address #284 since we'll no longer have middleware that expects other-middleware-populated req state (specifically: req.body does not exist unless the express.json or bodyParser.json middleware has been run).

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