Repository navigation
Description
The OAuth token cache is restricted by POSIX mode bits only. On Windows a mode argument does not become an access-control list, so neither the cache directory's 0700 nor the token file's 0600 restricts anything: both inherit the ACL of the directory they are created in.
This is long-standing, not a regression — the previous Path.write_text plus os.chmod did not restrict access on Windows either. It is filed separately because #424 removes the POSIX exposure window and the non-atomic write, and the Windows half needs a decision this repo has not made.
Evidence
runtime/auth.py—_write_private_filecreates the file throughtempfile.mkstemp, which documents "readable and writable only by the creating user ID" in POSIX terms;_ensure_dircreates the directory withmkdir(mode=0o700). CPython maps the mode to the read-only attribute on Windows, not to a DACL.tests/acceptance/test_token_cache_permissions.py— the mode assertions areskipif(os.name != "posix")for this reason, so CI on Windows does not cover it.
Found by Copilot's review of #429.
Expected behaviour
Shared SDK policy, Secrets must not leak: "For the on-disk OAuth token cache, review its location, file permissions (mode 0600), cleanup and Windows behaviour whenever you change it."
The decision this needs
Three options, none of which should be picked inside a bug-fix PR:
- Restrict by ACL on Windows. Needs a platform-specific call (
pywin32, orctypesagainstadvapi32) to set an owner-only DACL on the directory at creation. A new optional dependency, or a chunk ofctypes, for a path the SDK's CI does not currently exercise. - Rely on the default location. If the cache lives under
%LOCALAPPDATA%, the per-user profile ACL already restricts it, and the gap only reappears when a user configuresCAMUNDA_TOKEN_CACHE_DIRsomewhere shared. That would make this a documentation and default-location issue rather than a code one. - Document the limitation and leave the behaviour as it is.
Whichever is chosen, the cross-SDK answer should match: the other SDKs cache tokens on Windows too.
Type: bug
Found-by: review
Affects: main
Severity: low
Activity
chore(auth): stop claiming a Windows guarantee, and harden two edges
test(auth): pin the long-filename and raising-logger token cache edges
fix(auth): write the oauth token cache private and atomically (#429)
docs: document the Windows limits of the OAuth token cache (#439)
fix(auth): write the oauth token cache private and atomically (#429) (#…