Skip to content

security: add API key authentication to all API endpoints#437

Open
aaniya22 wants to merge 2 commits into
utksh1:mainfrom
aaniya22:security/api-key-auth-266
Open

security: add API key authentication to all API endpoints#437
aaniya22 wants to merge 2 commits into
utksh1:mainfrom
aaniya22:security/api-key-auth-266

Conversation

@aaniya22
Copy link
Copy Markdown
Contributor

Fixes #266

Every API endpoint was reachable without any credential. An attacker
with access to the backend port could read vault secrets, wipe scan
history, or start arbitrary scans.

Changes:

  • Added backend/secuscan/auth.py with require_api_key dependency
  • On first startup, if SECUSCAN_API_KEY is not set, a random 64-char
    hex key is generated, saved to data/api_key.txt, and logged once
  • Every request to /api/v1/* must supply the key as:
    Authorization: Bearer <key> or X-Api-Key: <key>
  • /api/v1/health, /docs, /redoc, / remain public
  • Added SECUSCAN_API_KEY to config.py and documented in .env.example

No breaking change for users who set SECUSCAN_API_KEY in their env.
Users without it get a key auto-generated and logged on first run.

@utksh1 utksh1 added level:critical 80 pts difficulty label for critical or high-impact PRs type:security Security work category bonus label type:feature Feature work category bonus label area:frontend Frontend React/UI work area:backend Backend API, database, or service work area:security Security-sensitive implementation or tests labels May 31, 2026
Copy link
Copy Markdown
Owner

@utksh1 utksh1 left a comment

Choose a reason for hiding this comment

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

Thanks for working on API auth. This cannot merge as-is: backend-tests are failing, the frontend/API client has no credential flow so the app would start sending unauthenticated requests, and generating/logging an API key from inside the backend is not an operator-safe rollout path. Please restore green checks, add frontend/client integration and docs, keep health/public endpoints intentional, and avoid logging secrets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend Backend API, database, or service work area:frontend Frontend React/UI work area:security Security-sensitive implementation or tests level:critical 80 pts difficulty label for critical or high-impact PRs type:feature Feature work category bonus label type:security Security work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Security] No Authentication on Any API Endpoint — Vault Secrets and Destructive Operations Fully Exposed

2 participants