Summary
CodeWhale's terminal-based coding agent previously validated only the initial URL against a restricted IP blocklist to prevent SSRF, but allowed the HTTP client to follow redirects without reapplying those checks.
An attacker who can influence the requested URL could leverage HTTP redirects to reach internal or otherwise restricted network resources, bypassing the original SSRF protections.
Affected context
This vulnerability affects environments where CodeWhale's fetch_url tool is used to perform HTTP requests on behalf of the user or other components.
The issue arises when:
- The tool is configured to use an HTTP client that automatically follows redirects, and
- The initial URL is validated against a restricted-IP blocklist, but
- Redirect targets are not revalidated against the same SSRF protections.
In such setups, redirected requests can escape the initial network and IP constraints and reach internal endpoints that are not intended to be exposed.
Exploit preconditions
- Attack surface: The
fetch_urlcapability within CodeWhale that can issue HTTP/HTTPS requests. - Required access: Ability to supply or influence the URL passed into
fetch_url(for example via user input, prompt content, or external references). - Trigger point: An attacker-controlled or attacker-influenced URL that returns an HTTP redirect (3xx) to a restricted IP address or internal service.
- Why exploitation is possible: The IP restriction is enforced only on the initial resolved URL. The HTTP client's redirect behavior (following up to 5 redirects) does not re-run the same
is_restricted_ip()checks on each redirect target, allowing a redirect chain to lead into private or otherwise protected network locations.
Why this happens
The underlying issue is a partial and one-time validation of outbound URLs combined with automatic redirect handling.
While the first URL is checked against a restricted-IP blocklist to mitigate SSRF, subsequent redirect locations are trusted implicitly by the HTTP client and never revalidated.
This design assumes that redirect responses from external or semi-trusted hosts are safe, which is incorrect: an attacker-controlled endpoint can emit arbitrary redirect targets, including internal IPs, localhost, or cloud metadata addresses.
Conceptually, this maps to CWE-918: Server-Side Request Forgery (SSRF), where server-side HTTP functionality is exposed without consistently enforcing network access policies across all request stages, including redirects.
Potential impact
- Access to internal HTTP services that are not directly reachable from the public internet.
- Interaction with cloud provider metadata services, potentially disclosing credentials or configuration.
- Discovery of internal network structure and services through response content or timing.
- Use of the CodeWhale runtime as a pivot point for further attacks within the hosting environment.
- Indirect data exposure or manipulation within internal APIs that trust requests originating from the local environment.
General mitigation guidance
Effective mitigation centers on ensuring that network access controls are applied consistently for every outbound request, including redirects and retries.
Common defensive approaches include:
- Reapplying the same restricted-IP and hostname validation logic on every redirect target before issuing the next request.
- Using an HTTP client configuration that either:
- Disables automatic redirects and handles them manually with explicit validation, or
- Provides hooks to approve or deny each redirect based on security policy.
- Implementing strict allowlists for outbound destinations where feasible, rather than relying solely on blocklists.
- Segregating the runtime environment so that tooling like CodeWhale has minimal network reach and cannot directly access sensitive internal services or metadata endpoints.
- Treating all externally influenced URLs as untrusted and minimizing features that allow arbitrary URL fetching when not strictly necessary.
How teams detect issues like this
Detection efforts can focus on both code-level and behavioral indicators:
- Static analysis and code review:
- Look for HTTP client configurations that enable automatic redirects without accompanying validation callbacks.
- Identify patterns where SSRF checks (such as IP blocklists) are applied only to the initial URL but not to redirect locations.
- Flag network access helpers that expose arbitrary URL fetching to untrusted or semi-trusted inputs.
- Policy and automated tooling:
- Enforce linters or custom rules that require explicit validation for each redirect or the disabling of automatic redirect following in security-sensitive components.
- Integrate security scanning tools that understand SSRF patterns and can highlight missing checks on redirect handling.
- Runtime monitoring:
- Log outbound requests along with their final destinations and redirect chains, and alert on access to known-sensitive IP ranges (localhost, link-local addresses, metadata IPs, RFC1918 space).
- Use egress filtering or proxy solutions that can centrally enforce network access rules and provide audit trails.

