fix(tests): Add hostname parser security regression tests (#1498)#1552
Closed
RanPollak wants to merge 1 commit into
Closed
fix(tests): Add hostname parser security regression tests (#1498)#1552RanPollak wants to merge 1 commit into
RanPollak wants to merge 1 commit into
Conversation
Add comprehensive regression tests for hostname parser security vulnerabilities to prevent parser differential attacks and allowlist bypasses. Tests cover: - NUL byte injection (Claude Code SOCKS5 bypass) - Control character injection (CRLF, CR, LF, TAB) - URL encoding safety - Hostname space handling - Length limits (DoS prevention) - IPv6 bracket validation - Invalid port handling - Missing port validation - Normalization consistency Test Results: - 6 tests FAIL - exposing real vulnerabilities - 3 tests PASS - confirming some protections work - 163 existing tests PASS - no regressions Security Impact: Tests reveal 6 vulnerabilities enabling parser differential attacks, HTTP request smuggling, and header injection. Fixes NVIDIA#1498 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Thank you for your interest in contributing to OpenShell, @RanPollak. This project uses a vouch system for first-time contributors. Before submitting a pull request, you need to be vouched by a maintainer. To get vouched:
See CONTRIBUTING.md for details. |
|
Thank you for your submission! We ask that you sign our Developer Certificate of Origin before we can accept your contribution. You can sign the DCO by adding a comment below using this text: I have read the DCO document and I hereby sign the DCO. You can retrigger this bot by commenting recheck in this Pull Request. Posted by the DCO Assistant Lite bot. |
Author
|
I have read the DCO document and I hereby sign the DCO. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds comprehensive regression tests for hostname parser security vulnerabilities to prevent parser differential attacks and allowlist bypasses.
Motivation
Issue #1498 requested test coverage for malformed CONNECT hostnames after the Claude Code SOCKS5 NUL-byte allowlist bypass disclosure. This ensures OpenShell's proxy hostname parser rejects malicious inputs before they reach policy evaluation.
Changes
proxy.rsparse_target()functionTest Results
6 tests currently FAIL, exposing real vulnerabilities:
test_nul_byte_in_hostname_rejected- NUL byte injection (CRITICAL)test_control_chars_in_hostname_rejected- CRLF/CR/LF/TAB injection (CRITICAL)test_hostname_with_spaces_rejected- Space handlingtest_ipv6_bracket_handling- IPv6 bracket validationtest_invalid_port_rejected- Port range validationtest_missing_port_rejected- Port requirement enforcement3 tests PASS, confirming some protections are in place:
test_encoded_hostnames_safe- URL encoding handled safelytest_hostname_length_limits- No DoS via lengthtest_hostname_normalization_consistency- Consistent case handling163 existing tests still pass - no regressions
Security Impact
Tests reveal 6 vulnerabilities enabling:
Attack Scenario Example
This is the exact vulnerability described in #1498's reference to the Claude Code SOCKS5 bypass.
Implementation Notes
These tests are intentionally failing to expose existing vulnerabilities. They serve as regression coverage and documentation of security issues that need fixing.
Maintainers can:
Next Steps
Follow-up PR will implement fixes to the
parse_target()function to make all tests pass by:Fixes #1498