recovery: add O_NOFOLLOW|O_EXCL to prevent symlink-following in recovery file creation#448
Merged
ebiggers merged 1 commit intogoogle:masterfrom Apr 15, 2026
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
…ery file creation WriteRecoveryInstructions() opens the recovery README with os.OpenFile using O_WRONLY|O_CREATE without O_NOFOLLOW. When fscrypt encrypt runs as root, this allows a local attacker to place a symlink at the recovery file path, causing root to write through the symlink and then fchown the target file to the attacker. Adding O_EXCL|O_NOFOLLOW aligns with the existing security pattern in filesystem.go:608 and filesystem.go:747.
fea6c21 to
a3279c3
Compare
ebiggers
approved these changes
Apr 15, 2026
Collaborator
|
Merged, thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WriteRecoveryInstructions() at recovery.go:94 opens the recovery README
with os.O_WRONLY|os.O_CREATE without O_NOFOLLOW. When fscrypt encrypt
runs as root via sudo, a local attacker who controls the parent directory
can place a symlink at the recovery file path, causing root to write
through the symlink and fchown the target to the attacker.
The rest of the codebase uses O_NOFOLLOW consistently:
This change adds os.O_EXCL|unix.O_NOFOLLOW to align with the existing
security pattern.