You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
security: unauthenticated HTTP API endpoints expose database queries and index operations #1008
The FastAPI router in src/codegraphcontext/api/router.py exposes several management and query endpoints—including /index, /query (proxying to execute_cypher_query), and /tools/call—without any authentication middleware.
Anyone with network access to the API port can execute arbitrary Cypher queries (and bypass the regex blocklist), start arbitrary indexing jobs on the host, or call backend MCP tools, which presents a critical security risk.
Where it is:
File: src/codegraphcontext/api/router.py
Function/Section: All route definitions (e.g., /index, /query, /tools/call)
Why it matters:
An unauthenticated API allows arbitrary actors to execute Cypher queries against the database, trigger indexing jobs on the host, or call internal tools, leading to potential data exposure and unauthorized actions.
Steps to reproduce / observe:
Start the FastAPI server (e.g. running the visualizer or API).
Perform a POST request to http://localhost:<port>/api/v1/query with an empty or custom Cypher payload from a separate terminal without supplying any auth headers.
Observe that the API processes the request successfully.
Suggested direction:
Introduce an API key or Token-based authentication layer. Read a secure token from configuration (config.yaml or .env), validate it in a FastAPI dependency (e.g., checking the Authorization header), and return 401 Unauthorized for invalid or missing keys. We can auto-generate a secure token on first run if none is set.
I would like to work on this issue. I propose implementing a security dependency/middleware in FastAPI using HTTPBearer or a custom header checker. This dependency will read a secure API token/key from the configuration (config.yaml or .env), validate incoming requests on all router endpoints (excluding health checks if appropriate), and return a 401 Unauthorized response on validation failure. I'll also implement a startup hook that generates a secure default key if none exists. Please assign this issue to me.
Activity
github-actions commentedon May 28, 2026
Hi! 👋 Join our CodeGraphContext Discord channel to collaborate: https://discord.gg/dR4QY32uYQ
shreyasfegade commentedon May 28, 2026
I would like to work on this issue. I propose implementing a security dependency/middleware in FastAPI using
HTTPBeareror a custom header checker. This dependency will read a secure API token/key from the configuration (config.yamlor.env), validate incoming requests on all router endpoints (excluding health checks if appropriate), and return a401 Unauthorizedresponse on validation failure. I'll also implement a startup hook that generates a secure default key if none exists. Please assign this issue to me.srinithithirumaran commentedon May 29, 2026
Hi, I would like to work on this issue under GSSoC 2026. Could you please assign it to me?
Shashankss1205 commentedon Jun 1, 2026
Heyyy @shreyasfegade go ahead!
@srinithithirumaran can you please create or work on other issue?
feat(security): optional API key auth for HTTP endpoints (#1008) (#1406)
Improve progress bar handling during repository indexing (#1219)