Skip to content

uucore: add O_NOFOLLOW to DirFd::open_file_at - #13623

Open
sylvestre wants to merge 1 commit into
uutils:mainfrom
sylvestre:safe-traversal-open-file-at-nofollow
Open

uucore: add O_NOFOLLOW to DirFd::open_file_at#13623
sylvestre wants to merge 1 commit into
uutils:mainfrom
sylvestre:safe-traversal-open-file-at-nofollow

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

openat anchors the directory, not the final component, so open_file_at (O_CREAT|O_WRONLY|O_TRUNC) still followed a symlink planted at name and truncated its target -- despite the caller documenting the fd-based path as the one that "prevents symlink race conditions".

install's copy_file_safe calls it immediately after unlink_at(), which is exactly the window an attacker races; the path-based copy_file is stricter here because create_new(true) implies O_EXCL.

Truncate-an-existing-file semantics are unchanged; only symlinks are refused.

openat anchors the directory, not the final component, so open_file_at
(O_CREAT|O_WRONLY|O_TRUNC) still followed a symlink planted at `name` and
truncated its target -- despite the caller documenting the fd-based path as
the one that "prevents symlink race conditions".

install's copy_file_safe calls it immediately after unlink_at(), which is
exactly the window an attacker races; the path-based copy_file is stricter
here because create_new(true) implies O_EXCL.

Truncate-an-existing-file semantics are unchanged; only symlinks are refused.
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/tail-n0f (fails in this run but passes in the 'main' branch)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant