Skip to content
DoS Disclosed report Beginner

CPU Exhaustion via Crafted TOML Files in translation-finder

The translation-finder library's TOML format check reads files character by character, so a TOML file with a very long single line takes about 0.1 seconds to process. An attacker can include about 64 such files in a repository, causing tools like Weblate that scan repositories to spend around 7 seconds of CPU time per scan instead of milliseconds.

visionx7 Follow

Originally disclosed on HackerOne

Medium 5.3 View original
  • Fixed in 42 hours
  • Disclosed after 37 days

The translation-finder library has a function that checks TOML files to see if they are go-i18n format files. This function reads the file one character at a time in a loop. If a TOML file has one very long line (around 1 MB), this check takes about 0.1 to 0.15 seconds to run.

An attacker can create a repository with about 64 files like this. When a tool like Weblate scans this repository using discover(), it takes about 7 seconds to finish, instead of a few milliseconds. The built in budget system limits the damage to around 7 to 8 seconds per scan, but this cost is easy to trigger and repeat.

Affected project: WeblateOrg/translation-finder Affected version: 3.7.1 Affected commit: aa9017b412c521ca794564bf3e1bfa4e2b3c280b Affected file: translation_finder/discovery/files.py Affected functions: _toml_line_code() and _is_go_i18n_toml()

Steps to Reproduce

Environment used: Python 3 (fish shell), local clone of the repository, installed with pip install -e .

Step 1: Clone the repository and confirm the commit

Bash
git clone https://github.com/WeblateOrg/translation-finder.git
cd translation-finder
git log -1
pip install -e . --break-system-packages

Step 2: Run a baseline test with a normal, small repository

FISH
set -x PYTHONPATH .
 
time python3 -c "
import tempfile, time
from pathlib import Path
from translation_finder.api import discover
 
with tempfile.TemporaryDirectory() as tmpdir:
    root = Path(tmpdir)
    for i in range(5):
        d = root / f'proj{i}'
        d.mkdir()
        (d / 'en.po').write_text('msgid \"a\"\nmsgstr \"b\"\n')
    t0 = time.time()
    results = discover(str(root))
    print(f'BASELINE elapsed: {time.time()-t0:.4f}s, results: {len(results)}')
"

This finishes in a few milliseconds. This is the normal, expected speed.

Step 3: Run the crafted repository test

Create 64 folders. Each folder has one TOML file with a single line about 1 MB long.

FISH
set -x PYTHONPATH .
 
time python3 -c "
import tempfile, time
from pathlib import Path
from translation_finder.api import discover
 
with tempfile.TemporaryDirectory() as tmpdir:
    root = Path(tmpdir)
    big_toml = '\"' + 'x' * (1024 * 1024 - 10) + '\"'
    for i in range(64):
        d = root / f'proj{i}'
        d.mkdir()
        (d / 'en.toml').write_text(big_toml)
        (d / 'fr.toml').write_text('\"hello\"')
    t0 = time.time()
    results = discover(str(root))
    elapsed = time.time() - t0
    print(f'MALICIOUS REPO elapsed: {elapsed:.2f}s, results: {len(results)}')
"

Result: elapsed time of about 7.16 seconds, instead of a few milliseconds. The usr time is almost equal to real time, which shows the CPU is busy the whole time, not waiting on disk or network.

Step 4: Confirm the delay does not grow with a bigger repository

Repeat Step 3 but use 200 folders instead of 64.

Result: elapsed time of about 7.20 seconds, almost the same as Step 3 with only 64 folders. This shows the delay is capped by the tool's own internal budget, not by how big the malicious repository is. This means an attacker does not need a large repository. A small one with about 64 crafted files is enough to cause the full delay.

Step 5: Confirm the exact function causing the delay

FISH
set -x PYTHONPATH .
 
python3 -c "
import time
from translation_finder.discovery.files import _is_go_i18n_toml
 
big_toml = '\"' + 'x' * (1024 * 1024 - 10) + '\"'
t0 = time.time()
result = _is_go_i18n_toml(big_toml)
elapsed = time.time() - t0
print(f'_is_go_i18n_toml() time: {elapsed:.3f}s, result={result}')
"

Result: about 0.119 seconds for one file. Multiplied by 64 files, this is close to the total delay seen in Step 3 and Step 4. This confirms the delay comes from this one function.

POC Evidence (Screenshots)

File What it shows
01-setup-commit-and-install.png Repository cloned, exact commit confirmed, install successful
02-baseline-legit-repo.png Normal repository scan finishes in milliseconds
03-crafted-toml-runtime.png Crafted repository (64 files) takes about 7.16 seconds, CPU bound
04-amplification-200-dirs.png Crafted repository with 200 files still takes about 7.20 seconds, confirms budget cap
05-isolated-root-cause.png Single function call takes 0.119s, confirms the exact root cause

Impact

  • A repository with about 64 crafted TOML files causes the discover() function to take about 7 to 8 seconds, instead of milliseconds.
  • discover() is meant to be used by tools like Weblate to scan repositories automatically, for example when a new repository or component is added, or when a repository is scanned again after a push.
  • An attacker only needs to add a small number of large, single line TOML files to a repository. They do not need write access to the server, only the ability to get their repository content scanned (for example, by submitting it as a project, or contributing to a repository that gets rescanned).
  • If this scan runs often, for example on every push or every scheduled scan, this becomes a repeatable way to waste CPU time on the server doing the scanning.
  • This is a CPU exhaustion issue. It does not read files outside the repository, does not leak data, and does not allow code execution. The damage is limited by the tool's own budget system to around 7 to 8 seconds per scan.

Remediation

The root cause is in _toml_line_code(). This function reads a line of text one character at a time in a Python loop. For very long lines, this becomes slow because there is no limit on how long a single line can be before the function starts working on it.

Suggested fix 1: Add a maximum line length check before running the character by character scan. If any line in the file is longer than a reasonable limit (for example, 4096 characters), skip the TOML check for that file. Normal go-i18n TOML files do not have single lines that are 1 MB long.

Suggested fix 2: Replace the manual character by character loop with a faster method, such as using regular expressions or built in string search functions, so that scanning long lines does not cost as much CPU time.

Attachments

01-setup-commit-and-install.png
01-setup-commit-and-install.png From the original on HackerOne
02-baseline-legit-repo.png
02-baseline-legit-repo.png
03-crafted-toml-runtime.png
03-crafted-toml-runtime.png
04-amplification-200-dirs.png
04-amplification-200-dirs.png
05-isolated-root-cause.png
05-isolated-root-cause.png

The original report as published on HackerOne, by visionx7. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 8 min read.

Context

translation-finder is a library in the WeblateOrg GitHub organisation. Its job is to look at a repository and work out which files are translation files and which format they use, so that a tool such as Weblate can set up components automatically. The public entry point used in this report is discover(), from translation_finder.api.

One of the formats it recognises is go-i18n TOML. To decide whether a TOML file is a go-i18n file, the library calls _is_go_i18n_toml(), which in turn uses _toml_line_code(). The report identifies the affected file as translation_finder/discovery/files.py and the affected functions as _toml_line_code() and _is_go_i18n_toml().

The weakness is uncontrolled resource consumption: the format check reads a file one character at a time in a Python loop, so a single very long line makes the check expensive. Because discover() walks a whole repository, an attacker who controls repository content can multiply that cost across many files.

Setup

The researcher worked against a local clone of the repository, on Python 3, using the fish shell, and installed the package in editable mode. The affected version is 3.7.1 and the affected commit is [redacted].

No account, role or server-side access is needed to reproduce the issue: the whole demonstration runs locally against the library. The precondition for the real-world attack is only that the attacker can get repository content scanned by a tool that uses discover(), for example by submitting a project or contributing to a repository that is rescanned.

Finding it

The go-i18n TOML check reads the file one character at a time in a loop. That makes the cost of the check proportional to line length rather than to file size in any useful sense: a TOML file containing one very long line of around 1 MB takes about 0.1 to 0.15 seconds for the check alone.

That number is small on its own, but discover() processes many files in a repository. If each file carries a long line, the per-file cost adds up.

Exploitation

Step 1: Clone the repository and confirm the commit

Bash
git clone https://github.com/WeblateOrg/translation-finder.git
cd translation-finder
git log -1
pip install -e . --break-system-packages

This clones the project, prints the checked-out commit so it can be matched against the affected commit, and installs the package in editable mode so the local source is what gets imported.

01-setup-commit-and-install.png
01-setup-commit-and-install.png From the original on HackerOne

The screenshot shows the repository cloned, the exact commit confirmed and the install succeeding.

Step 2: Baseline with a normal, small repository

FISH
set -x PYTHONPATH .

time python3 -c "
import tempfile, time
from pathlib import Path
from translation_finder.api import discover

with tempfile.TemporaryDirectory() as tmpdir:
    root = Path(tmpdir)
    for i in range(5):
        d = root / f'proj{i}'
        d.mkdir()
        (d / 'en.po').write_text('msgid \"a\"\nmsgstr \"b\"\n')
    t0 = time.time()
    results = discover(str(root))
    print(f'BASELINE elapsed: {time.time()-t0:.4f}s, results: {len(results)}')
"

The script builds a temporary directory with five project folders, each holding a small en.po file, then times a single discover() call over the root. This finishes in a few milliseconds, which the researcher records as the normal, expected speed.

02-baseline-legit-repo.png
02-baseline-legit-repo.png From the original on HackerOne

The screenshot shows the normal repository scan finishing in milliseconds.

Step 3: Crafted repository with 64 files

FISH
set -x PYTHONPATH .

time python3 -c "
import tempfile, time
from pathlib import Path
from translation_finder.api import discover

with tempfile.TemporaryDirectory() as tmpdir:
    root = Path(tmpdir)
    big_toml = '\"' + 'x' * (1024 * 1024 - 10) + '\"'
    for i in range(64):
        d = root / f'proj{i}'
        d.mkdir()
        (d / 'en.toml').write_text(big_toml)
        (d / 'fr.toml').write_text('\"hello\"')
    t0 = time.time()
    results = discover(str(root))
    elapsed = time.time() - t0
    print(f'MALICIOUS REPO elapsed: {elapsed:.2f}s, results: {len(results)}')
"

The payload is big_toml: a double quote, then x repeated 1024 * 1024 - 10 times, then a closing double quote. That produces a single TOML line of roughly 1 MB. The script creates 64 project folders, each with one such en.toml and a tiny fr.toml containing "hello", then times discover() over the root.

The result is an elapsed time of about 7.16 seconds instead of a few milliseconds. The researcher also notes that usr time is almost equal to real time, which shows the CPU is busy for the whole run rather than waiting on disk or network.

03-crafted-toml-runtime.png
03-crafted-toml-runtime.png From the original on HackerOne

The screenshot shows the crafted repository with 64 files taking about 7.16 seconds, CPU bound.

Step 4: Confirm the delay does not grow with a bigger repository

The same test is repeated with 200 folders instead of 64.

The result is about 7.20 seconds, almost identical to the 64-folder run. That shows the delay is capped by the tool's own internal budget rather than by repository size. The practical consequence is that an attacker does not need a large repository: a small one with about 64 crafted files is enough to trigger the full delay.

04-amplification-200-dirs.png
04-amplification-200-dirs.png From the original on HackerOne

The screenshot shows the 200-file crafted repository still taking about 7.20 seconds, confirming the budget cap.

Step 5: Isolate the function responsible

FISH
set -x PYTHONPATH .

python3 -c "
import time
from translation_finder.discovery.files import _is_go_i18n_toml

big_toml = '\"' + 'x' * (1024 * 1024 - 10) + '\"'
t0 = time.time()
result = _is_go_i18n_toml(big_toml)
elapsed = time.time() - t0
print(f'_is_go_i18n_toml() time: {elapsed:.3f}s, result={result}')
"

This calls the format check directly on the same 1 MB single-line string, bypassing discover() and the filesystem. The result is about 0.119 seconds for one file. Multiplied by 64 files, that is close to the total delay seen in Steps 3 and 4, which confirms the delay comes from this one function.

05-isolated-root-cause.png
05-isolated-root-cause.png From the original on HackerOne

The screenshot shows a single function call taking 0.119s, confirming the exact root cause.

Root cause

The root cause is in _toml_line_code(). It reads a line of text one character at a time in a Python loop. For very long lines this is slow because there is no limit on how long a single line can be before the function starts working on it. _is_go_i18n_toml() calls into that routine, so every TOML file with a long line pays the cost during discovery.

The library's budget system does limit the total damage to around 7 to 8 seconds per scan, which is why the 200-folder run is no slower than the 64-folder run. That defence bounds a single scan but does not prevent the cost from being triggered, and the cost is easy to trigger and repeat.

Impact

  • A repository with about 64 crafted TOML files makes discover() take about 7 to 8 seconds instead of milliseconds.
  • discover() is meant to be used by tools such as Weblate to scan repositories automatically, for example when a new repository or component is added, or when a repository is rescanned after a push.
  • The attacker only needs to add a small number of large, single-line TOML files to a repository. They do not need write access to the server, only the ability to get their repository content scanned, for example by submitting it as a project or contributing to a repository that gets rescanned.
  • If the scan runs often, for example on every push or every scheduled scan, this becomes a repeatable way to waste CPU time on the scanning server.
  • The issue is CPU exhaustion only. It does not read files outside the repository, does not leak data and does not allow code execution. The damage is limited by the tool's own budget system to around 7 to 8 seconds per scan.

Fix

The report proposes two fixes, both aimed at _toml_line_code():

  1. Add a maximum line length check before running the character-by-character scan. If any line in the file is longer than a reasonable limit, for example 4096 characters, skip the TOML check for that file. Normal go-i18n TOML files do not have single lines that are 1 MB long.
  2. Replace the manual character-by-character loop with a faster method, such as regular expressions or built-in string search functions, so that scanning long lines does not cost as much CPU time.

The report does not state which of these was applied, or whether the library was changed at all.

Variants to test

  • Other format detectors in the same library. Any check that walks a file character by character, or otherwise scales with line length, is a candidate. A positive result is a single crafted file whose detection time is far above the milliseconds a normal file takes.
  • Other TOML-shaped inputs. The report's payload is a quoted 1 MB string; try long unquoted values, long keys, long comments and long arrays, and compare per-file timing. A positive result is any shape that reproduces the roughly 0.1 second per-file cost.
  • File-count thresholds. The report shows 64 files producing about 7.16 seconds and 200 files about 7.20 seconds. Try smaller counts to find the minimum that still produces the full delay on a given deployment.
  • Repeated scans. Where a platform rescans on every push or on a schedule, measure whether the delay is paid on each scan. A positive result is a consistent multi-second cost per scan from a small repository.
  • Other consumers of discover(). Any tool that scans untrusted repository content automatically is exposed in the same way; check whether the scan runs synchronously in a request path or in a background worker, since that changes who feels the CPU cost.

Hunting notes

This class of bug hides in parsing and format-detection code that runs over untrusted content: file type sniffers, importers, linters and anything that decides "is this file format X". The signal during recon is a code path that processes a file character by character, or otherwise has cost proportional to line length, combined with an entry point that walks many files automatically.

The researcher did four things. First, a baseline on a normal repository, so the milliseconds figure is measured rather than assumed. Second, a crafted repository at realistic scale, with the CPU-bound nature confirmed by comparing usr time with real time. Third, a scaling test at 200 folders to show the budget cap and to prove a small repository is sufficient. Fourth, an isolated call to the suspected function, whose per-file time multiplied by the file count matches the end-to-end delay.

The report is explicit about what the bug is not: no file read outside the repository, no data leak, no code execution.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 16 min read.

What happened, in plain words

Weblate is a service that helps people translate software. You point it at a code repository (a folder of project files stored on a service such as GitHub), and it works out which files contain text that needs translating and what format those files use. To do that, Weblate uses a helper library called translation-finder.

A security researcher found that one of the checks inside translation-finder is very slow when it meets a file containing one extremely long line of text. A single such file costs about a tenth of a second. That sounds tiny, but the library scans a whole repository, so an attacker who can get a repository scanned can put about 64 of these files in it and make the scan take around 7 seconds instead of a few milliseconds.

The library has a built-in limit (a "budget") that stops a scan after roughly 7 to 8 seconds, so the damage per scan is capped. But the cost is easy to trigger and easy to repeat, for example every time the repository is pushed to and rescanned. The report calls this uncontrolled resource consumption: the software uses far more of a resource (here, processor time) than it should, because it does not limit how much work it accepts. CVSS is a standard scoring system for how serious a security flaw is.

Nothing is stolen, no data leaks and no attacker code runs. The problem is wasted computer time.

Context

translation-finder is a library (a reusable piece of code other programs can call) in the WeblateOrg GitHub organisation. Its job is to look at a repository and work out which files are translation files and which format they use, so that a tool such as Weblate can set up components automatically. A "component" in Weblate is one translatable part of a project.

The public entry point used in this report is discover(), from translation_finder.api. An entry point is simply the function you call to start the work; think of it as the front door of the library. discover() is the function that walks through a repository and inspects the files.

One of the formats it recognises is go-i18n TOML. TOML is a plain-text configuration file format, a bit like a simple list of settings. go-i18n is a translation tool for the Go programming language, and it stores translations in TOML files. To decide whether a TOML file is a go-i18n file, the library calls _is_go_i18n_toml(), which in turn uses _toml_line_code(). The report identifies the affected file as translation_finder/discovery/files.py and the affected functions as _toml_line_code() and _is_go_i18n_toml().

The weakness is uncontrolled resource consumption: the format check reads a file one character at a time in a Python loop. A loop is code that repeats an action; here it repeats "read the next character" for every character in the line. A single very long line therefore makes the check expensive. Because discover() walks a whole repository, an attacker who controls repository content can multiply that cost across many files.

Setup

The researcher worked against a local clone of the repository, on Python 3, using the fish shell, and installed the package in editable mode. A "clone" is a full local copy of a repository. Python 3 is the programming language the library is written in. The fish shell is a program for typing commands into a computer (other systems use bash or zsh). "Editable mode" means the installed package points at the local copy of the source code, so any change you make locally is what actually runs.

The affected version is 3.7.1 and the affected commit is [redacted]. A commit is a saved snapshot of a repository, identified by a long code like that one; it lets everyone talk about exactly the same version of the code.

No account, role or server-side access is needed to reproduce the issue: the whole demonstration runs locally against the library. The precondition for the real-world attack is only that the attacker can get repository content scanned by a tool that uses discover(), for example by submitting a project or contributing to a repository that is rescanned.

Finding it

The go-i18n TOML check reads the file one character at a time in a loop. That makes the cost of the check grow with line length rather than with anything useful: a TOML file containing one very long line of around 1 MB takes about 0.1 to 0.15 seconds for the check alone. 1 MB is about one million characters, roughly the length of a short novel.

That number is small on its own, but discover() processes many files in a repository. If each file carries a long line, the per-file cost adds up.

Exploitation

Step 1: Clone the repository and confirm the commit

Bash
git clone https://github.com/WeblateOrg/translation-finder.git
cd translation-finder
git log -1
pip install -e . --break-system-packages

Line by line:

  1. git clone https://github.com/WeblateOrg/translation-finder.git downloads a full copy of the project from GitHub into a new folder. Git is the version-control tool that stores code history.
  2. cd translation-finder moves you into that new folder, so the following commands act on it.
  3. git log -1 shows the most recent commit, so you can check it matches the affected commit [redacted]. This matters because a bug report is only meaningful if everyone tests the same version of the code.
  4. pip install -e . --break-system-packages installs the package from the current folder (.) in editable mode (-e). pip is Python's package installer. --break-system-packages tells pip to go ahead even though the operating system normally prefers you not to install packages this way; it is a convenience for a test machine.
01-setup-commit-and-install.png
01-setup-commit-and-install.png From the original on HackerOne

The screenshot shows the repository cloned, the exact commit confirmed and the install succeeding.

Step 2: Baseline with a normal, small repository

FISH
set -x PYTHONPATH .

time python3 -c "
import tempfile, time
from pathlib import Path
from translation_finder.api import discover

with tempfile.TemporaryDirectory() as tmpdir:
    root = Path(tmpdir)
    for i in range(5):
        d = root / f'proj{i}'
        d.mkdir()
        (d / 'en.po').write_text('msgid \"a\"\nmsgstr \"b\"\n')
    t0 = time.time()
    results = discover(str(root))
    print(f'BASELINE elapsed: {time.time()-t0:.4f}s, results: {len(results)}')
"

Line by line:

  1. set -x PYTHONPATH . tells the fish shell to make the current folder available to Python as a place to find modules, and to print each command as it runs. PYTHONPATH is an environment variable, a named setting the operating system passes to programs.
  2. time python3 -c "..." runs Python with the code given directly on the command line, and time measures how long it takes.
  3. import tempfile, time loads two standard Python modules: one for creating temporary folders and one for measuring time.
  4. from pathlib import Path loads a helper for working with file paths.
  5. from translation_finder.api import discover loads the function under test.
  6. with tempfile.TemporaryDirectory() as tmpdir: creates a temporary folder that is deleted automatically afterwards, and names it tmpdir.
  7. root = Path(tmpdir) turns that name into a path object.
  8. for i in range(5): repeats the next lines five times, with i going 0 to 4.
  9. d = root / f'proj{i}' builds a folder name such as proj0 inside the temporary folder.
  10. d.mkdir() creates that folder.
  11. (d / 'en.po').write_text('msgid \"a\"\nmsgstr \"b\"\n') writes a tiny translation file in the .po format, which is a common format for translation files. \n means a line break.
  12. t0 = time.time() records the start time.
  13. results = discover(str(root)) runs the library's scan over the whole temporary folder.
  14. print(...) prints the elapsed time, rounded to four decimal places, and how many results came back.

The script builds a temporary directory with five project folders, each holding a small en.po file, then times a single discover() call over the root. This finishes in a few milliseconds, which the researcher records as the normal, expected speed. A baseline is a measurement of normal behaviour, so that later numbers can be compared against something real rather than assumed.

02-baseline-legit-repo.png
02-baseline-legit-repo.png From the original on HackerOne

The screenshot shows the normal repository scan finishing in milliseconds.

Step 3: Crafted repository with 64 files

FISH
set -x PYTHONPATH .

time python3 -c "
import tempfile, time
from pathlib import Path
from translation_finder.api import discover

with tempfile.TemporaryDirectory() as tmpdir:
    root = Path(tmpdir)
    big_toml = '\"' + 'x' * (1024 * 1024 - 10) + '\"'
    for i in range(64):
        d = root / f'proj{i}'
        d.mkdir()
        (d / 'en.toml').write_text(big_toml)
        (d / 'fr.toml').write_text('\"hello\"')
    t0 = time.time()
    results = discover(str(root))
    elapsed = time.time() - t0
    print(f'MALICIOUS REPO elapsed: {elapsed:.2f}s, results: {len(results)}')
"

Line by line:

  1. The first lines are the same as in Step 2: set up the module path, start Python, load the modules and the function.
  2. big_toml = '\"' + 'x' * (1024 * 1024 - 10) + '\"' builds the payload. A payload is the deliberately crafted input that triggers the bug. It is a double quote, then the letter x repeated 1024 * 1024 - 10 times (about one million), then a closing double quote. The result is a single TOML line of roughly 1 MB.
  3. for i in range(64): repeats 64 times.
  4. d = root / f'proj{i}' and d.mkdir() create 64 project folders.
  5. (d / 'en.toml').write_text(big_toml) writes the 1 MB single-line file into each folder.
  6. (d / 'fr.toml').write_text('\"hello\"') writes a tiny second TOML file containing "hello", so each folder looks like a small translation project with two languages.
  7. t0 = time.time(), results = discover(str(root)), elapsed = time.time() - t0 and print(...) time the scan and print the result to two decimal places.

The result is an elapsed time of about 7.16 seconds instead of a few milliseconds. The researcher also notes that usr time is almost equal to real time. These are two figures the time command reports: real time is the elapsed time on the clock, and usr time is the processor time spent running the program. When they are nearly equal, the processor is busy for the whole run rather than waiting on disk or network. That distinction matters, because a slow disk would also make a scan slow, but it would not be the library's fault.

03-crafted-toml-runtime.png
03-crafted-toml-runtime.png From the original on HackerOne

The screenshot shows the crafted repository with 64 files taking about 7.16 seconds, CPU bound.

Step 4: Confirm the delay does not grow with a bigger repository

The same test is repeated with 200 folders instead of 64.

The result is about 7.20 seconds, almost identical to the 64-folder run. That shows the delay is capped by the tool's own internal budget rather than by repository size. The practical consequence is that an attacker does not need a large repository: a small one with about 64 crafted files is enough to trigger the full delay.

04-amplification-200-dirs.png
04-amplification-200-dirs.png From the original on HackerOne

The screenshot shows the 200-file crafted repository still taking about 7.20 seconds, confirming the budget cap.

Step 5: Isolate the function responsible

FISH
set -x PYTHONPATH .

python3 -c "
import time
from translation_finder.discovery.files import _is_go_i18n_toml

big_toml = '\"' + 'x' * (1024 * 1024 - 10) + '\"'
t0 = time.time()
result = _is_go_i18n_toml(big_toml)
elapsed = time.time() - t0
print(f'_is_go_i18n_toml() time: {elapsed:.3f}s, result={result}')
"

Line by line:

  1. set -x PYTHONPATH . and python3 -c "..." do the same as before: make the local code importable and run Python with inline code.
  2. import time loads the timing module.
  3. from translation_finder.discovery.files import _is_go_i18n_toml imports the suspected function directly, skipping discover() entirely.
  4. big_toml = '\"' + 'x' * (1024 * 1024 - 10) + '\"' builds the same 1 MB single-line string as before.
  5. t0 = time.time() records the start time.
  6. result = _is_go_i18n_toml(big_toml) calls the check on the string, with no files involved.
  7. elapsed = time.time() - t0 computes how long it took.
  8. print(...) prints the time to three decimal places and the function's answer.

This calls the format check directly on the same 1 MB single-line string, bypassing discover() and the filesystem. The result is about 0.119 seconds for one file. Multiplied by 64 files, that is close to the total delay seen in Steps 3 and 4, which confirms the delay comes from this one function.

05-isolated-root-cause.png
05-isolated-root-cause.png From the original on HackerOne

The screenshot shows a single function call taking 0.119s, confirming the exact root cause.

Root cause

The root cause is in _toml_line_code(). It reads a line of text one character at a time in a Python loop. For very long lines this is slow because there is no limit on how long a single line can be before the function starts working on it. _is_go_i18n_toml() calls into that routine, so every TOML file with a long line pays the cost during discovery.

A useful comparison is reading a book. Reading a page normally takes a moment; reading it by picking up one letter at a time, putting it down, and picking up the next takes far longer, and the longer the page, the worse the gap gets. The library is doing the letter-by-letter version.

The library's budget system does limit the total damage to around 7 to 8 seconds per scan, which is why the 200-folder run is no slower than the 64-folder run. That defence bounds a single scan but does not prevent the cost from being triggered, and the cost is easy to trigger and repeat.

Impact

  • A repository with about 64 crafted TOML files makes discover() take about 7 to 8 seconds instead of milliseconds.
  • discover() is meant to be used by tools such as Weblate to scan repositories automatically, for example when a new repository or component is added, or when a repository is rescanned after a push. A push is when someone uploads changes to a repository.
  • The attacker only needs to add a small number of large, single-line TOML files to a repository. They do not need write access to the server, only the ability to get their repository content scanned, for example by submitting it as a project or contributing to a repository that gets rescanned.
  • If the scan runs often, for example on every push or every scheduled scan, this becomes a repeatable way to waste CPU time on the scanning server. CPU is the processor, the part of a computer that does the actual work.
  • The issue is CPU exhaustion only. It does not read files outside the repository, does not leak data and does not allow code execution. The damage is limited by the tool's own budget system to around 7 to 8 seconds per scan.

Fix

The report proposes two fixes, both aimed at _toml_line_code():

  1. Add a maximum line length check before running the character-by-character scan. If any line in the file is longer than a reasonable limit, for example 4096 characters, skip the TOML check for that file. Normal go-i18n TOML files do not have single lines that are 1 MB long. In everyday terms: if a page is absurdly long, do not read it letter by letter, just set it aside.
  2. Replace the manual character-by-character loop with a faster method, such as regular expressions or built-in string search functions, so that scanning long lines does not cost as much CPU time. A regular expression is a pattern for matching text, and the language's built-in search is written in fast compiled code rather than a slow Python loop.

The report does not state which of these was applied, or whether the library was changed at all.

Variants to test

  • Other format detectors in the same library. Any check that walks a file character by character, or otherwise scales with line length, is a candidate. A positive result is a single crafted file whose detection time is far above the milliseconds a normal file takes.
  • Other TOML-shaped inputs. The report's payload is a quoted 1 MB string; try long unquoted values, long keys, long comments and long arrays, and compare per-file timing. A positive result is any shape that reproduces the roughly 0.1 second per-file cost.
  • File-count thresholds. The report shows 64 files producing about 7.16 seconds and 200 files about 7.20 seconds. Try smaller counts to find the minimum that still produces the full delay on a given deployment.
  • Repeated scans. Where a platform rescans on every push or on a schedule, measure whether the delay is paid on each scan. A positive result is a consistent multi-second cost per scan from a small repository.
  • Other consumers of discover(). Any tool that scans untrusted repository content automatically is exposed in the same way; check whether the scan runs synchronously in a request path or in a background worker, since that changes who feels the CPU cost. Synchronously means the user's request waits for it; in a background worker means it happens out of sight.

Hunting notes

This class of bug hides in parsing and format-detection code that runs over untrusted content: file type sniffers, importers, linters and anything that decides "is this file format X". Parsing means reading structured text and working out what it means. The signal during recon is a code path that processes a file character by character, or otherwise has cost proportional to line length, combined with an entry point that walks many files automatically. Recon here means the early look around a target to spot promising places to dig.

The researcher did four things. First, a baseline on a normal repository, so the milliseconds figure is measured rather than assumed. Second, a crafted repository at realistic scale, with the CPU-bound nature confirmed by comparing usr time with real time. Third, a scaling test at 200 folders to show the budget cap and to prove a small repository is sufficient. Fourth, an isolated call to the suspected function, whose per-file time multiplied by the file count matches the end-to-end delay.

The report is explicit about what the bug is not: no file read outside the repository, no data leak, no code execution.

Glossary

  • API: a defined set of functions one program offers to another; here, the functions translation-finder exposes for tools to call.
  • Baseline: a measurement of normal behaviour taken before testing, used for comparison.
  • Budget system: an internal limit that stops a scan after a certain amount of work or time.
  • Clone: a full local copy of a repository, including its history.
  • Commit: a saved snapshot of a repository, identified by a long code.
  • Component: in Weblate, one translatable part of a project.
  • CPU: the processor, the part of a computer that performs calculations.
  • CPU bound: a program whose speed is limited by processor work rather than by disk or network.
  • CPU exhaustion: using up so much processor time that other work is slowed or starved.
  • CVSS: a standard scoring system for the severity of a security flaw.
  • Editable mode: installing a Python package so it runs directly from a local source folder.
  • Entry point: the function you call to start a piece of work.
  • Environment variable: a named setting the operating system passes to programs.
  • fish shell: a program for typing commands into a computer.
  • Function: a named block of code that performs a task and can be called by name.
  • Git: the version-control tool that stores code history.
  • go-i18n: a translation tool for the Go programming language that stores translations in TOML files.
  • Library: reusable code that other programs call instead of writing it themselves.
  • Loop: code that repeats an action a number of times.
  • Module: a file or package of Python code that can be imported.
  • Parsing: reading structured text and working out what it means.
  • Payload: the deliberately crafted input that triggers a bug.
  • pip: Python's package installer.
  • .po file: a common plain-text format for translation files.
  • Push: uploading changes to a repository.
  • Python: the programming language the library is written in.
  • Recon: the early look around a target to spot promising places to investigate.
  • Regular expression: a pattern for matching text, used to search quickly.
  • Repository: a folder of project files stored on a service such as GitHub, with its history.
  • Synchronous: work that a user's request waits for, rather than happening in the background.
  • TOML: a plain-text configuration file format, a bit like a simple list of settings.
  • Uncontrolled resource consumption: a weakness where software uses far more of a resource, such as processor time, than it should because it does not limit the work it accepts.
  • usr time / real time: processor time spent running a program versus elapsed time on the clock; when they are close, the program is CPU bound.

More by visionx7

View all

1 more disclosed report, best first.

More from Weblate

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.