VYPR
Medium severity5.3NVD Advisory· Published Apr 10, 2026· Updated Apr 23, 2026

CVE-2026-40086

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.

PackageAffected versionsPatched versions
rembgPyPI
< 2.0.752.0.75

Affected products

1

Patches

1
7c76d3cdc575

Fix path traversal vulnerability in custom model sessions (GHSA-3wqj-33cg-xc48)

https://github.com/danielgatis/rembgDaniel GatisApr 8, 2026via ghsa
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

News mentions

0

No linked articles in our index yet.