Harden OAuth U2M token cache encryption and file permissions#1520
Open
sreekanth-db wants to merge 1 commit into
Open
Harden OAuth U2M token cache encryption and file permissions#1520sreekanth-db wants to merge 1 commit into
sreekanth-db wants to merge 1 commit into
Conversation
- Replace the hardcoded PBKDF2 salt with a per-file random 16-byte salt, stored alongside the IV in the encrypted payload. This prevents offline key derivation from the passphrase alone. - Set file permissions to owner-only (0600) before writing content, eliminating the TOCTOU window where the cache file could be world-readable. Non-POSIX platforms retain best-effort behavior. - New on-disk format: Base64(salt[16] || IV[16] || ciphertext). Existing caches written with the old fixed-salt format will fail to decrypt and trigger a one-time re-authentication (handled gracefully by the SDK). - Add unit tests for random salt uniqueness, hardcoded-salt resistance, cross-instance round-trip, and POSIX permission enforcement. Co-authored-by: Isaac Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
Collaborator
|
can we add testing details to pr description? |
Collaborator
Author
|
Updated the PR description with testing details — unit tests, offline vulnerability repro, and end-to-end U2M browser flow results (before and after the fix). |
vikrantpuppala
approved these changes
Jul 2, 2026
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.
Summary
EncryptedFileTokenCachewith a per-file random salt, preventing offline key derivation from the passphrase alone.0600) before writing content, rather than after.Scope: Only affects the OAuth U2M browser flow (
AuthMech=11;Auth_Flow=2) withEnableTokenCache=1. PAT, M2M, token-passthrough, and Azure-MI are unaffected.User impact: Existing cached tokens (old format) will not decrypt after upgrade, triggering a one-time browser re-login. This is handled gracefully —
load()returnsnulland the SDK performs a fresh authentication.Addresses SEC-20598.
Testing
Unit Tests
All 21 unit tests in
EncryptedFileTokenCacheTestpass — 14 existing tests remain green, and 5 new tests were added covering:rw-------) from the start, not loosened then tightened.rw-r--r--) are tightened torw-------on overwrite.Offline Vulnerability Repro
A deterministic test (no browser or network required) saves a token and then simulates an attacker who knows the passphrase and the old hardcoded salt attempting to decrypt it:
End-to-End U2M Browser Flow
Tested the full OAuth U2M flow (
AuthMech=11;Auth_Flow=2;EnableTokenCache=1) against an Azure Databricks workspace, both before and after the fix:Before fix (baseline):
rw-------.After fix:
rw-------.NO_CHANGELOG=false
This pull request and its description were written by Isaac.