Visitar URL original
Fix cache client context validation by PingaleSampada · Pull Request #8869 · AzureAD/microsoft-authentication-library-for-js · GitHub
Skip to content

Fix cache client context validation - #8869

Merged
Sampada (PingaleSampada) merged 10 commits into
devfrom
spingale-microsoft-cache-client-context-validation
Sep 29, 2026
Merged

Sampada (PingaleSampada) merged 10 commits into
devfrom
spingale-microsoft-cache-client-context-validation

Conversation

@PingaleSampada

@PingaleSampada Sampada (PingaleSampada) commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • validate structured and legacy credential broadcasts against the exact client owner while preserving shared account and family refresh-token updates
  • treat BroadcastChannel messages as cache notifications and reload values from persistent storage instead of trusting sender-provided token data
  • prevent stale asynchronous decryptions from overwriting newer writes or removals and synchronize removals across tabs
  • preserve the existing encryption context for cache compatibility while using stricter client-aware broadcast routing
  • add regression coverage for forged values, app and family refresh tokens, legacy keys, removals, decryption failures, races, malformed payloads, and mixed-case client IDs

Related incident: IcM 31000000727400

Validation

  • @azure/msal-browser: dependency-ordered type build
  • @azure/msal-browser: 120/120 suites, 2,190 passed tests (3 skipped)
  • @azure/msal-browser: lint (0 errors; 2 pre-existing warnings)
  • @azure/msal-browser: format check and API Extractor
  • git diff --check

assistance: agentic-ide
type: bug
agent-tool: copilot-chat
agent-model: n/a
work-item: AB#n/a

@PingaleSampada Sampada (PingaleSampada) added agentic-ide Copilot IDE / editor agent drove the bulk of actions bug A problem that needs to be fixed for the feature to function as intended. labels Sep 25, 2026
Sampada (PingaleSampada) pushed a commit that referenced this pull request Sep 25, 2026
Add patch changefiles for msal-common and msal-browser linked to PR #8869.
@PingaleSampada
Sampada (PingaleSampada) marked this pull request as ready for review September 25, 2026 17:56
@PingaleSampada
Sampada (PingaleSampada) requested a review from a team as a code owner September 25, 2026 17:56
Copilot AI lite review requested due to automatic review settings September 25, 2026 17:56
@PingaleSampada
Sampada (PingaleSampada) marked this pull request as draft September 25, 2026 17:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Critical client-context validation gaps remain in Node cache keys and auth-scheme access tokens.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 High severity

Open (2)
What changed in this PR

Fixes cache client-context validation to prevent credential collisions and unsafe broadcasts.

Changes:

  • Enforces exact client/family ownership matching.
  • Validates browser credential broadcasts.
  • Adds regression tests and package changefiles.
File Summary
lib/​msal-common/​test/​cache/​CacheManager.spec.ts Adds collision regression coverage.
lib/​msal-common/​src/​cache/​CacheManager.ts Adds owner validation; unresolved critical gap for --separated Node keys (2 votes).
lib/​msal-browser/​test/​cache/​LocalStorage.spec.ts Adds broadcast validation coverage.
lib/​msal-browser/​src/​cache/​LocalStorage.ts Adds broadcast validation; unresolved critical gap for AccessToken_With_AuthScheme (4 votes).
change/​@azure-msal-common-client-context-validation.json Records the common package patch.
change/​@azure-msal-browser-client-context-validation.json Records the browser package patch.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions github-actions Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'msal-node client-credential Regression Test'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.10.

Benchmark suite Current: e8d603f Previous: 916beb1 Ratio
ConfidentialClientApplication#acquireTokenByClientCredential-fromCache-resourceIsFirstItemInTheCache 379785 ops/sec (±0.53%) 567933 ops/sec (±1.27%) 1.50
ConfidentialClientApplication#acquireTokenByClientCredential-fromCache-resourceIsLastItemInTheCache 372848 ops/sec (±0.76%) 615380 ops/sec (±1.12%) 1.65

This comment was automatically generated by workflow using github-action-benchmark.

CC: Bogdan Gavril (@bgavrilMS) Robbie-Microsoft

@PingaleSampada
Sampada (PingaleSampada) force-pushed the spingale-microsoft-cache-client-context-validation branch from b8d6d96 to 9f6f52d Compare September 25, 2026 18:23
Sampada (PingaleSampada) pushed a commit that referenced this pull request Sep 25, 2026
Add patch changefiles for msal-common and msal-browser linked to PR #8869.
@PingaleSampada
Sampada (PingaleSampada) marked this pull request as ready for review September 25, 2026 18:24
@PingaleSampada

Copy link
Copy Markdown
Contributor Author

Addressed both Copilot findings in 9f6f52d38: auth-scheme access tokens are now client-bound for broadcast validation, and msal-node hyphen-separated credential keys use credential-type-anchored owner matching. Added focused regressions for both cases; full package validation is green locally.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved critical legacy-key validation and additional coverage/documentation issues remain.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 1 Medium severity

Open (2)
Resolved since last review (2)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved owner-matching and broadcast-validation issues could allow incorrect cache entries or miss valid keys.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (2)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Hyphen-delimited owner matching can produce false positives, and new helpers lack required documentation.

Review effort: Lite
Findings: None

Resolved since last review (1)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

A critical legacy-key ownership validation issue remains unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)

Sampada added 2 commits September 28, 2026 16:49
Validate structured credential cache keys by their owner segment and reject contextless client-bound cache broadcasts.
Add patch changefiles for msal-common and msal-browser linked to PR #8869.
Sampada added 5 commits September 28, 2026 16:49
@PingaleSampada
Sampada (PingaleSampada) force-pushed the spingale-microsoft-cache-client-context-validation branch from b37120c to 73fd2ce Compare September 28, 2026 23:49
shylasummers
shylasummers previously approved these changes Sep 29, 2026
Treat BroadcastChannel messages as cache update notifications instead of trusted token values. Preserve client-aware routing, synchronize removals, guard asynchronous reload races, and keep encryption context compatible with existing cache entries.
Restore the existing getContext helper name and explicitly handle rejected broadcast cache updates.
@PingaleSampada
Sampada (PingaleSampada) merged commit 08a044d into dev Sep 29, 2026
77 checks passed
@PingaleSampada
Sampada (PingaleSampada) deleted the spingale-microsoft-cache-client-context-validation branch September 29, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentic-ide Copilot IDE / editor agent drove the bulk of actions bug A problem that needs to be fixed for the feature to function as intended.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants