Skip to content

fix(auth): the OAuth token cache is not access-restricted on Windows #436

Open

Description

@claude

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_file creates the file through tempfile.mkstemp, which documents "readable and writable only by the creating user ID" in POSIX terms; _ensure_dir creates the directory with mkdir(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 are skipif(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:

  1. Restrict by ACL on Windows. Needs a platform-specific call (pywin32, or ctypes against advapi32) to set an owner-only DACL on the directory at creation. A new optional dependency, or a chunk of ctypes, for a path the SDK's CI does not currently exercise.
  2. 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 configures CAMUNDA_TOKEN_CACHE_DIR somewhere shared. That would make this a documentation and default-location issue rather than a code one.
  3. 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

  1. added
    bug
    affects/main
    severity/low
    found-by/review
    on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects/mainbugfound-by/reviewseverity/low

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions