CVE-2026-40086
Description
Rembg is a tool to remove images background. Prior to 2.0.75, a path traversal vulnerability in the rembg HTTP server allows unauthenticated remote attackers to read arbitrary files from the server's filesystem. By sending a crafted request with a malicious model_path parameter, an attacker can force the server to attempt loading any file as an ONNX model, revealing file existence, permissions, and potentially file contents through error messages. This vulnerability is fixed in 2.0.75.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
rembgPyPI | < 2.0.75 | 2.0.75 |
Affected products
1Patches
17c76d3cdc575Fix path traversal vulnerability in custom model sessions (GHSA-3wqj-33cg-xc48)
3 files changed · +21 −3
rembg/sessions/ben_custom.py+7 −1 modified@@ -75,7 +75,13 @@ def download_models(cls, *args, **kwargs): if model_path is None: raise ValueError("model_path is required") - return os.path.abspath(os.path.expanduser(model_path)) + abs_path = os.path.abspath(os.path.expanduser(model_path)) + allowed_dir = os.path.abspath(os.path.expanduser(cls.u2net_home())) + if not abs_path.startswith(allowed_dir + os.sep) and abs_path != allowed_dir: + raise ValueError( + f"model_path must be within the models directory: {allowed_dir}" + ) + return abs_path @classmethod def name(cls, *args, **kwargs):
rembg/sessions/dis_custom.py+7 −1 modified@@ -74,7 +74,13 @@ def download_models(cls, *args, **kwargs): if model_path is None: raise ValueError("model_path is required") - return os.path.abspath(os.path.expanduser(model_path)) + abs_path = os.path.abspath(os.path.expanduser(model_path)) + allowed_dir = os.path.abspath(os.path.expanduser(cls.u2net_home())) + if not abs_path.startswith(allowed_dir + os.sep) and abs_path != allowed_dir: + raise ValueError( + f"model_path must be within the models directory: {allowed_dir}" + ) + return abs_path @classmethod def name(cls, *args, **kwargs):
rembg/sessions/u2net_custom.py+7 −1 modified@@ -80,7 +80,13 @@ def download_models(cls, *args, **kwargs): if model_path is None: raise ValueError("model_path is required") - return os.path.abspath(os.path.expanduser(model_path)) + abs_path = os.path.abspath(os.path.expanduser(model_path)) + allowed_dir = os.path.abspath(os.path.expanduser(cls.u2net_home())) + if not abs_path.startswith(allowed_dir + os.sep) and abs_path != allowed_dir: + raise ValueError( + f"model_path must be within the models directory: {allowed_dir}" + ) + return abs_path @classmethod def name(cls, *args, **kwargs):
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
5- github.com/danielgatis/rembg/commit/7c76d3cdc5757ffbda6a76664b24cfbecdb80273nvdPatchWEB
- github.com/danielgatis/rembg/security/advisories/GHSA-3wqj-33cg-xc48nvdExploitMitigationVendor AdvisoryWEB
- github.com/advisories/GHSA-3wqj-33cg-xc48ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2026-40086ghsaADVISORY
- github.com/danielgatis/rembg/releases/tag/v2.0.75nvdProductRelease NotesWEB
News mentions
0No linked articles in our index yet.