Skip to content

Fix CRLF header injection in CONNECT request - #17

Merged
proxymesh merged 4 commits into
mainfrom
cursor/vulnerability-hunter-agent-c360
Jul 30, 2026
Merged

Fix CRLF header injection in CONNECT request#17
proxymesh merged 4 commits into
mainfrom
cursor/vulnerability-hunter-agent-c360

Conversation

@cursor

@cursor cursor Bot commented Jul 30, 2026

Copy link
Copy Markdown

Summary

Fixes a CRLF header injection vulnerability in the HTTP CONNECT request construction. Header names and values from proxy_connect_request_headers were interpolated directly into the raw CONNECT request buffer without sanitization, allowing HTTP request smuggling via the proxy if user-derived data flows into header values.

Changes

  • lib/ruby_proxy_headers.rb — Added RubyProxyHeaders.validate_header!(name, value) method that raises ArgumentError if a header name or value contains CR (\r), LF (\n), or NUL (\0) bytes.
  • lib/ruby_proxy_headers/net_http.rb — Calls validate_header! before interpolating each header into the CONNECT request buffer (line 85).
  • lib/ruby_proxy_headers/connection.rb — Same validation applied in build_connect_request before appending custom proxy headers.
  • spec/validate_header_spec.rb — Tests covering clean headers, CR/LF/NUL/CRLF rejection in names and values, and to_s coercion of non-string arguments.

Security Impact

Without this fix, an attacker who can influence proxy CONNECT header values (e.g., through an application that passes user input as X-ProxyMesh-IP) can inject arbitrary headers into the CONNECT request sent to the proxy, enabling request smuggling, proxy authentication manipulation, or IP spoofing through injected proxy control headers.

Open in Web View Automation 

Add RubyProxyHeaders.validate_header! to reject header names and values
containing CR, LF, or NUL bytes before they are interpolated into raw
HTTP CONNECT requests. This prevents HTTP request smuggling via the
proxy when user-derived data flows into proxy_connect_request_headers.

Applied in both net_http.rb (production code path) and connection.rb
(standalone Connection class). Raises ArgumentError with a descriptive
message so callers are alerted to the injection attempt rather than
silently stripping characters.

Co-authored-by: ProxyMesh AI <proxymeshai@users.noreply.github.com>
@proxymesh
proxymesh marked this pull request as ready for review July 30, 2026 15:53
@proxymesh
proxymesh enabled auto-merge July 30, 2026 15:54

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

Stale comment

Left a non-blocking review: this is a security-sensitive CONNECT header validation change, not a Dependabot version bump, so it is not auto-approved. Human review is required; a reviewer has been assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: oss dependabot approver

@cursor
cursor Bot requested a review from proxymesh July 30, 2026 15:54
Runs 'bundle exec rspec' on push to main and on pull requests across
Ruby 3.1, 3.2, and 3.3. Also adds webmock as a dev dependency in the
gemspec since spec/spec_helper.rb requires it.

Co-authored-by: ProxyMesh AI <proxymeshai@users.noreply.github.com>

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

Stale comment

Left a non-blocking review: this is a security-sensitive CONNECT header validation change, not a Dependabot version bump, so it is not auto-approved. Human review is required; a reviewer is already assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: oss dependabot approver

Remove push trigger for unit tests workflow

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

Stale comment

Left a non-blocking review: this is a security-sensitive CONNECT header validation change, not a Dependabot version bump, so it is not auto-approved. Human review is required; a reviewer is already assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: oss dependabot approver

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

Stale comment

Left a non-blocking review: this is a security-sensitive CONNECT header validation change, not a Dependabot version bump, so it is not auto-approved. Human review is required; a reviewer is already assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: oss dependabot approver

@cursor
cursor Bot force-pushed the cursor/vulnerability-hunter-agent-c360 branch from b5a7dc3 to e948691 Compare July 30, 2026 16:12

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

Stale comment

Left a non-blocking review: this is a security-sensitive CONNECT header validation change, not a Dependabot version bump, so it is not auto-approved. Human review is required; a reviewer is already assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: oss dependabot approver

@cursor
cursor Bot force-pushed the cursor/vulnerability-hunter-agent-c360 branch from e948691 to 1bf1ca6 Compare July 30, 2026 16:14

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

Stale comment

Left a non-blocking review: this is a security-sensitive CONNECT header validation change, not a Dependabot version bump, so it is not auto-approved. Human review is required; a reviewer is already assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: oss dependabot approver

- Pin actions/checkout to SHA (v6.0.3) across all workflows
- Pin rubygems/release-gem to SHA (v1.2.0)
- Keep ruby/setup-ruby@v1 unpinned per maintainer guidance (pinning
  freezes available Ruby versions)
- Update Gemfile.lock with webmock dependency and refreshed checksums
- Fix BUNDLED WITH to 2.5.0 (bundler 4.0.8 is incompatible with the
  Ruby 3.1 CI matrix entry)

Co-authored-by: ProxyMesh AI <proxymeshai@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/vulnerability-hunter-agent-c360 branch from 1bf1ca6 to 4b90e64 Compare July 30, 2026 16:17

@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 review: this is a security-sensitive CONNECT header validation change, not a Dependabot version bump, so it is not auto-approved. Human review is required; a reviewer is already assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: oss dependabot approver

@proxymesh
proxymesh merged commit 000696b into main Jul 30, 2026
5 checks passed
@proxymesh
proxymesh deleted the cursor/vulnerability-hunter-agent-c360 branch July 30, 2026 17:12
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