Skip to content

/proc hardening #7

@cyphar

Description

@cyphar

Right now, we do a few security checks when operating on /proc, namely:

  • That /proc has an fs_type of PROC_SUPER_MAGIC (which can't be faked by FUSE), to make sure we're dealing with a real procfs.

  • That /proc has an inode number of 1 to indicate that it is the root of a procfs mount -- which is part of the API of Linux and will always be the case.

Unfortunately, this method is still vulnerable to potential attacks if we're in a situation where /proc (usually thanks to a confused deputy) has been set up in such a way to trick us into thinking (for instance) that we are writing an AppArmor label when in fact we aren't.

Effectively we need to use the resolution capabilities of libpathrs for /proc (which leads to some fun re-entrancy issues since libpathrs depends on using /proc during resolution). So that will need some attention.

Note that checking that a given Handle has PROC_SUPER_MAGIC is not sufficient at all because you can always bind-mount another process's procfs file to your own -- and for write-related requests you can just bind-mount a file which no-ops on write like /proc/self/sched.

The set of underlying features currently required are:

Metadata

Metadata

Assignees

No one assigned

    Labels

    securityA security issue or hardening problem.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions