pypi package report

Is rembg safe?

5 known vulnerabilities, worst severity HIGH.

// reach

30 direct dependencies

12 carry known advisories, worst CRITICAL

1 packages depend on it

an advisory here reaches each of them

Create a free accountfor every dependency path, dependent and what to upgrade
// ai model usage

No published models are known to use this package.


cvss
8.6
high

CVSS v3.1 base score out of 10

epss
0.39%
low

chance of exploitation in 30 days, 34th percentile of all CVEs

xyz score
4.0
medium

CyberXYZ composite out of 10

fig. 01 — GHSA-qr6x-7v33-6qmg, the advisory selected below

// 5 advisories

GHSA-qr6x-7v33-6qmg

HIGHGitHub ratingCVE-2026-115924

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

// cvss v3.1 vector

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
Low
Availability
Low

Checked 2026-11-08 at 00:23 UTC. The most recent advisory here was published 2026-10-27. Updated continuously from NVD, GHSA, OSV and CNA feeds.

Think a verdict here is wrong? Tell us — we respond within 2 business days.