Skip to content

fix: backport the fixes from the v1 branch#10688

Merged
jasonsaayman merged 3 commits into
v0.xfrom
fix/10685-backport-security-fixes
Apr 11, 2026
Merged

fix: backport the fixes from the v1 branch#10688
jasonsaayman merged 3 commits into
v0.xfrom
fix/10685-backport-security-fixes

Conversation

@jasonsaayman
Copy link
Copy Markdown
Member

@jasonsaayman jasonsaayman commented Apr 10, 2026

Summary by cubic

Backports v1 security hardening to axios v0.x: sanitize outgoing header values and correctly bypass proxies via NO_PROXY/no_proxy, including localhost, loopback, trailing dots, and bracketed IPv6. Also ensures proxy bypass is checked before parsing proxy URLs and uses parsed.host for correct ports/IPv6 handling.

Description

  • Summary of changes
    • Added sanitizeHeaderValue and applied it to all request headers before dispatch. Strips invalid bytes, CR/LF, and trims boundary whitespace. Supports arrays.
    • Added shouldBypassProxy to honor NO_PROXY/no_proxy (wildcards, explicit ports, trailing dots, IPv6 including bracketed, loopback aliases). Used in the Node http adapter to skip proxy when needed.
    • Run bypass check before parsing env proxy URL. Updated proxy target building to use parsed.host so ports and IPv6 are handled correctly.
  • Reasoning
    • Prevent header injection and Node “Invalid character in header content” errors.
    • Ensure hosts covered by NO_PROXY don’t leak through proxies; aligns with common semantics, including loopback aliases.
  • Additional context
    • Backport from v1. No public API changes.

Docs

  • Headers are sanitized before sending; invalid characters are removed and leading/trailing whitespace is trimmed.
  • Proxy bypass now respects NO_PROXY/no_proxy with:
    • Wildcards (e.g. *.example.com)
    • Port-specific rules (e.g. localhost:8080)
    • Loopback aliases equivalence (localhost, 127.0.0.1, ::1)
    • Bracketed IPv6 ([::1]) and hostnames with trailing dots (localhost.)

Testing

  • Added unit tests for sanitizeHeaderValue (invalid chars, boundary whitespace, arrays).
  • Added unit tests for shouldBypassProxy (wildcards, explicit ports, loopback aliases, trailing dots, bracketed IPv6).
  • Updated browser and Node adapter tests:
    • Verifies header sanitization and avoids Node header-character errors even on failed requests.
    • Ensures proxy is not used for localhost/loopback variants and respects NO_PROXY ports and wildcards, including trailing dots and bracketed IPv6.

Written for commit 5e905d2. Summary will update on new commits.

@jasonsaayman jasonsaayman self-assigned this Apr 10, 2026
@jasonsaayman jasonsaayman added priority::medium A medium priority commit::fix The PR is related to a bugfix labels Apr 10, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 8 files

Confidence score: 4/5

  • This PR looks safe to merge with minimal risk: both findings are moderate/low severity and appear to be edge-case parsing/sanitization behaviors rather than broad breakages.
  • Most significant issue is in lib/helpers/sanitizeHeaderValue.js, where boundary whitespace stripping only removes a single leading/trailing space or tab, which can leave partially unsanitized header values when multiple boundary whitespace characters are present.
  • lib/helpers/shouldBypassProxy.js may mis-handle an explicit :0 port by treating 0 as falsy and falling back to the protocol default, which can cause incorrect proxy bypass decisions for that specific input.
  • Pay close attention to lib/helpers/sanitizeHeaderValue.js and lib/helpers/shouldBypassProxy.js - edge-case input handling (multi-boundary whitespace and explicit :0 port parsing) should be verified.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="lib/helpers/sanitizeHeaderValue.js">

<violation number="1" location="lib/helpers/sanitizeHeaderValue.js:6">
P2: Boundary whitespace regex only strips one leading/trailing space or tab; values with multiple boundary whitespace characters remain partially unsanitized.</violation>
</file>

<file name="lib/helpers/shouldBypassProxy.js">

<violation number="1" location="lib/helpers/shouldBypassProxy.js:95">
P2: Explicit port `:0` is misparsed as the protocol default because `0` is treated as falsy.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread lib/helpers/sanitizeHeaderValue.js Outdated
Comment thread lib/helpers/shouldBypassProxy.js Outdated
@jasonsaayman
Copy link
Copy Markdown
Member Author

@cubic-dev-ai please review this again. Please be on the look out for any gaps in the fixes to the security concerns.

@cubic-dev-ai
Copy link
Copy Markdown
Contributor

cubic-dev-ai Bot commented Apr 11, 2026

@cubic-dev-ai please review this again. Please be on the look out for any gaps in the fixes to the security concerns.

@jasonsaayman I have started the AI code review. It will take a few minutes to complete.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 8 files

Confidence score: 3/5

  • There is a concrete behavior risk in lib/helpers/shouldBypassProxy.js: NO_PROXY only treats wildcard bypass as valid when the value is exactly *, not when * appears in a list.
  • Because this issue is high severity with high confidence, proxy bypass decisions can be wrong in real deployments, which can cause unexpected routing through a proxy.
  • Pay close attention to lib/helpers/shouldBypassProxy.js - wildcard parsing in comma/space-separated NO_PROXY entries can fail and change network behavior.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="lib/helpers/shouldBypassProxy.js">

<violation number="1" location="lib/helpers/shouldBypassProxy.js:90">
P1: `NO_PROXY` wildcard entries are only honored when the value is exactly `*`; `*` inside a comma/space-separated list is ignored, so proxy bypass can fail unexpectedly.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread lib/helpers/shouldBypassProxy.js
@jasonsaayman
Copy link
Copy Markdown
Member Author

@cubic-dev-ai please review again

@cubic-dev-ai
Copy link
Copy Markdown
Contributor

cubic-dev-ai Bot commented Apr 11, 2026

@cubic-dev-ai please review again

@jasonsaayman I have started the AI code review. It will take a few minutes to complete.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 8 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commit::fix The PR is related to a bugfix priority::medium A medium priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant