Skip to content

Harden Node.js WebSocket server handling#3391

Open
Jens-G wants to merge 2 commits intoapache:masterfrom
Jens-G:p4-node-websocket
Open

Harden Node.js WebSocket server handling#3391
Jens-G wants to merge 2 commits intoapache:masterfrom
Jens-G:p4-node-websocket

Conversation

@Jens-G
Copy link
Copy Markdown
Member

@Jens-G Jens-G commented Apr 11, 2026

Client: nodejs

  • Validate origin on WebSocket upgrade using the same CORS rules as HTTP requests
  • Fix path containment check to use trailing separator
  • Replace deprecated new Buffer() with Buffer.alloc()
  • Sanitize interpolated header values in upgrade response

Client: nodejs

- Validate origin on WebSocket upgrade using the same CORS rules
  as HTTP requests
- Fix path containment check to use trailing separator
- Replace deprecated new Buffer() with Buffer.alloc()
- Sanitize interpolated header values in upgrade response

(04)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mergeable mergeable bot added the nodejs label Apr 11, 2026
Comment on lines +570 to +572
var origin = (request.headers.origin || "").replace(/[\r\n]/g, "");
var host = (request.headers.host || "").replace(/[\r\n]/g, "");
var reqUrl = (request.url || "").replace(/[\r\n]/g, "");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can have a dedicated function to do this

Client: nodejs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants