Skip to content

Add headers validation check to prevent crash#55749

Open
vzaidman wants to merge 3 commits intofacebook:mainfrom
vzaidman:export-D94375533
Open

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

Conversation

@vzaidman
Copy link
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

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
@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

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
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
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 meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants