Summary
A path-confinement weakness in IIB's file-serving access control accepts paths whose names merely begin with an allowed directory name. When access control is enabled and a requester can reach the file-serving endpoint, this may expose readable files outside the intended directory boundary.
Affected context
The issue occurs in deployments where IIB's access-control logic is active, including configurations that explicitly enable it or infer enablement from network-exposure options such as sharing, tunneling, listening, or a configured server name. The vulnerable comparison can treat a sibling directory with a similar prefix as being inside an allowed parent. Standalone deployments without access control may already serve any readable file, so the impact and applicability depend on deployment settings and filesystem permissions.
Exploit preconditions
- Attack surface: IIB's file-serving endpoint exposed through the Stable Diffusion WebUI integration
- Required access: Ability to submit or cause a file request to be processed by the service
- Trigger point: Path validation before the requested file is returned through
FileResponse - Why exploitation is possible: The validator uses a prefix comparison without requiring a directory boundary, allowing a path outside the approved directory to satisfy the trust check
Why this happens
The vulnerability results from treating a filesystem path as trusted when its string representation merely starts with the string representation of an allowed parent directory. Without appending or otherwise enforcing a path-separator boundary, directory names that share the allowed directory's prefix can be accepted incorrectly. This is a path traversal and improper pathname validation pattern mapped to CWE-22: Improper Limitation of a Pathname to a Restricted Directory.
Potential impact
- An attacker may read files outside the intended confinement directory.
- Sensitive configuration, credentials, or application data could be disclosed if readable by the service.
- The exposed file-serving endpoint could broaden the effective attack surface of a network-accessible WebUI.
- Information disclosure could support further compromise of the host or application.
General mitigation guidance
Mitigation generally focuses on enforcing filesystem-aware containment rather than raw string-prefix checks.
Common defensive patterns include:
- Compare normalized, resolved paths using a directory-boundary-aware containment check.
- Require the approved parent path to terminate with a path separator when using compatible prefix logic.
- Resolve symlinks and canonicalize paths according to the platform's filesystem semantics.
- Restrict file-serving operations to explicit allowlisted directories and file types.
- Apply least-privilege filesystem permissions to the service account.
- Keep access control enabled by default for network-exposed deployments and avoid serving arbitrary readable files.
How teams detect issues like this
Organizations can identify this weakness through:
- Static analysis rules for
startswithor equivalent prefix comparisons used in pathname authorization. - Code review checks for missing path-separator boundaries, canonicalization, or resolved-path containment.
- Tests covering allowed directories alongside sibling names that share the same prefix.
- Policy enforcement requiring filesystem-aware path validation before file responses are generated.
- Runtime monitoring for requests targeting paths outside configured serving roots and for unusual file-read activity.
- Automated security review tools that flag path authorization based solely on string prefixes.

