Skip to content

Security: Sensitive AI provider API keys stored in localStorage#1166

Open
tuanaiseo wants to merge 1 commit intozuiidea:masterfrom
tuanaiseo:contribai/fix/security/sensitive-ai-provider-api-keys-stored-in
Open

Security: Sensitive AI provider API keys stored in localStorage#1166
tuanaiseo wants to merge 1 commit intozuiidea:masterfrom
tuanaiseo:contribai/fix/security/sensitive-ai-provider-api-keys-stored-in

Conversation

@tuanaiseo
Copy link
Copy Markdown

Problem

AI provider credentials (including apiKey) are persisted in localStorage via saveAISettings. Any XSS in the application or third-party script execution can read and exfiltrate these secrets. localStorage is not appropriate for long-lived sensitive tokens/keys.

Severity: high
File: src/pages/ai/aiConfig.ts

Solution

Do not store raw API keys in browser localStorage. Move model-provider calls behind a backend proxy and keep provider secrets server-side. If client-side storage is unavoidable, reduce risk with short-lived scoped tokens, strict CSP, and avoid persisting secrets at rest.

Changes

  • src/pages/ai/aiConfig.ts (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

AI provider credentials (including `apiKey`) are persisted in `localStorage` via `saveAISettings`. Any XSS in the application or third-party script execution can read and exfiltrate these secrets. localStorage is not appropriate for long-lived sensitive tokens/keys.

Affected files: aiConfig.ts

Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 10, 2026

@tuanaiseo is attempting to deploy a commit to the Zui Idea's projects Team on Vercel.

A member of the Team first needs to authorize it.

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