fix: guard builder plugin command umask on group-writable hosts - #33
Merged
Conversation
run_builder_plugin_command spawned the Codex CLI without an os.umask guard, unlike its sibling run_verified_installer. On hosts whose ambient umask is 0002 (the Ubuntu default, unlike macOS 022) the child inherited that umask and created plugins/, cache/, marketplace/, and the cached plugin manifest with group-writable modes (0775/0664). The builder cache validators reject any entry with mode & 0o022, so install-builder failed closed on Ubuntu desktops. Wrap the Popen in os.umask(0o077)/restore, mirroring run_verified_installer. Add regression tests asserting the guard is present, restores the ambient umask, and prevents group-writable child output under umask 0002.
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.
Problem
run_builder_plugin_commandspawned the Codex CLI without anos.umaskguard, unlike its siblingrun_verified_installer. On hosts whose ambient umask is0002(the Ubuntu default, unlike macOS022) the child inherited that umask and createdplugins/,cache/,marketplace/, and the cached plugin manifest with group-writable modes (0775/0664).The builder cache validators reject any entry with
mode & 0o022, soinstall-builderfailed closed on Ubuntu desktops:Fix
Wrap the
Popeninos.umask(0o077)/restore, mirroringrun_verified_installer(lines 3353-3365). This is the only unguardedPopencall site in the module (audit confirmed exactly 2Popencalls; the other is already guarded).Tests
Added
tests/test_umask_guard.py(3 cases, all passing):test_guard_restores_prior_umask— the guard sets the effective mask to0o077and restores the ambient umask afterward, even under umask0002.test_child_dirs_are_not_group_writable_under_guard— a child mimicking the Codex CLI's directory creation cannot produce group-writable entries while the guard is active.test_source_has_the_guard— static guard: the umask pair appears in bothrun_verified_installerandrun_builder_plugin_command.Run with:
uv run --with pytest pytest tests/test_umask_guard.py -vVerification
Tested on
rldyourmnd-ubuntu-1(Ubuntu 26.04 x86_64, umask 0002):install-buildersucceeds after this fix; the previously-failing validator path now passes.Notes
git ls-filesshows all100644); the on-disk664/775is purely a local-checkout artifact of umask 0002 and is exactly what the guard prevents the child from reproducing. Nochmod/.gitattributeschange is needed.rldyourmnd-ubuntu-1).