Repository navigation
test: cover http: credential redaction and FormData prototype guard - #11299
renanmpimentel wants to merge 3 commits into
Conversation
- buildFullPath: add an http: case to the credential redaction tests. Restricting the redaction regex to https: kept the whole unit suite green while leaking "admin:hunter2" into the error message. - formDataToJSON: assert that a `__proto__[isAdmin]` field cannot replace the prototype of the resulting object. Removing the `__proto__` guard kept the whole unit suite green while the result inherited `isAdmin: "true"` from an attacker-chosen prototype.
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply to a comment to ask cubic a question or push back. It learns from your replies.
Turn on auto-fix | Re-trigger cubic
[Low impact] No blocking issues identified in this test-only PR; runtime code, public APIs, and types remain unchanged. SummaryAdds two security regression tests without changing runtime code.
No new actionable issues found. Tests were inspected but not run during this review. Reviews (3) · Last reviewed commit: "chore: sync security regression tests wi..." · Reviewed by Greptile |
There was a problem hiding this comment.
PR #11299 - test: cover http: credential redaction and FormData prototype guard
Repo: axios/axios Author: @renanmpimentel Base: v1.x Files: 3 **+30/-0
CI: Unavailable: no checks returned; no build/test workflow result is present in this snapshot. Mergeability: conflicting. Reviewed head: 712a4d892bca8359199ee37ae11a8ba708dc2a4f.
Repo Profile
Axios is an npm JavaScript HTTP client for browsers and Node, with XHR/Fetch/HTTP adapters, default and named exports, interceptors, headers/errors, and paired ESM/CJS declarations. The target uses Vitest plus browser and package/module tests; v1 packaging covers older Node CJS runtimes as well as current ESM, Bun and Deno. Contributions preserve transport/security boundaries, add regression coverage and prerelease records, and defer unreleased user docs to PRE_RELEASE_DOCS.md. This review uses the actual target-branch guidance and files, not the separate local v0 checkout.
Verdict
Request changes — No concrete source defect found in this review; the missing latest-head validation and merge conflicts prevent merge approval.
Posted as a comment review for the validation/integration hold; no formal code-change request is implied beyond the specific items below.
Change Explanation And User Impact
The HTTP additions assert that credentials do not leak into serialized diagnostics. The form reconstruction tests also assert the prototype of the returned object, which catches an unsafe result even when Object.prototype itself is unchanged. No runtime behavior changes in this PR. Inferred maintainer effect: an implementation that creates a polluted result or exposes request credentials will fail a direct contract assertion rather than passing a weaker global-prototype check.
Validation scope: source/diff and regression-test review. Examples explicitly marked executed used isolated source snapshots on Node 24.18.0 with the workspace dependency installation; these were focused checks, not a clean install, full CI matrix, or full test-suite run. Author-reported test results were not treated as independently executed.
Competing PRs
Search: axios/axios open PRs, including drafts; full open-list scan plus formDataToJSON in:title,body, 11295 in:title,body, credential redaction in:title,body. Complementary searches were run across related APIs/issues; no query reached the 100-result cap and no search failed. The five explicitly excluded PRs were not reviewed or modified in this batch.
#11296 and #11328 address the same length-slot failure. #11296 uses a narrower guard and has both insertion orders plus browser HTML-form coverage, so it is preferred. #11278 preserves empty field names; #11280 supplies a benchmark; #11299 strengthens hardening tests. Those are complementary. Newly opened #11353 uses the same targeted guard as #11296, with fewer regressions and no prerelease entry; its combined length/nested/dotted cases are covered by #11296.
Preferred PR: No competing implementation supersedes this PR; continue it independently.
Unique contributions: The submitted regression cases protect this specific boundary; preserve them independently of adjacent fixes.
Action: No duplicate closure: the candidates are complementary or no equivalent solution was found.
Project Fit
North star: Reliable HTTP transport and configuration across supported JavaScript environments, without embedding application-specific policy.
Benefits: Protects credential redaction and the prototype of returned form objects.
Tradeoffs: Security tests must distinguish trusted caller config from attacker-controlled keys and avoid claiming a stronger redaction boundary than the implementation provides.
Fit: Strong — The underlying problem belongs in the transport, serializer, declarations or their maintenance tests.
Adversarial Review
Strongest objection: Security tests must distinguish trusted caller config from attacker-controlled keys and avoid claiming a stronger redaction boundary than the implementation provides. Latest-head integration evidence is still needed.
Abuse/failure modes checked: Read the credential assertions and result-prototype checks, their cleanup, and the existing hardening code they exercise. This is additional defense regression coverage, not evidence of a newly fixed vulnerability.
Result: No concrete source defect established in the examined cases; validation and integration limits remain below.
Disposition
Continue
Address the specific blockers below; no unrelated scope or complementary PR should be closed.
Semver
patch — Corrects existing behavior or strengthens internal tooling/tests without adding a public API.
Breaking Changes
None: this is test/tooling-only work or a declaration widening for already-supported runtime behavior.
Documentation
PRE_RELEASE_CHANGELOG.md records the change. No new API reference or migration is required for this scoped correction; keep the release description consistent with the behavior and limits above.
Performance And Regression Risk
Hot path touched: No shipped runtime change.
Performance concern: No shipped runtime hot path changes; tooling/type validation still needs the appropriate CI run.
Regression risk: low — the changed boundary needs regression and integration coverage, particularly after any rebase.
Evidence requested: The latest-head checks listed below; no extra benchmark requested for this scoped change.
Blocking Issues
- Latest-head build/test validation is unavailable in the returned GitHub checks. Run or attach the repository build, relevant regression suite and required package/type/browser checks before merge; review/security bots alone do not establish that they pass. This is a validation hold, not an invented source defect.
- GitHub reports merge conflicts with the current target. Resolve them and re-run relevant checks; the reviewed source snapshot is not a tested merge result.
Non-Blocking Suggestions
- Keep the returned-object prototype assertions alongside global pollution checks; they detect different failure modes.
Looks Good
- Read the credential assertions and result-prototype checks, their cleanup, and the existing hardening code they exercise. This is additional defense regression coverage, not evidence of a newly fixed vulnerability.
Summary
Two security guards in
lib/can currently be removed without any unit test failing. This PR adds one regression test for each. Test-only.http:URLs (lib/core/buildFullPath.js). Invalid-URL errors redact userinfo with/^(https?:\/{0,2})[^/?#]*@/i, but the existing test only uses anhttps:URL. Changinghttps?tohttpskeeps the suite green whilebuildFullPath(undefined, 'http:admin:[email protected]/v1')putsadmin:hunter2inerror.message, whichAxiosError.toJSON()serializes and apps commonly log.__proto__guard informDataToJSON(lib/helpers/formDataToJSON.js). The existing pollution test checks thatObject.prototypestays clean, which still holds without the guard. What the guard prevents is local: without it,__proto__[isAdmin]=truemakes the returned object inheritisAdmin: "true"(result.isAdmin === "true"), whileJSON.stringify(result)shows only{"name":"bob"}. The new test asserts the result keepsObject.prototypeand does not exposeisAdmin.Linked issue
None. Found by mutation testing and statement-removal analysis: both removals survived the full
tests/unitsuite.Changes
tests/unit/core/buildFullPath.test.js:redacts credentials in http: URLs as well as https: URLstests/unit/helpers/formDataToJSON.test.js:should not replace the prototype of the resulting objectPRE_RELEASE_CHANGELOG.md: Maintenance entryValidation
Node v26.12.1, integrated with
v1.xate6b79d9(head473d241):npm ci --ignore-scripts: passednpm run lint: passednode node_modules/typescript/bin/tsc --noEmit --strict --lib es2020,dom --module Node16 --moduleResolution Node16 index.d.ts index.d.cts: passednpm run build: passednpm run test:vitest:unit: 74 files, 1,702 tests passedgit diff --check origin/v1.x: passed; added-line secret-pattern scan: 0 matches2b169bb(temporary, reverted): narrowinghttps?tohttpsand removing the__proto__guard each made its new test fail.action_required; maintainer approval is needed before CI results exist.Compatibility and documentation
No semver impact (test-only). No
PRE_RELEASE_DOCS.mdorindex.d.ts/index.d.ctschanges needed.Checklist
PRE_RELEASE_CHANGELOG.mdentry added or updated (or AGENTS.md's automated release-preparation exception explained)action_requiredon the current head; maintainer approval is pending, so CI is not green yet.AI tooling assisted with this change; the
ai-assistedlabel is applied.Found with supertest: mutation testing plus statement-removal analysis, with every finding confirmed by running the regression against the unmodified test.
Summary by cubic
Description
Test-only PR adding two regression tests found via mutation testing and statement-removal analysis: both security guards could be removed without any existing unit test failing. These tests make sure the guards stay.
buildFullPathnow has a test covering credential redaction forhttp:URLs in invalid-URL error messages. Existing coverage only usedhttps:, so narrowing the redaction regex tohttpsalone kept the suite green while leakingadmin:hunter2intoerror.message.formDataToJSONnow has a test asserting a__proto__[isAdmin]FormData field cannot replace the prototype of the resulting object. Without the guard, the result inheritsisAdmin: "true"from an attacker-chosen prototype whileJSON.stringifyonly shows{"name":"bob"}.Docs
No documentation changes needed. Test-only change; no runtime, public API, or type changes.
PRE_RELEASE_CHANGELOG.mdgets a maintenance entry linking this PR.Testing
Two unit tests added, plus a changelog entry:
tests/unit/core/buildFullPath.test.js: redacts credentials inhttp:URLs as well ashttps:URLs.tests/unit/helpers/formDataToJSON.test.js: should not replace the prototype of the resulting object.PRE_RELEASE_CHANGELOG.md: maintenance entry referencing this PR.Verified both new tests fail against the unguarded source and pass with it restored; full unit suite passes (1519 tests). Lint passes.
Semantic version impact
Patch. Test-only change with no runtime, public API, or type impact.
Written for commit 712a4d8. Summary will update on new commits.