Back to Blog
high SEVERITY3 min read

fetch() with Automatic Redirects Leaks HTTPS Trust to api.tomys.top

The `withProxy()` fetch wrapper allowed automatic HTTP redirects from `api.tomys.top`, trusting the external API's domain integrity without validating final destinations. A compromised or malicious redirect response could send users to attacker-controlled phishing sites while maintaining HTTPS protocol and hostname checks that falsely appear secure.

O
By Orbis AppSec
•Technically reviewed by Anupam Mediratta•Published September 28, 2026•Reviewed September 28, 2026

Answer Summary

The `withProxy()` utility in model/utils.js used automatic redirects when fetching from `api.tomys.top`. An attacker achieving control of redirect responses from that external API could redirect users to phishing domains. The fix adds `redirect: 'manual'` to the fetch options, forcing explicit validation before following any redirect. CWE-601: URL Redirection to Untrusted Site.

Vulnerability at a Glance

cweCWE-601
fix`redirect: 'manual'` disables automatic following
riskPhishing via trusted-appearing redirect chain
languageJavaScript
root cause`redirect: 'follow'` (default) accepted destination URLs without application-level validation
vulnerabilityOpen Redirect / Unvalidated Redirect

Affected Versions

Affected unknown (first-party code)
Fixed in unknown (see PR commit)
Ecosystem not applicable (first-party code)
CVE / GHSA not assigned
CWE CWE-601: URL Redirection to Untrusted Site

The Vulnerability Explained

The withProxy() utility wraps native fetch() calls to route traffic through configurable proxies. When fetching random background images, it constructed options like this:

const fetchOptions = withProxy(
  { method: 'GET', signal: AbortSignal.timeout(5000) },
  pluginConfig,
  pluginConfig.proxy?.randomBackground,
  // ...
);

The problem: fetch() defaults to redirect: 'follow', meaning any 301/302/307 response is automatically followed without giving the application code a chance to inspect the destination. The existing validation checked that the original URL used HTTPS and matched the expected hostname—but this happens before the redirect, not after.

Here's the attack chain:
1. Application calls withProxy() to fetch from https://api.tomys.top/random-bg
2. Compromised API returns 302 Found with Location: https://attacker-phishing.com/malware
3. fetch() automatically follows to the attacker's site
4. The response returns to the application, which has no visibility into the redirect chain

The HTTPS and hostname checks provided false confidence. They validated the initial request, not where the client actually ended up.

The Fix

The change adds explicit redirect control to disable automatic following:

const fetchOptions = withProxy(
  { method: 'GET', signal: AbortSignal.timeout(5000), redirect: 'manual' },
  pluginConfig,
  pluginConfig.proxy?.randomBackground,
  // ...
);

With redirect: 'manual', fetch() returns the 3xx response instead of following it. The application can now:
- Inspect response.headers.get('location')
- Validate the destination against an allowlist
- Reject suspicious redirects before any subsequent request

This shifts security control from the external API's integrity back to the application. The signal: AbortSignal.timeout(5000) timeout remains, protecting against slow responses, but now the redirect chain is equally protected.

Key Takeaways

  • redirect: 'follow' (the default) is dangerous for external API calls: Never assume HTTPS on the original URL guarantees HTTPS on every hop in a redirect chain.

  • Proxy wrappers need redirect awareness: The withProxy() abstraction obscured fetch() behavior; security-critical options must be explicit, not inherited from defaults.

  • Hostname validation must cover final destinations: Checking api.tomys.top on request start misses attacker.com on response completion.

  • Manual redirects enable defense in depth: Even if api.tomys.top is later compromised, the application can reject unexpected destinations rather than blindly following them.

How Orbis AppSec Detected This

Source: The pluginConfig.proxy?.randomBackground configuration value controlling proxy routing for background image fetches.

Sink: The withProxy() utility's internal fetch() call, invoked with default redirect: 'follow' behavior.

Missing control: No validation of response.url after automatic redirect following; the application had no mechanism to inspect or reject redirect destinations from api.tomys.top.

CWE: CWE-601 — URL Redirection to Untrusted Site

Fix: Added redirect: 'manual' to fetch options, converting automatic redirects into inspectable responses that require explicit application-level validation before following.

Orbis AppSec automatically detected this vulnerability and opened a pull request with the fix. Try Orbis AppSec on your repositories to find and fix issues like this automatically.

Conclusion

This fix demonstrates how default fetch() behavior can undermine application security when calling external APIs. The withProxy() utility's partial HTTPS and hostname validation created a dangerous blind spot: it checked the front door but ignored where the redirect chain led. By switching to redirect: 'manual', the code regains control over the entire request lifecycle—essential when any external domain, even trusted ones like api.tomys.top, might return redirect responses.

Prevention and further reading

Frequently Asked Questions

Does the `withProxy()` utility still support proxying through api.tomys.top after the fix?

Yes, but fetch calls now receive `redirect: 'manual'`, requiring explicit handling of 3xx responses rather than automatically following them.

Why was hostname matching insufficient protection for the random background image fetch?

Hostname validation only checked the original URL, not redirect destinations. A compromised `api.tomys.top` could return a 302 to `attacker.com` while the validation logic saw only the initial HTTPS hostname match.

Which fetch option parameter changed from default behavior to explicit control?

The `redirect` option changed from implicit `'follow'` to explicit `'manual'` in the options object passed to `withProxy()`.

View the Security Fix

Check out the pull request that fixed this vulnerability

View PR #154

Related Articles

high

axios 1.18.1 CVE-2026-101898: HTTP/2 Ignores proxy and lookup

A dependency upgrade moved `axios` from 1.18.1 to 1.20.0 to pick up the fix for CVE-2026-101898, in which proxy and DNS resolution settings supplied through axios request configuration were not applied on the HTTP/2 request path. Applications that rely on `config.proxy`, `HTTP_PROXY`/`NO_PROXY` environment variables, or a custom `lookup` function as an SSRF or egress control could have those controls silently skipped for HTTP/2 requests.

critical

Cloudflare Worker Reverse Proxy SSRF via String Concatenation

A Cloudflare Worker reverse proxy built its upstream request URL by string-concatenating an environment variable with the incoming request's pathname and search string, letting a crafted path or query redirect requests to attacker-chosen hosts. The fix replaces concatenation with the `URL` object's `pathname` and `search` setters, which normalize input against the configured origin instead of blindly appending it.

high

fast-uri 3.1.2 IDN Host Bypass: CVE-2026-13676 Upgrade

A dependency tree in this repository resolved `fast-uri` 3.1.2, a version affected by CVE-2026-13676, in which improper Unicode hostname canonicalization lets a crafted URI parse to one host while the HTTP client connects to another. Because `fast-uri` is what `ajv` uses to parse and resolve URIs for `format: "uri"` validation and `$ref` resolution, any host allowlist built on its parsed output could be bypassed. The fix upgrades the resolved copy to `fast-uri` 4.1.4 and pins it with an npm `ove

high

boardcards.js parseArgs() SSRF: --board Flag Reaches Metadata IPs

The `parseArgs()` function in boardcards.js accepted a user-controlled `--board` command-line argument and passed it directly to fetch() calls without validating the URL scheme or hostname. An attacker could supply `http://169.254.169.254/latest/meta-data/` or other internal addresses to extract cloud credentials or scan internal networks.

high

Meta.get() Honored @uploadURL From Script Headers: SSRF Fix

A userscript manager's metadata parser accepted the `@uploadURL` directive from a script's own header block, so any installed or auto-updated script could silently redirect the options-page `uploadScript()` fetch to an attacker-chosen destination — including loopback, link-local metadata endpoints, and LAN addresses. The fix makes `Meta.get()` ignore `@uploadURL` when it appears in a script header, leaving the User Metadata field (validated in `Meta.getUserMeta()`) as the only way to set it, and

high

picomatch 2.3.1 ReDoS: Extglob Pattern Catastrophic Backtracking

picomatch versions below 2.3.2, 3.0.2, or 4.0.4 contain a Regular Expression Denial of Service vulnerability in extglob pattern parsing. An attacker can cause catastrophic backtracking with patterns containing nested alternations and quantifiers, freezing any Node.js process that evaluates untrusted glob expressions.