Skip to content

Loader path security #991

@mrdomino

Description

@mrdomino

There is currently a security issue in the way the loader passes paths to the binary.

For argument's sake, consider:

  • user installs a setuid root sudo.com that reads its configuration out of /zip/etc/sudoers
  • user does ln -sf /usr/local/bin dir
  • user runs dir/../bin/sudo.com bad.sh
  • user wins a race with the loader, changing dir to point to bad from which ../bin/sudo.com is a zip archive with a user controlled sudoers file in it, between when the loader finds the binary and when the binary opens itself

There are a few mitigations that can be done:

  1. If the loader detects that the binary it has been asked to run is setuid, it can refuse to run it from a non-canonical path (i.e. a path containing ...)
  2. The loader can always do (the moral equivalent of) realpath on the path it resolves before passing it to the binary.
  3. More speculatively, binaries can embed their own hash at a known label. Whenever they open themselves, they can compare the hash of the binary they open against their own embedded value.

1 is a no-brainer. 2 may be a good idea but I'm not sure it buys much beyond 1. 3 is a very neat sounding idea to me; thoughts?

EDIT: actually 1 doesn't help that much. Consider: ln -sf /usr/local dir; ~/dir/bin/sudo.com. There is probably some adjacent mitigation that is similar in spirit though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions