Summary
Axios, a popular HTTP client for browsers and Node.js, incorrectly handles hostname normalization when applying NO_PROXY rules, especially for loopback addresses like localhost. (with a trailing dot) and [::1].
Under certain hostname formats, requests that developers expect to bypass the proxy instead get routed through it, enabling proxy bypass and potential SSRF attacks against loopback or internal services despite NO_PROXY protections.
Affected context
This vulnerability affects applications that:
- Use Axios (prior to 1.15.0 and 0.31.0) as an HTTP client in Node.js or browser environments, and
- Rely on NO_PROXY (or equivalent) configuration to prevent sensitive loopback or internal hosts from being accessed via a proxy.
The issue appears when Axios evaluates whether a target host should bypass the proxy based on NO_PROXY entries. Due to incomplete hostname normalization, certain syntactic variants of loopback addresses (for example localhost. or [::1]) are not matched against NO_PROXY, causing traffic that should be direct to instead flow through the configured proxy.
Exploit preconditions
- Attack surface: Any Axios-based HTTP request where the destination URL can be influenced by an attacker, such as:
- User-controlled URLs in backend services (e.g., webhooks, URL previews, metadata fetchers)
- Indirectly controlled endpoints in microservices or integration layers
- Required access: Ability to inject or control all or part of the request URL (including hostname) used by Axios within a process that has a proxy configured and NO_PROXY set for internal or loopback addresses.
- Trigger point: The moment Axios evaluates NO_PROXY rules and decides whether a given request (e.g., to
http://localhost.:portorhttp://[::1]/) should be proxied or sent directly. - Why exploitation is possible: Axios performs NO_PROXY matching on hostnames that are not fully normalized to their canonical representations. Variant hostnames that still resolve to loopback or internal addresses evade NO_PROXY matching and are sent through the proxy, contradicting configuration intent and undermining trust boundaries around internal services.
Why this happens
The core issue is an improper access control decision during proxy-bypass checks, rooted in hostname normalization and comparison logic.
Axios relies on NO_PROXY entries to decide whether certain hosts should bypass the proxy (typically loopback or internal services). However, the implementation does not normalize hostnames and IP literals into a canonical form before applying matching rules. As a result:
- Syntactic variants like
localhost.(with a trailing dot) or IPv6 literals like[::1]are treated as distinct from their more common representations (localhost,::1). - NO_PROXY patterns that were configured to protect loopback or internal hosts fail to match these variants.
This maps to:
- CWE-441: Unintended Proxy or Intermediary — access control decisions about the use of a proxy are made incorrectly, allowing traffic to traverse an intermediary against configuration intent.
- CWE-918: Server-Side Request Forgery (SSRF) — an attacker can leverage the HTTP client to make requests to otherwise protected loopback or internal endpoints.
Abstractly, the bug is an instance of inconsistent input normalization before security decisions: security policies (NO_PROXY rules) are applied to one representation of hostnames, while the actual network behavior and resolution treat multiple syntactic forms as equivalent, creating a discrepancy attackers can exploit.
Potential impact
- Requests that developers intended to keep off the proxy (e.g.,
localhost, internal hostnames) can be routed through the configured proxy. - Attackers may coerce backend services into making SSRF requests to:
- Loopback-only admin endpoints
- Cloud metadata services
- Internal microservices or management interfaces
- Exposure of sensitive internal APIs or configuration data reachable only from loopback or internal networks.
- Potential escalation from SSRF to:
- Credential theft (e.g., tokens from metadata services)
- Unauthorized administration actions on internal services
- Pivoting deeper into private network segments via the proxy.
- Violation of network segmentation assumptions and defense-in-depth models that depend on NO_PROXY honoring internal hosts.
General mitigation guidance
Mitigation focuses on ensuring consistent hostname handling and defensive network boundaries around HTTP clients:
- Normalize hostnames before policy checks:
- Apply canonicalization of hostnames and IP literals (e.g., remove trailing dots, normalize IPv6 notation) before evaluating NO_PROXY or equivalent rules.
- Standardize on a common representation of loopback and internal hosts in application-level checks.
- Strengthen NO_PROXY and proxy-handling logic:
- Treat loopback and link-local ranges as protected by default in higher-level request wrappers, regardless of NO_PROXY configuration.
- Implement a deny-by-default list for sensitive destinations (e.g.,
127.0.0.0/8,::1, metadata service addresses) that bypasses proxy usage and rejects untrusted input outright.
- Reduce trust in user-controlled URLs:
- Avoid directly passing unvalidated, user-supplied URLs to Axios. Instead, validate and constrain:
- Allowed schemes (e.g., restrict to
https), - Hostnames and IP ranges (disallow localhost, private IPs, and metadata endpoints for untrusted contexts),
- Ports and paths where applicable.
- Enforce network-level segmentation:
- Place sensitive loopback or internal services behind network controls rather than relying solely on NO_PROXY for protection.
- Use firewall rules, container networking policies, or service meshes to block unwanted egress to internal-only endpoints.
- Apply least privilege to proxies:
- Limit the proxy's ability to reach internal or administrative networks where feasible.
- Separate proxies used for external traffic from those that have access to sensitive internal services.
How teams detect issues like this
Detection can leverage both code-level and operational insights:
- Static analysis and code review:
- Flag locations where Axios is invoked with URLs influenced by external input (e.g., request parameters, headers, body fields).
- Look for reliance on NO_PROXY as the sole mechanism guarding access to loopback or internal endpoints.
- Review any URL-normalization utilities and ensure they are applied before security-related hostname checks.
- Configuration and policy auditing:
- Inventory services that configure Axios with proxies and NO_PROXY settings, especially those handling user-supplied URLs.
- Check for assumptions in documentation or comments that "NO_PROXY protects localhost/internal services" and treat them as potential risk indicators.
- Runtime and network monitoring:
- Monitor proxy logs for unexpected requests targeting loopback or internal-only hostnames and IP ranges.
- Use anomaly detection on outbound HTTP traffic patterns from backend services, focusing on requests originating from components that should not reach internal endpoints via the proxy.
- Automated tooling:
- Integrate security scanners or linters into CI/CD that:
- Identify Axios usage with proxy settings.
- Highlight missing hostname normalization or insufficient SSRF protections.
- Employ dynamic security testing to fuzz URL inputs and observe whether loopback/internal routes become accessible via the proxy.

