Rembg: Unauthenticated SAM model injection permits local-file disclosure through malicious ONNX graphs
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.
(width: 2172, height: 1182)
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.
(width: 2432, height: 1254)
Screenshot 2 — The identical second request returns HTTP 200 with an encoded PNG.
(width: 2858, height: 1548)
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.
(width: 1816, height: 1146)
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
What to do
Upgrade rembg to version 2.0.82 or later. Additionally, 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.
Affected software
Click a technology to see all vulnerabilities affecting it.
| Platform | Package | Vulnerable versions | Fixed in |
|---|---|---|---|
| Python (PyPI) | rembg | < 2.0.82 | 2.0.82 |
References
- https://github.com/danielgatis/rembg/security/advisories/GHSA-qr6x-7v33-6qmg
- https://nvd.nist.gov/vuln/detail/CVE-2026-115924
- https://github.com/danielgatis/rembg/commit/b2758c6b39bb2b02df90a03128110339476984d3
- https://github.com/danielgatis/rembg
- https://github.com/danielgatis/rembg/releases/tag/v2.0.82
- CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L- Weakness (CWE)
CWE-22- Platform
- Python (PyPI)
- Package
rembg- Disclosed
- 27.10.2026
- Updated
- 30.10.2026 10:00
Sources and licenses · Edited or translated by DockRay; source rights and applicable licenses are retained.
OSV / GitHub Advisory Database - GHSA-qr6x-7v33-6qmg - CC BY 4.0
Vulnerability history: rembg
All published vulnerabilities of this package (Python (PyPI)), newest first. Shows whether this is a one-off slip or a package that needs watching.
- Total entries
- 5
- First → latest
- 03.2025 10.2026
- Without a fix
- 0
- Exploited in attacks
- 0
Severity breakdown
- High 2
- Medium 3
Disclosures per year
- 2025: 2
- 2026: 3
-
Rembg: Unauthenticated SAM model injection permits local-file disclosure through malicious ONNX graphs this entry
Know which vulnerabilities affect your application
With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.