NewApp Monitoring is liveSign up free
AgentbeamBeta
Open-source package vulnerability · PyPI

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

highCVSS 3.1 8.6GHSA-qr6x-7v33-6qmg

rembg 2.0.81 and earlier let an unauthenticated client of the /api/remove endpoint choose the SAM model name through extras.sam_model. Path traversal and a URL fragment let the attacker plant a malicious ONNX model next to a target file and read that file back inside a returned PNG. Upgrade to rembg 2.0.82.

Published Oct 27, 2026 · Analysis Nov 1, 2026

What an attacker can do

The /api/remove endpoint takes a public extras JSON field and passes it to new_session() (rembg/commands/s_command.py). In rembg/sessions/sam.py, sam_model is placed into the encoder and decoder file names and into fixed GitHub download URLs, then fetched with pooch.retrieve() with no pinned hash. The Requests library drops a URL fragment, but the local POSIX path keeps it. Pooch also creates attacker-chosen parent directories with no cache containment check.

The first request creates the directory tree and returns HTTP 500. The identical second request downloads the attacker's asset twice and stores it as both SAM models beside the target file. The malicious ONNX graph reads the target through a relative external tensor and maps each byte to mask pixels. rembg returns the mask as a PNG, and the attacker decodes the PNG back into the original bytes.

No login is needed. The attacker needs network access to the rembg server and a server that can host the model for the download. The reporter read /etc/passwd and a synthetic flag file from a container that ran as root. Any file the rembg process can read is exposed, and the advisory also calls out arbitrary ONNX computation. CVSS rates integrity and availability impact as low.

Who is affected

The package data lists rembg below 2.0.82. The advisory names 2.0.81 as reproduced. You are exposed if you run the rembg HTTP server, where /api/remove accepts the extras parameter, and the SAM session is reachable by untrusted clients. Command-line use on local files is not the attack path.

pip show rembg

For Docker images, check the pinned rembg version inside the image.

rembg

Ecosystem
PyPI
Affected
< 2.0.82
Fixed in
2.0.82
Check
pip show rembg

How to fix it

Upgrade to rembg 2.0.82.

pip install --upgrade "rembg>=2.0.82"

The fix commit, b2758c6, allows only three sam_model values, sam_vit_b_01ec64, sam_vit_l_0b3195 and sam_vit_h_4b8939, and raises ValueError for anything else. It also pins an md5 checksum for each SAM asset, skipped when MODEL_CHECKSUM_DISABLED is set. Do not set that variable. The advisory also advises running the container as a non-root user with a read-only root filesystem, and keeping the server off untrusted networks.

How to tell if you were hit

Look in the rembg server's access logs for POST requests to /api/remove with an extras field that holds a sam_model value containing ../ sequences, a # fragment, a slash or a URL. Look for a pair of identical requests, the first returning HTTP 500 and the second HTTP 200. On disk, search for unexpected directories and .onnx files created outside the model cache, and for outbound downloads from the rembg host to unfamiliar servers. Rotate any secrets stored in files the process could read.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

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.

*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.

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

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.

*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

Credited to rach1tarora.

Questions

Does CVE-2026-115924 need authentication?

No. The advisory describes an unauthenticated attacker using the public /api/remove endpoint. The CVSS vector shows no privileges and no user interaction.

Why does the exploit need two requests?

The first request creates the attacker-chosen path tree and returns HTTP 500. The identical second request downloads the malicious model into place and returns HTTP 200 with the file's bytes encoded in a PNG.

Which files can be read?

Any file the rembg process can read. The reporter's root container exposed /etc/passwd and a synthetic /flag file. Running as non-root with a read-only root filesystem limits this.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More PyPI vulnerabilities

All PyPI entries