Skip to content
This repository was archived by the owner on Jan 29, 2022. It is now read-only.
This repository was archived by the owner on Jan 29, 2022. It is now read-only.

Security: move all permission validation to happen prior to normal serializer validation #158

@zachmullen

Description

@zachmullen

Running validators before fully checking permission can spill private data to unauthorized users. One example that already exists is in POST /folders, where we don't do permission checking until inside perform_create on the view set. Validators on the serializer are all run prior to that, which for example can leak the existence of a folder or file with a given name inside a folder that a user has no access to.

DRF runs things in the following order in the default create:

  1. Permission checking via permission_classes
  2. Serializer validation
  3. perform_create

In summary, any logic that could be used to deny permission to a user, should occur in permission classes, or else if that's not practical, must run as serializer validators prior to any non-permission related serializer validators. Permission checking must occur prior to serializer.is_valid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsecurity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions