Skip to content

fix: prevent CRLF injection in CONNECT request headers - #42

Open
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/vulnerability-findings-memory-ba7f
Open

fix: prevent CRLF injection in CONNECT request headers#42
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/vulnerability-findings-memory-ba7f

Conversation

@cursor

@cursor cursor Bot commented Aug 6, 2026

Copy link
Copy Markdown

Summary

Fixes a CRLF header injection vulnerability (CWE-113) in buildConnectRequest().

Problem

The buildConnectRequest function in lib/core/utils.js interpolated user-provided header names and values directly into the raw HTTP CONNECT request string without any validation. Since this library constructs raw TCP protocol data (bypassing Node.js's built-in http.validateHeaderName()/http.validateHeaderValue() checks), a malicious value containing \r\n could inject arbitrary headers into the CONNECT request — including overriding Proxy-Authorization credentials.

Example attack payload:

proxyHeaders: { 'X-ProxyMesh-Country': 'US\r\nProxy-Authorization: Basic ZXZpbDpldmls' }

This would produce a CONNECT request where the injected Proxy-Authorization appears as a separate, legitimate header line.

Fix

  • Added validateHeaderName(name) and validateHeaderValue(value) functions that reject any string containing \r, \n, or NUL (\0) characters with a descriptive TypeError.
  • buildConnectRequest now calls both validators before interpolating each header entry.
  • Both validators are also exported from the package root for consumers who want to pre-validate input.

Testing

Verified that:

  • Normal headers continue to work as expected
  • CRLF in header values throws TypeError
  • CRLF in header names throws TypeError
  • NUL bytes in values throw TypeError
  • Map-based headers are also validated
Open in Web View Automation 

The buildConnectRequest function interpolated header names and values
directly into the raw HTTP CONNECT request without validation. This
allowed CRLF sequences in header values to inject arbitrary headers
into the proxy CONNECT request (CWE-113).

Add validateHeaderName() and validateHeaderValue() that reject names
or values containing CR, LF, or NUL characters. These are called
automatically in buildConnectRequest and also exported for consumers
who want to pre-validate input.

Co-authored-by: ProxyMesh AI <proxymeshai@users.noreply.github.com>
@proxymesh
proxymesh marked this pull request as ready for review August 6, 2026 14:19
Co-authored-by: ProxyMesh AI <proxymeshai@users.noreply.github.com>
@cursor
cursor Bot requested review from proxymesh and proxymeshai August 6, 2026 14:21

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Left a non-blocking comment: not approving because Cursor Bugbot and Cursor Security Agent were not present, this is not a Dependabot version bump, and the integration check failed. Assigned proxymesh and proxymeshai for human review.

Open in Web View Automation 

Sent by Cursor Approval Agent: dependabot approver

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.

1 participant