Skip to content

Fix CRLF injection in Connection.connect via target_host parameter - #22

Open
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/vulnerability-findings-memory-51a7
Open

Fix CRLF injection in Connection.connect via target_host parameter#22
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/vulnerability-findings-memory-51a7

Conversation

@cursor

@cursor cursor Bot commented Aug 6, 2026

Copy link
Copy Markdown

Summary

Fixes a CRLF injection vulnerability in RubyProxyHeaders::Connection#connect where the target_host and target_port parameters are interpolated directly into the raw HTTP CONNECT request line without validation for control characters (CR, LF, NUL).

Problem

The build_connect_request method constructs a CONNECT request by directly interpolating target_host:

"CONNECT #{target_host}:#{target_port} HTTP/1.1"
"Host: #{target_host}:#{target_port}"

If a consuming application passes user-derived input as the target hostname, an attacker can inject CRLF sequences to smuggle HTTP requests or headers through the proxy.

While validate_header! was already applied to proxy header values (since v0.2.1), this same validation was missing for the request-line target parameters.

Fix

  • Added validate_connect_target! private method that checks both target_host and target_port against INVALID_HEADER_VALUE_RE (rejects CR, LF, NUL)
  • Validation runs at the top of connect(), before any network I/O (fail fast)
  • Added RSpec coverage for CR, LF, NUL in target_host and CR in target_port

Impact

This is a defense-in-depth fix. Exploitation requires a consuming application to pass unsanitized user input directly as a target hostname to Connection.connect(). The fix ensures the library rejects malicious input regardless of the caller's validation practices.

Open in Web View Automation 

Validate target_host and target_port for CR, LF, and NUL characters
before interpolating them into the raw CONNECT request line. This
prevents HTTP request smuggling through the proxy when a consuming
application passes user-derived input as the connection target.

The validation uses the same INVALID_HEADER_VALUE_RE regex already
used by validate_header! for proxy header values, ensuring consistency.
Validation runs before any network I/O (fail fast).

Adds specs covering CR, LF, NUL in target_host and CR in target_port.

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

@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: approval criteria were met (Bugbot/Security Agent not present; CI passed; no policy-required human review), but GitHub blocked bot self-approval on this PR. Existing human approval remains; no reviewers were assigned.

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.

2 participants