Summary
Sub2API contains a path traversal flaw in wildcard response routes that allows an authenticated tenant to influence the upstream request path. Under affected configurations, an attacker may relay requests to arbitrary upstream endpoints using shared operator-owned provider credentials.
Affected context
The vulnerability occurs in Sub2API versions 0.1.135 through 0.1.168 when tenant-facing response routes construct upstream URLs from an unvalidated client-supplied subpath. Risk is highest when the gateway uses shared ChatGPT, Codex OAuth, OpenAI platform, or operator-configured provider credentials for upstream requests.
Exploit preconditions
- Attack surface: Authenticated tenant-facing
POST /responses/*subpathroutes - Required access: A valid platform API key issued to a tenant
- Trigger point: Processing and forwarding of the client-controlled wildcard subpath
- Why exploitation is possible: The route does not sufficiently constrain the supplied path, allowing traversal into unintended upstream endpoints while the gateway attaches pooled provider credentials
Why this happens
The underlying defect is an insufficiently constrained path component used to construct an upstream URL. Client-controlled path data is spliced into a privileged request target without canonicalization, allowlisting, or strict route-boundary enforcement. This maps primarily to CWE-22: Path Traversal and is related to CWE-441: Unintended Proxy or Intermediary ('Confused Deputy'), because the gateway can be induced to use the operator's credentials on behalf of a less-privileged caller.
Potential impact
- Unauthorized access to upstream API functionality
- Consumption or abuse of pooled provider quotas
- Exposure of responses returned by unintended upstream endpoints
- Disclosure or misuse of operator-owned credentials through forwarded requests
- Increased costs, service disruption, or provider account restrictions
General mitigation guidance
Mitigation generally focuses on separating tenant-controlled routing from privileged upstream request construction.
Common defensive patterns include:
- Restricting upstream destinations and paths with explicit route allowlists
- Canonicalizing and validating path components before URL construction
- Rejecting traversal sequences, encoded separators, and unexpected path forms
- Keeping tenant authorization checks aligned with each upstream operation
- Avoiding shared credentials where per-tenant credentials or narrowly scoped tokens are feasible
- Applying least privilege, quota controls, and destination-level network policies to gateway workers
- Preventing client input from selecting arbitrary hosts, bases, or provider endpoints
How teams detect issues like this
Detection can include:
- Static analysis for string concatenation or URL joining involving request paths and privileged upstream clients
- Code review checks for wildcard routes lacking canonicalization and destination allowlisting
- Runtime logging of normalized route paths, selected upstream operations, and tenant-to-provider mappings
- Alerts for traversal markers, encoded separators, unexpected endpoint prefixes, or unusual quota consumption
- Policy enforcement requiring approved upstream destinations and explicit route schemas
- Automated security review tools that identify SSRF, proxy-confusion, and path-validation patterns

