DEV Community

SorrelThorncroft
SorrelThorncroft

Posted on

LightRAG API-Key Mode Still Accepted Guest Tokens Minted With a Public Default Secret

LightRAG API-Key Mode Still Accepted Guest Tokens Minted With a Public Default Secret

LightRAG can require an X-API-Key for its HTTP API. A deployment may treat that as a clear authentication boundary. The GitHub security advisory GHSA-f4vv-55c2-5789 describes an API-key-only profile where a public endpoint and a hardcoded JWT default provide a second way past the check.

The advisory lists versions up to 1.4.15 as affected and no patched versions.

The three-part failure

The code ships a default JWT secret. When LIGHTRAG_API_KEY is set but AUTH_ACCOUNTS is unset, the authentication handler falls back to that default secret and logs a warning. The public GET /auth-status and POST /login endpoints can then mint a guest JWT without authentication.

The combined authorization dependency accepts that guest token before reaching the X-API-Key comparison. An attacker can therefore create a token locally with a secret published in the repository, or obtain one from the application's public login path, and then call endpoints protected by the combined dependency.

The advisory names destructive operations including DELETE /documents, POST /documents/upload, /documents/clear_cache and POST /query. Access to those routes means an attacker can remove indexed data, insert content, trigger processing or query the knowledge base.

Why the API key does not help

The API-key check is present, but it is not the first authorization decision in this deployment profile. A token with the guest role reaches an early return. That is a fail-open path created by the interaction between configuration options.

Changing the API key alone does not remove the default signing secret. Rotating the key can invalidate one credential while leaving the guest-token path active. Administrators need to verify both the configured authentication mode and the code path that handles the request.

What to inspect

Search LightRAG configurations for LIGHTRAG_API_KEY and AUTH_ACCOUNTS. A deployment with an API key and no account configuration matches the advisory's affected profile. Check whether TOKEN_SECRET is set to a unique random value.

Review access logs for requests to /auth-status and /login, especially those followed by document changes or queries. A successful API call may not contain an X-API-Key header. Look for guest tokens, unusual document identifiers and changes to indexed sources.

Mitigation

The advisory lists no patched release. Remove direct network access to the LightRAG API, require authentication at a trusted reverse proxy and disable the API-key-only mode until a fixed build is verified. Configure AUTH_ACCOUNTS and a strong, unique TOKEN_SECRET where the deployment supports it.

Rotate the API key, signing secret and any credentials available to the service. Clear exposed documents only after preserving the evidence needed for investigation. Rebuild the index from trusted sources if an attacker modified or deleted documents.

Verification

Test a request with a forged guest JWT and no API key. It should be rejected before the protected route runs. Test the public login endpoint separately and confirm that it cannot mint a usable token for an untrusted caller. Then repeat the checks after every configuration change, because the issue depends on a combination of settings.

References

Top comments (0)