Skip to content

Add headers validation check to prevent crash#55749

Closed
vzaidman wants to merge 3 commits into
facebook:mainfrom
vzaidman:export-D94375533
Closed

Add headers validation check to prevent crash#55749
vzaidman wants to merge 3 commits into
facebook:mainfrom
vzaidman:export-D94375533

Conversation

@vzaidman
Copy link
Copy Markdown
Contributor

Summary:
Add defensive checks when processing custom headers to ensure:

  1. Header keys are valid NSString instances before using them
  2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 25, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Feb 25, 2026

@vzaidman has exported this pull request. If you are a Meta employee, you can view the originating Diff in D94375533.

vzaidman added a commit to vzaidman/react-native that referenced this pull request Feb 25, 2026
Summary:

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533
@vzaidman vzaidman force-pushed the export-D94375533 branch 2 times, most recently from 5a1eefa to 6b1b743 Compare February 25, 2026 17:02
vzaidman added a commit to vzaidman/react-native that referenced this pull request Feb 25, 2026
Summary:
Pull Request resolved: facebook#55749

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533
vzaidman added a commit to vzaidman/react-native that referenced this pull request Feb 26, 2026
Summary:

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533
vzaidman added a commit to vzaidman/react-native that referenced this pull request Feb 26, 2026
Summary:

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533
vzaidman added a commit to vzaidman/react-native that referenced this pull request Feb 26, 2026
Summary:
Pull Request resolved: facebook#55749

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533
@vzaidman vzaidman force-pushed the export-D94375533 branch 2 times, most recently from e55f331 to 45995fd Compare February 26, 2026 12:55
vzaidman added a commit to vzaidman/react-native that referenced this pull request Feb 26, 2026
Summary:

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533
vzaidman added a commit to vzaidman/react-native that referenced this pull request Feb 26, 2026
Summary:
Pull Request resolved: facebook#55749

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533
vzaidman added a commit to vzaidman/react-native that referenced this pull request Feb 26, 2026
Summary:
Pull Request resolved: facebook#55749

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533
vzaidman added a commit to vzaidman/react-native that referenced this pull request Feb 26, 2026
Summary:
Pull Request resolved: facebook#55749

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533
@vzaidman vzaidman force-pushed the export-D94375533 branch 2 times, most recently from 3716811 to 55a6e3c Compare February 26, 2026 13:17
vzaidman added a commit to vzaidman/react-native that referenced this pull request Feb 26, 2026
Summary:
Pull Request resolved: facebook#55749

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533
vzaidman added a commit to vzaidman/react-native that referenced this pull request Feb 26, 2026
Summary:

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533
vzaidman added a commit to vzaidman/react-native that referenced this pull request Feb 26, 2026
Summary:

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533
vzaidman added a commit to vzaidman/react-native that referenced this pull request Feb 26, 2026
Summary:
Pull Request resolved: facebook#55749

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533
vzaidman added a commit to vzaidman/react-native that referenced this pull request Feb 26, 2026
Summary:
Pull Request resolved: facebook#55749

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533
@vzaidman vzaidman force-pushed the export-D94375533 branch 2 times, most recently from 4ff1d2e to 3f4c40e Compare February 27, 2026 12:30
vzaidman added a commit to vzaidman/react-native that referenced this pull request Feb 27, 2026
Summary:

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533
Vitali Zaidman added 2 commits February 27, 2026 04:32
Summary:
Add defensive check to validate the WebSocket URL before attempting to connect.
This prevents potential crashes when an invalid or nil URL is passed to the
WebSocket module, which could cause XPC serialization failures deep in the
network stack.

The crash was observed in  during XPC serialization when
SocketRocket attempted to open a connection with invalid URL data.

Differential Revision:
[to be generated]

D94375527
Summary:
Add defensive check to validate components.URL before using it to load cookies.
If NSURLComponents fails to parse the URL or returns nil for components.URL,
this prevents passing nil to cookiesForURL which could cause issues in the
network stack.

Differential Revision: D94375528
vzaidman added a commit to vzaidman/react-native that referenced this pull request Feb 27, 2026
Summary:
Pull Request resolved: facebook#55749

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533
vzaidman added a commit to vzaidman/react-native that referenced this pull request Feb 27, 2026
Summary:

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533
vzaidman added a commit to vzaidman/react-native that referenced this pull request Feb 27, 2026
Summary:
Pull Request resolved: facebook#55749

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533
@vzaidman vzaidman force-pushed the export-D94375533 branch 2 times, most recently from c643da0 to 2b802f3 Compare February 27, 2026 15:40
vzaidman added a commit to vzaidman/react-native that referenced this pull request Feb 27, 2026
Summary:

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533
Summary:
Pull Request resolved: facebook#55749

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Differential Revision: D94375533
@meta-codesync meta-codesync Bot closed this in e2fdf0f Mar 3, 2026
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Mar 3, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Mar 3, 2026

This pull request has been merged in e2fdf0f.

zoontek pushed a commit to zoontek/react-native that referenced this pull request Mar 9, 2026
Summary:
Pull Request resolved: facebook#55749

Add defensive checks when processing custom headers to ensure:
1. Header keys are valid NSString instances before using them
2. Header values are successfully converted before adding to the request

This prevents potential crashes when invalid header data (non-string keys or values that fail conversion) is passed from JavaScript to the WebSocket module.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D94375533

fbshipit-source-id: 8af25eb2e2d5426e2bae5503a88cc5bc160b84cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants