Skip to content

Refuse in-root symlinks for auth files opened through os.Root #257

Closed

Description

@HemSoft

Problem

readAuth (reviewer/auth_profile_unix.go:174) opens auth files (state.json, lease.json, …) with root.OpenFile(path, O_RDONLY|O_NOFOLLOW|O_NONBLOCK, 0) on an *os.Root. With Go 1.26, os.Root.OpenFile follows a symlink whose target stays inside the root even when O_NOFOLLOW is set; only a plain os.OpenFile refuses it (ELOOP). The following privateAuthFile check then judges the symlink's target, so the documented "no symlink" rule for the private auth directory is not enforced. Production has 55 OpenFile(... O_NOFOLLOW ...) call sites; those on an *os.Root may share this gap.

Evidence

Reproduced on mini with go1.26.7: in a fresh directory, state.json -> real.json; os.OpenRoot(dir).OpenFile("state.json", O_RDONLY|O_NOFOLLOW, 0) returns the file with no error, while os.OpenFile(dir+"/state.json", O_RDONLY|O_NOFOLLOW, 0) fails with "too many levels of symbolic links". Observed first by the E2E qualification work for #250.

Impact

Low: creating such a link already requires write access to the private 0700 auth directory. It is a hardening gap where the code's stated invariant is silently not enforced.

Acceptance criteria

  • Opening an auth file that is a symlink (in-root or escaping) is refused, for every auth file the store reads or writes.
  • The other *os.Root + O_NOFOLLOW call sites are audited, and each either refuses symlinks or documents why following an in-root link is acceptable.
  • Tests create an in-root symlink for each audited path and require refusal.

Validation

go -C reviewer test -race -run 'Auth' . and the full race suite.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingrisk:lowLow-risk: dependency bumps, safe refactorssource:manualManually created by developer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions