lightrag-hku
Affected
- introduced
0, fixed1.5.5(ecosystem)
Fixed versions
1.5.5
Fix
- Fixed version
1.5.5pip install --upgrade lightrag-hku==1.5.5
Advisory
Also known as: CVE-2026-85709, PYSEC-2026-4063
lightrag-hku: Sensitive Information Exposure Through Raw Exception Messages in API Error Responses
Summary
The LightRAG API server passes raw Python exception messages directly into HTTP
error responses across 30+ error handlers in every router. When combined with
the default unauthenticated configuration (see companion report on CWE-306), any
network-reachable client can trigger exceptions whose raw text discloses
internal infrastructure — server filesystem paths, database host/port/user, LLM
provider error details, and Python library internals. No global exception
handler sanitizes error messages before they reach the client.
Details
Throughout the API route handlers, exceptions are caught and their string
representation is returned verbatim via detail=str(e) / detail=str(exc)
(and f-string variants such as detail=f"...: {str(e)}"). This occurs in every
router file. Location breakdown on the current main branch:
HTTP 500 — raw exception passthrough (`except Exception as e`):
document_routes.py — 13graph_routes.py — 12 (mix of detail=f"...{str(e)}" and detail=error_msg)query_routes.py — 3ollama_api.py — 2lightrag_server.py — 1 (health endpoint)HTTP 422 — raw exception passthrough (`except ValueError as exc`):
document_routes.py — 2 (chunking-config validation)Total: ~33 raw-exception-to-HTTP-response locations. The only pre-existing
custom exception handler in lightrag_server.py is specific toRequestValidationError for /query/data; it does not cover the genericException handlers in route code.
Example pattern (document_routes.py, upload handler):
except Exception as e:
logger.error(f"Error /documents/upload: {file.filename}: {str(e)}")
raise HTTPException(status_code=500, detail=str(e))
Categories of sensitive information that can leak through these responses:
[Errno 13] Permission denied: '/app/data/rag_storage/default/kv_store_full_docs.json'), aiding path-traversal or targeted attacks. *(Verified — see PoC Step 1.)*password authentication failed for user "lightrag" (username) or a socket error naming the unreachable host and port. Note on credentials: the PostgreSQL backend uses asyncpg, which is built from keyword parameters and does not echo the password in its exception strings — so a raw asyncpg error leaks host/port/user/db, not the password. URI-configured backends behave differently: the MongoDB backend is built with AsyncMongoClient(MONGO_URI, ...), and a malformed-URI / configuration error from pymongo can surface the connection string itself, which may embed credentials (mongodb://user:password@host:port/). The leak surface is therefore backend- and error-type-dependent.The risk is amplified by the default unauthenticated configuration (CWE-306,
companion report), which lets any network client trigger and read these errors
without credentials.
PoC
Tested on a clean checkout with the [api] extras installed and the server run
via lightrag-server.
Step 1 — Filesystem path disclosure (default JSON storage)
With the default storage backend, a file-permission error is returned verbatim:
# Make a storage file unreadable to force an I/O error.
chmod 000 ./rag_storage/default/kv_store_full_docs.json
curl -s http://localhost:9621/documents | python3 -m json.tool
Vulnerable response — the full server-side path is disclosed:
{
"detail": "[Errno 13] Permission denied: '/app/data/rag_storage/default/kv_store_full_docs.json'"
}
Step 2 — Database infrastructure disclosure (PostgreSQL backend)
Configure a PostgreSQL KV backend pointed at an unreachable / misconfigured host:
LIGHTRAG_KV_STORAGE=PGKVStorage
POSTGRES_HOST=nonexistent-host-12345.example.com
POSTGRES_PORT=5432
POSTGRES_USER=lightrag
POSTGRES_DATABASE=lightrag
A request that touches storage returns the raw connection error, disclosing the
host / port / user the server is configured to reach (the asyncpg password is
not echoed — see the credentials note above):
{
"detail": "[Errno -2] Name or service not known"
}
For a URI-configured backend such as MongoDB (MONGO_URI=mongodb://user:pass@host:port/db),
a malformed-URI / configuration error can instead surface the connection string
itself, including any embedded credentials.
Impact
Error-message information exposure. A client able to reach the LightRAG
server can extract:
When combined with the default unauthenticated configuration, any
network client can trigger and read these responses without authentication,
which is why this is scored PR:N.
Suggested remediation
except Exception as e:
logger.error(f"Error /documents/upload: {file.filename}: {e!r}")
raise HTTPException(status_code=500, detail="Internal server error")
@app.exception_handler(Exception)
async def unhandled_exception_handler(request, exc):
logger.error(f"Unhandled exception: {exc!r}", exc_info=True)
return JSONResponse(status_code=500, content={"detail": "Internal server error"})
Fix status: implemented in HKUDS/LightRAG#3422 — a sharedinternal_server_error() helper routes all 500 handlers through a generic body
carrying a correlation id (full detail logged server-side), a global@app.exception_handler(Exception) is registered in create_app, and the two
422 validators are wrapped.
Medium Basis: The source's own band: MODERATE
0, fixed 1.5.5 (ecosystem)1.5.5
1.5.5pip install --upgrade lightrag-hku==1.5.5Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0