Skip to content

🐛 fix(app-data): protect missing cache parents - #3642

Merged
gaborbernat merged 2 commits into
pypa:mainfrom
gaborbernat:fix/qzd-private-cache-parents
Nov 20, 2026
Merged

gaborbernat merged 2 commits into
pypa:mainfrom
gaborbernat:fix/qzd-private-cache-parents

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

The default app-data creation path made the cache leaf private but could create its missing parent with permissions from a permissive umask. Another local account with write access to that parent could replace the cache entry and affect later pip seeding. The default path now creates every missing component with owner-only permissions. This addresses draft advisory ANT-2026-QZDZJBPR.

Default cache creation used the umask for parents

The old os.makedirs(..., mode=0o700) call set the leaf mode, while Python applies the process umask to intermediate directories. The new creation path uses make_private_dirs() for the default cache. It creates each missing component with mode 0700 and leaves existing components untouched.

Migration could create an open target parent

The old migration paths could create a missing target parent through shutil.move() or os.makedirs(). Nonnested migration now prepares that parent before moving or copying data. The migration target path now closes missing nested components too, unless the old cache has the setgid bit for intentional sharing. Migration markers, retry behavior, and config retention still use their existing paths.

Behavior changes

On POSIX, each missing default-cache ancestor is created with mode 0700, including under umask 002 or 000. On Windows, Python 3.12.4 and later apply owner-only access control for os.mkdir(..., 0o700); earlier supported runtimes ignore the mode, as they did for the cache leaf. An existing directory keeps its mode. Explicit --app-data paths retain their umask-based creation behavior. Migration from a setgid shared cache retains group access. If a new path component becomes a file during creation, or an unavailable filesystem root stops the walk, the default cache falls back to temporary app-data.

Reported by oss-scanner: ANT-2026-QZDZJBPR.

Default app-data creation made only the cache leaf private. A loose umask
could leave its parent writable by another local account.

Create missing ancestors with owner-only permissions during default cache
creation and migration. Existing paths and setgid shared caches retain
their modes.
@gaborbernat gaborbernat added bug security Fixes a vulnerability or hardens the supply chain, CI or release labels Nov 20, 2026
@gaborbernat
gaborbernat merged commit b0b4c09 into pypa:main Nov 20, 2026
79 checks passed
gaborbernat added a commit that referenced this pull request Nov 20, 2026
Complete the cache creation fix from #3642.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug security Fixes a vulnerability or hardens the supply chain, CI or release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant