Skip to content

fix(fetch): reject SharedArrayBuffer-backed body views - #5601

Open
Baltsat wants to merge 1 commit into
nodejs:mainfrom
Baltsat:codex/fix-sab-bodyinit
Open

fix(fetch): reject SharedArrayBuffer-backed body views#5601
Baltsat wants to merge 1 commit into
nodejs:mainfrom
Baltsat:codex/fix-sab-bodyinit

Conversation

@Baltsat

@Baltsat Baltsat commented Jul 28, 2026

Copy link
Copy Markdown

This relates to...

Fixes #5596.

Rationale

XMLHttpRequestBodyInit recognized views only when their backing buffer was an ArrayBuffer. A typed array or DataView backed by a SharedArrayBuffer therefore fell through to string conversion, silently changing the request or response bytes.

Routing all ArrayBuffer views through the existing Web IDL BufferSource converter preserves ordinary views and rejects shared-backed views with a TypeError, as required for a non-[AllowShared] buffer source.

Changes

Features

N/A.

Bug Fixes

  • Reject Uint8Array, Buffer, and DataView bodies backed by SharedArrayBuffer in both Request and Response.
  • Preserve byte-for-byte behavior for ordinary ArrayBuffer-backed views.
  • Add focused regression coverage for both paths.

Breaking Changes and Deprecations

N/A.

Validation

  • node --test test/fetch/issue-5596.js — 7/7 passed.
  • Production-hunk revert — all six shared-view rejection cases failed; restoring the patch returned 7/7 passing.
  • npm run lint — passed.
  • npm run test:fetch — 483 fetch, 28 Web IDL, and 47 busboy tests passed.

Implementation and validation used Codex assistance. I reviewed the final diff and test results.

Status

  • I have read and agreed to the Developer's Certificate of Origin
  • Tested
  • Benchmarked (optional)
  • Documented (regression tests cover the behavior change; no user-facing API documentation changes)
  • Review ready
  • In review
  • Merge ready

Route all ArrayBuffer views through the Web IDL BufferSource converter so SharedArrayBuffer-backed views are rejected instead of being string-coerced. Add Request and Response regression coverage while preserving ordinary ArrayBuffer-backed body bytes.

User-Request: fix Undici issue 5596 | codex:oss-maintainer-loop
Signed-off-by: Konstantin Baltsat <baltsat2002@mail.ru>
Copilot AI review requested due to automatic review settings July 28, 2026 11:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@metcoder95
metcoder95 requested a review from KhafraDev July 30, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fetch: SharedArrayBuffer-backed view as request body is silently coerced to a string (lossy data corruption)

2 participants