Uncaught RecursionError crash in translation-finder (deep directory tree DoS)
The translation-finder library recursively walks repository directories without a depth limit, so a repository with around 1000 nested folders triggers an uncaught RecursionError. An attacker who can push such a tree can crash Weblate's discovery task repeatedly, stopping translation activity for the affected component.
Originally disclosed on HackerOne
- Fixed in 39 hours
- Disclosed after 33 days
Type: Denial of Service (Availability) Severity: Low-Medium (CVSS 3.7-5.5 depending on access) Affected: WeblateOrg/translation-finder v3.4.1, commit f5f8bb5 (current main)
TL;DR
translation-finder scans repository content using recursion without any depth limit. A repository with ~1000 nested folders causes an uncaught RecursionError that crashes the entire discovery call. The error is not handled anywhere, so Weblate's import/update/hook processing fails repeatedly.
Tested environment
- Python 3.13.9
- charset-normalizer 3.5.1
- ruamel.yaml 0.19.1
- Linux x86_64
Where the bug is
translation_finder/finder.py, lines 157–177:
def list_files(self, root: PurePath, files: PathListType, dirs: PathListType) -> None:
with scandir(root) as matches:
for match in matches:
if match.is_symlink():
continue
is_dir = match.is_dir()
path = Path(match.path)
if any(path.match(exclude) for exclude in EXCLUDES):
continue
if is_dir:
dirs.append(self.process_path(path))
try:
self.list_files(path, files, dirs) # <-- line 176: unbounded recursion
except OSError:
continue
else:
files.append(self.process_path(path))
The function calls itself recursively for every subdirectory. Only OSError is caught — RecursionError escapes and crashes discover() / Finder().
Why it matters
Git fully supports trees that are 1000+ levels deep. Any contributor can push such a tree to a repository. When Weblate scans that repo (import, update, webhook, PR), the discovery task crashes. Every retry also crashes, so the component's translation activity stops.
Steps to reproduce
-
Run the PoC script:
Bash python3 poc_deepnest.py 1000 -
The script creates a tree with 1000 nested directories plus two tiny translation files.
-
It calls
discover()on the tree.
Result (measured, repeatable)
| Depth | Result |
|---|---|
| 960 | pass — no crash |
| 985 | pass — no crash |
| 990 | CRASH — RecursionError |
| 1000, 1050, 1100 | CRASH |
The exact boundary is ~960–1000 depending on Python version and stack. Below it works, above it always crashes.
Proof
Attachment: bug1_traceback.txt — actual crash traceback from a real run.
Key frames:
File "translation_finder/api.py", line 54, in discover
finder = Finder(root, mock=mock)
File "translation_finder/finder.py", line 73, in __init__
self.list_files(root, files, dirs)
File "translation_finder/finder.py", line 176, in list_files
self.list_files(path, files, dirs)
[Previous line repeated 984 more times]
File "translation_finder/finder.py", line 154, in process_path
relative = path.relative_to(self.root)
RecursionError: maximum recursion depth exceeded
Attachment: bug1_finder_frames.txt — same crash with library frames extracted for readability.
CVSS 3.1
AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H= 3.7 (Low) — admin action required for importPR:Nin webhook / PR-driven setups = 5.5 (Medium)
Weakness
- CWE-674: Uncontrolled Recursion
- CWE-400: Uncontrolled Resource Consumption (secondary)
Suggested fix
Best: Replace recursion with an iterative walk (os.walk()), or add a depth cap (~256).
Minimum: Catch RecursionError and skip that subtree:
try:
self.list_files(path, files, dirs)
except (OSError, RecursionError): # add RecursionError here
continue
This is a one-line fix that turns the crash into a skip.
Attachments
| File | What it is |
|---|---|
poc_deepnest.py |
PoC script — creates deep tree and crashes discover() |
bug1_traceback.txt |
Real crash traceback (proof) |
bug1_finder_frames.txt |
Same crash, library frames extracted (readable summary) |
Impact
- Availability: uncaught exception kills Weblate's discovery task
- Repeated failures: every retry crashes again
- Component stuck: import/update/hook activity stops for affected component
- Aggregate CPU DoS: possible with many nested repos
Context
translation-finder is the library Weblate uses to discover translation files inside a repository. When a component is imported, updated, triggered by a webhook or scanned as part of a pull request, the discovery code walks the repository tree and decides which files are translation sources and which are not. The library exposes this through discover() in translation_finder/api.py, which constructs a Finder object; the Finder constructor then enumerates the tree.
The report concerns WeblateOrg/translation-finder v3.4.1, commit f5f8bb5 (described as current main at the time). The weakness is classified as CWE-674 (Uncontrolled Recursion), with CWE-400 (Uncontrolled Resource Consumption) as a secondary category. The researcher rates it Low to Medium, CVSS 3.7 to 5.5 depending on how the scan is triggered.
Setup
The researcher tested on Linux x86_64 with:
- Python 3.13.9
- charset-normalizer 3.5.1
- ruamel.yaml 0.19.1
Any contributor who can push to a repository can create the directory structure. What differs between scenarios is how the scan is triggered, which is what moves the CVSS score between 3.7 and 5.5.
Finding it
The problem is in translation_finder/finder.py, lines 157 to 177. list_files() opens a directory with scandir() and iterates over the entries. Symlinks are skipped, excluded paths are skipped, and then, for each subdirectory, the function appends the processed path to dirs and calls itself on that subdirectory:
def list_files(self, root: PurePath, files: PathListType, dirs: PathListType) -> None:
with scandir(root) as matches:
for match in matches:
if match.is_symlink():
continue
is_dir = match.is_dir()
path = Path(match.path)
if any(path.match(exclude) for exclude in EXCLUDES):
continue
if is_dir:
dirs.append(self.process_path(path))
try:
self.list_files(path, files, dirs) # <-- line 176: unbounded recursion
except OSError:
continue
else:
files.append(self.process_path(path))
The recursive call is wrapped in a try that only catches OSError. There is no depth limit and no handling for RecursionError, so once the tree is deep enough, the interpreter's recursion limit is hit and the exception escapes the whole call chain, taking down discover() / Finder().
Git itself has no problem storing trees that are 1000 or more levels deep, so a repository like this is perfectly valid and can be pushed by any contributor.
Exploitation
Step 1: build the deep tree
The researcher wrote a PoC script, poc_deepnest.py, which creates a tree of nested directories plus two tiny translation files. It is run with the desired depth as an argument:
python3 poc_deepnest.py 1000
Step 2: observe the crash
The measured, repeatable results were:
| Depth | Result |
|---|---|
| 960 | pass, no crash |
| 985 | pass, no crash |
| 990 | CRASH, RecursionError |
| 1000, 1050, 1100 | CRASH |
The exact boundary sits around 960 to 1000 depending on the Python version and the available stack. Below it the scan completes; above it the scan always crashes.
Step 3: read the traceback
The attachment bug1_traceback.txt contains the actual crash traceback from a real run. The key frames are:
File "translation_finder/api.py", line 54, in discover
finder = Finder(root, mock=mock)
File "translation_finder/finder.py", line 73, in __init__
self.list_files(root, files, dirs)
File "translation_finder/finder.py", line 176, in list_files
self.list_files(path, files, dirs)
[Previous line repeated 984 more times]
File "translation_finder/finder.py", line 154, in process_path
relative = path.relative_to(self.root)
RecursionError: maximum recursion depth exceeded
The traceback shows the entry point (discover() constructing Finder), the constructor calling list_files(), and then the recursive call at line 176 repeating 984 more times before the interpreter gives up. A second attachment, bug1_finder_frames.txt, contains the same crash with the library frames extracted for readability.
Root cause
The design mistake is unbounded recursion over attacker-controlled directory depth. The only guard on the recursive call is an except OSError, which covers filesystem errors but not the interpreter's recursion limit. Because RecursionError is not caught anywhere in the chain, it propagates out of list_files(), out of the Finder constructor and out of discover(), so the entire discovery call fails rather than skipping the offending subtree. Existing defences did not stop it: the exclusion list (EXCLUDES) filters paths by pattern, not by depth, and nothing else in the walk imposes a cap.
Impact
When Weblate scans a repository containing such a tree, whether on import, update, webhook or pull request, the discovery task crashes. Every retry crashes again, so the component's translation activity stops: import, update and hook processing fail repeatedly for the affected component. The researcher also notes that an aggregate CPU denial of service is possible with many nested repositories.
The severity depends on how the scan is triggered. The researcher's CVSS 3.1 assessment is:
AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H= 3.7 (Low), where an admin action is required for importPR:Nin webhook or pull-request-driven setups = 5.5 (Medium)
Fix
The researcher suggests two options. The best fix is to replace the recursion with an iterative walk (os.walk()) or to add a depth cap of around 256. The minimum fix is to catch RecursionError alongside OSError and skip that subtree:
try:
self.list_files(path, files, dirs)
except (OSError, RecursionError): # add RecursionError here
continue
That one-line change turns the crash into a skip. The report does not say which fix was adopted.
Variants to test
- Other recursive directory walkers. Look for functions that call themselves per subdirectory with only narrow exception handling. A positive result is a traceback showing the recursive frame repeated many times and a
RecursionErrorescaping the public entry point. - Depth caps set too high. Where a limit exists, try trees just above it. A positive result is a crash or a scan that takes disproportionately long at the boundary.
- Symlink and exclusion bypasses. The walk skips symlinks and
EXCLUDESmatches; check whether a deep tree can be reached through paths that avoid those checks. A positive result is a crash from a tree the filters were meant to ignore. - Repeated-trigger scenarios. In webhook or pull-request-driven setups, push the deep tree and observe retries. A positive result is a component whose import, update or hook processing fails on every attempt.
- Recursion in other parsers. Translation and configuration parsers often recurse over nested structures. Feed deeply nested input and watch for an uncaught
RecursionErrorrather than a clean validation error.
What happened, in plain words
Weblate is a web service that helps teams translate software. It keeps translations in a repository, which is a shared folder of files stored on a server (often on GitHub or a similar hosting site). To know which files inside that repository are translations and which are not, Weblate uses a small helper library called translation-finder. When someone imports a project, updates it, or a change arrives through an automatic trigger, this library walks through every folder in the repository and builds a list of the files it finds.
The walk is done with a technique called recursion. Recursion means a function (a named block of code that does a job) calls itself to handle the next level of a problem. Think of it like standing between two mirrors: each reflection contains another reflection. Here, the function looks inside a folder, and for every subfolder it calls itself again to look inside that one, and so on. That works fine for normal repositories, which are only a few folders deep.
The problem is that nothing stops the walk from going deeper and deeper. A repository can legally contain a folder inside a folder inside a folder, a thousand times over. Git, the version control system that stores repositories, has no objection to that. When the library reaches such a tree, it keeps calling itself until the programming language's built-in safety limit is hit. Python, the language the library is written in, raises an error called RecursionError at that point. The library never catches that error, so the whole discovery call fails. Weblate's import, update and webhook processing then fail too, and they fail again on every retry.
The researcher who found this rated it Low to Medium severity, with a CVSS score between 3.7 and 5.5 depending on how the scan is triggered. CVSS is a standard scoring system for security bugs; higher numbers mean more serious. The weakness is classified as CWE-674, Uncontrolled Recursion, with CWE-400, Uncontrolled Resource Consumption, as a secondary category. CWE is a public catalogue of weakness types.
Context
translation-finder is the library Weblate uses to discover translation files inside a repository. When a component is imported, updated, triggered by a webhook or scanned as part of a pull request, the discovery code walks the repository tree and decides which files are translation sources and which are not. The library exposes this through discover() in translation_finder/api.py, which constructs a Finder object; the Finder constructor then enumerates the tree.
A few of those words deserve a plain explanation:
- A component in Weblate is one translatable project, tied to one repository.
- A webhook is an automatic message that one service sends to another when something happens, for example when code is pushed. It saves a human from clicking a button.
- A pull request is a proposed change to a repository that someone asks to have merged in.
- An API is the part of a program that other programs talk to.
discover()is the front door of this library: other code calls it and gets an answer back. - A constructor is the piece of code that runs when a new object is created. Here, creating a
Finderimmediately starts the folder walk.
The report concerns WeblateOrg/translation-finder v3.4.1, commit f5f8bb5 (described as current main at the time). The researcher rates it Low to Medium, CVSS 3.7 to 5.5 depending on how the scan is triggered.
Setup
The researcher tested on Linux x86_64 with:
- Python 3.13.9
- charset-normalizer 3.5.1
- ruamel.yaml 0.19.1
Python is the programming language the library is written in. The other two are helper libraries listed in the tested environment. Linux x86_64 is the operating system and processor type of the test machine.
Any contributor who can push to a repository can create the directory structure. What differs between scenarios is how the scan is triggered, which is what moves the CVSS score between 3.7 and 5.5.
Finding it
The problem is in translation_finder/finder.py, lines 157 to 177. list_files() opens a directory with scandir() and iterates over the entries. Symlinks are skipped, excluded paths are skipped, and then, for each subdirectory, the function appends the processed path to dirs and calls itself on that subdirectory:
def list_files(self, root: PurePath, files: PathListType, dirs: PathListType) -> None:
with scandir(root) as matches:
for match in matches:
if match.is_symlink():
continue
is_dir = match.is_dir()
path = Path(match.path)
if any(path.match(exclude) for exclude in EXCLUDES):
continue
if is_dir:
dirs.append(self.process_path(path))
try:
self.list_files(path, files, dirs) # <-- line 176: unbounded recursion
except OSError:
continue
else:
files.append(self.process_path(path))
Line by line, in plain words:
def list_files(...)declares a function that takes a starting folder (root) and two lists, one for files and one for folders, which it fills in as it goes.with scandir(root) as matches:opens the folder and reads its contents. Thewithform makes sure the folder is closed again afterwards, like closing a drawer after looking inside.for match in matches:goes through each item in the folder, one at a time.if match.is_symlink(): continueskips symlinks. A symlink is a shortcut that points at another file or folder, and following shortcuts could lead the walk in circles.is_dir = match.is_dir()asks whether the item is a folder.path = Path(match.path)turns the item's location into a path object, a convenient way to handle file locations in code.if any(path.match(exclude) for exclude in EXCLUDES): continueskips anything matching a list of excluded patterns, such as temporary or hidden folders.if is_dir:handles the case where the item is a folder.dirs.append(self.process_path(path))records the folder in the list of folders.try: self.list_files(path, files, dirs)is the recursive call: the function calls itself on the subfolder to look inside it.except OSError: continuecatches only one kind of error,OSError, which covers problems reported by the operating system, such as a folder that cannot be read. If that happens, the walk skips that folder and carries on.else: files.append(self.process_path(path))handles ordinary files by adding them to the file list.
The recursive call is wrapped in a try that only catches OSError. There is no depth limit and no handling for RecursionError, so once the tree is deep enough, the interpreter's recursion limit is hit and the exception escapes the whole call chain, taking down discover() / Finder().
Git itself has no problem storing trees that are 1000 or more levels deep, so a repository like this is perfectly valid and can be pushed by any contributor.
Exploitation
Step 1: build the deep tree
The researcher wrote a PoC script, poc_deepnest.py, which creates a tree of nested directories plus two tiny translation files. It is run with the desired depth as an argument:
python3 poc_deepnest.py 1000
This line runs the script with Python 3 and passes the number 1000 to it. The script reads that number and builds a folder chain 1000 levels deep. The point of building it locally first is to reproduce the bug in a controlled place, without touching a real Weblate installation.
Step 2: observe the crash
The measured, repeatable results were:
| Depth | Result |
|---|---|
| 960 | pass, no crash |
| 985 | pass, no crash |
| 990 | CRASH, RecursionError |
| 1000, 1050, 1100 | CRASH |
The exact boundary sits around 960 to 1000 depending on the Python version and the available stack. Below it the scan completes; above it the scan always crashes. The stack is the region of memory Python uses to keep track of nested function calls; each recursive call takes a little more of it, and when it runs out, Python stops the program with RecursionError.
Step 3: read the traceback
The attachment bug1_traceback.txt contains the actual crash traceback from a real run. A traceback is the list of steps the program was taking when it failed, printed from the outermost call down to the point of the error. The key frames are:
File "translation_finder/api.py", line 54, in discover
finder = Finder(root, mock=mock)
File "translation_finder/finder.py", line 73, in __init__
self.list_files(root, files, dirs)
File "translation_finder/finder.py", line 176, in list_files
self.list_files(path, files, dirs)
[Previous line repeated 984 more times]
File "translation_finder/finder.py", line 154, in process_path
relative = path.relative_to(self.root)
RecursionError: maximum recursion depth exceeded
Reading it from the top:
- The first frame shows
discover()inapi.pycreating aFinderobject. This is the public entry point, the front door other code uses. - The second frame shows the
Finderconstructor (__init__) starting the folder walk by callinglist_files(). - The third frame shows
list_files()calling itself at line 176. [Previous line repeated 984 more times]means that same self-call happened 984 more times before Python gave up. This is the recursion piling up.- The last frame shows
process_path()trying to work out a file's location relative to the starting folder. RecursionError: maximum recursion depth exceededis Python saying it will not go any deeper.
A second attachment, bug1_finder_frames.txt, contains the same crash with the library frames extracted for readability.
Root cause
The design mistake is unbounded recursion over attacker-controlled directory depth. The only guard on the recursive call is an except OSError, which covers filesystem errors but not the interpreter's recursion limit. Because RecursionError is not caught anywhere in the chain, it propagates out of list_files(), out of the Finder constructor and out of discover(), so the entire discovery call fails rather than skipping the offending subtree. Existing defences did not stop it: the exclusion list (EXCLUDES) filters paths by pattern, not by depth, and nothing else in the walk imposes a cap.
In everyday terms: the walk has a rule for skipping shortcuts and a rule for skipping certain names, but no rule for stopping when the folders get absurdly deep. The one safety net it does have is too narrow, like a net with a hole exactly where the fall happens.
Impact
When Weblate scans a repository containing such a tree, whether on import, update, webhook or pull request, the discovery task crashes. Every retry crashes again, so the component's translation activity stops: import, update and hook processing fail repeatedly for the affected component. The researcher also notes that an aggregate CPU denial of service is possible with many nested repositories. A denial of service means making a service unusable for its normal users, here by making the scan fail rather than by stealing data.
The severity depends on how the scan is triggered. The researcher's CVSS 3.1 assessment is:
AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H= 3.7 (Low), where an admin action is required for importPR:Nin webhook or pull-request-driven setups = 5.5 (Medium)
That string is a compact CVSS vector. Each part describes one aspect of the bug: AV:N means it can be reached over the network, AC:L means the attack is easy to carry out, PR:L means the attacker needs low privileges, UI:N means no user interaction is needed, S:U means the impact stays within the affected component, C:N and I:N mean no loss of confidentiality or integrity, and A:H means a high loss of availability. The second line changes PR:L to PR:N, meaning no privileges at all are needed when a webhook or pull request triggers the scan, which raises the score.
Fix
The researcher suggests two options. The best fix is to replace the recursion with an iterative walk (os.walk()) or to add a depth cap of around 256. An iterative walk uses a loop instead of self-calls, so there is no stack to exhaust; a depth cap simply refuses to go deeper than a set number of levels.
The minimum fix is to catch RecursionError alongside OSError and skip that subtree:
try:
self.list_files(path, files, dirs)
except (OSError, RecursionError): # add RecursionError here
continue
This snippet keeps the same try block but widens the list of caught errors to include RecursionError. If the walk hits the recursion limit, the error is caught, the offending folder is skipped, and the scan carries on with the rest of the tree. That one-line change turns the crash into a skip. The report does not say which fix was adopted.
Variants to test
- Other recursive directory walkers. Look for functions that call themselves per subdirectory with only narrow exception handling. A positive result is a traceback showing the recursive frame repeated many times and a
RecursionErrorescaping the public entry point. - Depth caps set too high. Where a limit exists, try trees just above it. A positive result is a crash or a scan that takes disproportionately long at the boundary.
- Symlink and exclusion bypasses. The walk skips symlinks and
EXCLUDESmatches; check whether a deep tree can be reached through paths that avoid those checks. A positive result is a crash from a tree the filters were meant to ignore. - Repeated-trigger scenarios. In webhook or pull-request-driven setups, push the deep tree and observe retries. A positive result is a component whose import, update or hook processing fails on every attempt.
- Recursion in other parsers. Translation and configuration parsers often recurse over nested structures. Feed deeply nested input and watch for an uncaught
RecursionErrorrather than a clean validation error.
Glossary
- API: the part of a program that other programs call to use its features.
- Component: in Weblate, one translatable project tied to one repository.
- Constructor: the code that runs when a new object is created.
- Contributor: someone with permission to add changes to a repository.
- CPU: the processor that does the computing work; a CPU denial of service keeps it busy so normal work cannot proceed.
- CVSS: a standard scoring system for security bugs, from 0 to 10.
- CWE: a public catalogue of weakness types, each with a number.
- Denial of service: making a service unusable for its normal users.
- Directory tree: folders nested inside folders, like branches on a tree.
- Exception: an error signal raised by a program when something goes wrong.
- Exclusion list: a list of path patterns the walk deliberately ignores.
- Frame: one entry in a traceback, showing one function call.
- Function: a named block of code that performs a job and can be called by name.
- Git: the version control system that stores repositories and their history.
- Iterative walk: visiting folders with a loop instead of self-calls, so no stack builds up.
- Library: reusable code that other programs include instead of writing it themselves.
- OSError: the error Python raises for problems reported by the operating system, such as an unreadable folder.
- PoC: proof of concept, a small script that demonstrates a bug.
- Pull request: a proposed change to a repository that someone asks to have merged.
- Recursion: a function calling itself to handle the next level of a problem.
- RecursionError: the error Python raises when function calls nest too deeply.
- Repository: a shared folder of files, usually with full change history, stored on a hosting service.
- Scandir: a Python function that lists the contents of a folder.
- Stack: the memory region Python uses to track nested function calls.
- Symlink: a shortcut that points at another file or folder.
- Traceback: the list of calls a program was making when it failed.
- Webhook: an automatic message one service sends to another when something happens.
- Weblate: a web service for managing software translations.