GIVE YOUR AGENT THE EVIDENCE

Set up in your agent.

One prompt to get started. Paste it into your coding agent to connect cve.new through MCP and bring vulnerability context into your workflow.

Your agent needs remote MCP support and access to https://cve.new/mcp.

Read the setup guide

GIVE YOUR AGENT THE EVIDENCE

Investigate in your agent.

Turn this advisory into a focused investigation. Ask your agent to check your project’s versions, explain the evidence, and suggest a compatible fix.

Your agent needs remote MCP support and access to https://cve.new/mcp.

Read the setup guide

All vulnerabilities
GHSA-qr6x-7v33-6qmghigh8.6

Rembg: Unauthenticated SAM model injection permits local-file disclosure through malicious ONNX graphs

Check your stack

The advisory, in context

The public /api/remove endpoint uses attacker-controlled extras.sam_model in both SAM filenames and GitHub download URLs. Path traversal plus a URL fragment lets an unauthenticated attacker place malicious ONNX models beside a target file. The models read the file as ONNX external data and encode its bytes into the returned PNG.

This issue affects SAM's sam_model in 2.0.81 and returns complete file contents.

<img width="2172" height="1182" alt="image" src="https://github.com/user-attachments/assets/70aacab1-5ef8-4aad-b30e-e3780adef4d2" />

Screenshot 1 — First unauthenticated request primes the path and returns HTTP 500.

Technical details

rembg/commands/s_command.py:188-223,384-397 accepts public extras JSON and passes it to new_session(). rembg/sessions/sam.py:313-355 inserts sam_model into encoder/decoder filenames and fixed GitHub URLs, then invokes pooch.retrieve() without a pinned hash.

Requests removes the URL #fragment; the local POSIX path retains it. Pooch creates attacker-selected parent directories without enforcing cache containment. The first request creates the path tree and returns HTTP 500. The identical second request downloads the attacker asset twice and stores it as both SAM models beside the target.

The graph uses a relative external tensor to read the target and maps every byte to mask pixels. rembg returns the mask as a PNG, which the attacker decodes back into the original bytes.

<img width="2432" height="1254" alt="image" src="https://github.com/user-attachments/assets/99215c39-3619-4952-8f41-5ef2034f7499" />

Screenshot 2 — The identical second request returns HTTP 200 with an encoded PNG.

<img width="2858" height="1548" alt="image" src="https://github.com/user-attachments/assets/26322071-101c-41aa-a356-08a4969ef475" />

Proof of concept

The attached loopback-only PoC produced:

VULNERABLE: unauthenticated SAM model injection disclosed the synthetic /flag
first-http=500 second-http=200
decoded-value=REMBG_AUDIT_SYNTHETIC_FLAG_2026_08_28

The /etc/passwd variant produced:

VULNERABLE: disclosed /etc/passwd (839 bytes)
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
...
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin

The decoded contents matched /etc/passwd inside the owned container. Testing used a local TLS stand-in for GitHub; no public target was contacted.

<img width="1816" height="1146" alt="image" src="https://github.com/user-attachments/assets/664eaf25-5963-4ca6-b7eb-3e198499194a" />

Screenshot 3 — The decoder reconstructs all 839 bytes of /etc/passwd.

Impact

An unauthenticated attacker can execute arbitrary ONNX computation and disclose complete files that rembg can reach under the required filesystem permissions. The supplied root-running container exposed both /flag and /etc/passwd.

Remediation

Allow only fixed SAM identifiers mapped server-side to fixed filenames, URLs, and pinned hashes. Reject path and URL syntax; canonicalize destinations and enforce cache containment before creating directories. Run the container as a non-root user with a read-only root filesystem.

decode_samfragment_png.py samfragment_04.py samfragment_etc_passwd_lab.py

Affected packages

Start with the recorded fix for your release branch. Check your installed version and test compatibility before upgrading. Fixing this advisory does not rule out other vulnerabilities in the release.

rembg PyPI
Ecosystem versions

Earlier releases before 2.0.82

Fixed in 2.0.82

53 explicitly affected versions

2.0.28, 2.0.29, 2.0.30, 2.0.31, 2.0.32, 2.0.33, 2.0.34, 2.0.35, 2.0.36, 2.0.37, 2.0.38, 2.0.39, 2.0.40, 2.0.41, 2.0.43, 2.0.44, 2.0.45, 2.0.46, 2.0.47, 2.0.48, 2.0.49, 2.0.50, 2.0.51, 2.0.52, 2.0.53, 2.0.54, 2.0.55, 2.0.56, 2.0.57, 2.0.58, 2.0.59, 2.0.60, 2.0.61, 2.0.62, 2.0.63, 2.0.64, 2.0.65, 2.0.66, 2.0.67, 2.0.68, 2.0.69, 2.0.70, 2.0.71, 2.0.72, 2.0.73, 2.0.74, 2.0.75, 2.0.76, 2.0.77, 2.0.78, 2.0.79, 2.0.80, 2.0.81

View affected-version evidence
{
  "ranges": [
    {
      "events": [
        {
          "introduced": "0"
        },
        {
          "fixed": "2.0.82"
        }
      ],
      "type": "ECOSYSTEM"
    }
  ],
  "versions": [
    "2.0.28",
    "2.0.29",
    "2.0.30",
    "2.0.31",
    "2.0.32",
    "2.0.33",
    "2.0.34",
    "2.0.35",
    "2.0.36",
    "2.0.37",
    "2.0.38",
    "2.0.39",
    "2.0.40",
    "2.0.41",
    "2.0.43",
    "2.0.44",
    "2.0.45",
    "2.0.46",
    "2.0.47",
    "2.0.48",
    "2.0.49",
    "2.0.50",
    "2.0.51",
    "2.0.52",
    "2.0.53",
    "2.0.54",
    "2.0.55",
    "2.0.56",
    "2.0.57",
    "2.0.58",
    "2.0.59",
    "2.0.60",
    "2.0.61",
    "2.0.62",
    "2.0.63",
    "2.0.64",
    "2.0.65",
    "2.0.66",
    "2.0.67",
    "2.0.68",
    "2.0.69",
    "2.0.70",
    "2.0.71",
    "2.0.72",
    "2.0.73",
    "2.0.74",
    "2.0.75",
    "2.0.76",
    "2.0.77",
    "2.0.78",
    "2.0.79",
    "2.0.80",
    "2.0.81"
  ]
}

References