Repository navigation
fix(request): reject non-string header values before the bridge - #499
Merged
Merged
Conversation
Native reads every header value as a string, so a value of another type - an object a caller passed by mistake, a number, an array - could not cross the bridge: Android died on the ReadableNativeMap cast and iOS crashed without a visible error, before any JS could catch it. invalidHeader now refuses non-string values, so the call rejects EINVAL in JS like the other request-validation failures, before any native call or event listener is registered. fetch still normalises null and undefined headers to an empty string. Fixes #472.
RonRadtke
added a commit
that referenced
this pull request
Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #472.
invalidHeaderinutils/request.jsnow rejects a header value that is not a string withEINVAL, before any native call or event listener. It used to coerce the value withString()for its CR/LF/NUL check, so an object passed as'[object Object]'and the raw value went to native, where no platform gave JS an error it could catch:ReadableMap.getStringthrowsValue for <key> cannot be cast from ReadableNativeMap to String, which is the crash in the issue.JSValue::AsString()sends a number or boolean as text and an object as"".nullandundefinedvalues are still sent as"", as documented.Numbers and booleans are rejected too:
RequestHeadersalready declares values asstring | null | undefined, and rejecting them gives the same result on all three platforms. The cost is that a numeric header that works on Windows today now rejects there, and the caller's fix isString(value). If you would rather coerce numbers and booleans and reject only objects and arrays, that is a small change.The new case in
tests/unit/requestHardening.test.jscovers object, array, number and boolean values and checks forEINVAL, the header name in the message, no native call and no leaked listener. It fails without the fix (the request resolves) and passes with it.