fix(temp_utils): create scratch dir ancestors with mode 0700#6928
Open
abidedavana wants to merge 1 commit into
Open
fix(temp_utils): create scratch dir ancestors with mode 0700#6928abidedavana wants to merge 1 commit into
abidedavana wants to merge 1 commit into
Conversation
The exec-capable fallback scratch directories (/var/tmp/cloud-init and the /usr/lib/cloud-init/clouddir fallback used when /var/tmp is noexec) were created world-writable (0o1777) and left behind after cloud-init ran. All consumers run as root and the per-run mkdtemp children are already 0o700, so the ancestor need not be world-writable. Create it 0o700 instead, which also satisfies STIG UBTU-20-010427. Fixes canonicalGH-4189
holmanb
reviewed
Jul 13, 2026
| if not os.path.isdir(tdir): | ||
| os.makedirs(tdir) | ||
| os.chmod(tdir, 0o1777) | ||
| os.chmod(tdir, 0o700) |
Author
There was a problem hiding this comment.
the sticky bit only matters when multiple users can write to a dir , it stops them deleting/renaming each other's files, like in /tmp. with 0700 root is the only writer, so there's nothing left for it to protect. happy to keep it (0o1700) if you'd prefer, but on a root-only dir it'd be a no-op.
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.
The exec-capable fallback scratch directories (/var/tmp/cloud-init and the /usr/lib/cloud-init/clouddir fallback used when /var/tmp is noexec) were created world-writable (0o1777) and left behind after cloud-init ran. All consumers run as root and the per-run mkdtemp children are already 0o700, so the ancestor need not be world-writable. Create it 0o700 instead, which also satisfies STIG UBTU-20-010427.
Fixes GH-4189