Skip to content

fix: add output encoding in CustomUserSession.cs - #6

Open
anupamme wants to merge 1 commit into
NetCoreTemplates:mainfrom
anupamme:fix-repo-blazor-vue-api-key-exposure-in-auth-cookie
Open

fix: add output encoding in CustomUserSession.cs#6
anupamme wants to merge 1 commit into
NetCoreTemplates:mainfrom
anupamme:fix-repo-blazor-vue-api-key-exposure-in-auth-cookie

Conversation

@anupamme

Copy link
Copy Markdown

Summary

Fix critical severity security issue in MyApp.ServiceInterface/Data/CustomUserSession.cs.

Vulnerability

Field Value
ID V-001
Severity CRITICAL
Scanner multi_agent_ai
Rule V-001
File MyApp.ServiceInterface/Data/CustomUserSession.cs:38
Assessment Likely exploitable
CWE CWE-79
Chain Complexity 3-step

Description: The application stores raw API keys in the Identity Auth Cookie by adding them as claims in the AdditionalUserClaimsPrincipalFactory. The API key is retrieved from the database and directly embedded into the authentication cookie, which is then serialized and sent to the client. This exposes the API key to any process that can read the cookie (browser extensions, XSS attacks, or cookie theft via session hijacking).

Evidence

Exploitation scenario: An attacker who can steal the authentication cookie (via XSS, MITM on non-HTTPS connections, or browser compromise) can extract the API key from the cookie claims.

Scanner confirmation: multi_agent_ai rule V-001 flagged this pattern.

Production code: This file is in the production codebase, not test-only code.

Changes

  • MyApp.ServiceInterface/Data/CustomUserSession.cs

Behavior Preservation

The change is scoped to 1 file on the vulnerable path; it only tightens handling of untrusted input and leaves valid inputs unaffected.


Automated security fix by OrbisAI Security

Automated security fix generated by OrbisAI Security
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant