Fragmented packets during stream setup are not handled correctly #10
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: jjkiers/layer4-proxy#10
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When the tcp stream has started with fragmented packets, the code fails with the message that a packet is too long or too short to have a full TLS message.
This then leads to the proxy not being able to find the backend, and therefore going to the default backend (which is usually ban, meaning the connection will be unceremoniously closed).
Some example code to try, based on ChatGPT:
To use a dedicated library like
rustls
for accurate TLS ClientHello parsing without terminating TLS, you'll need to focus on extracting the information from the packets rather than handling the full TLS handshake. A more efficient method is to use thetls-parser
crate, which is specifically designed for parsing TLS packets.Here's an example demonstrating how you can parse the TLS ClientHello message to extract the SNI using
tls-parser
without modifying incoming traffic:First, add the dependencies to your
Cargo.toml
:Now, you can create the proxy application:
Explanation:
tls-parser
: This crate is used to parse the TLS ClientHello message and extract the SNI. It does not perform any certificate authentication or encrypted communication.SNI Extraction: The
extract_sni
function usestls-parser
to locate the SNI within the ClientHello message. It checks for the TLS extension containing the SNI and extracts the host name.Traffic Forwarding: The initial buffer reads and forwards traffic to the backend without any modification, ensuring connection integrity.
This setup should meet your requirements by checking the SNI without altering traffic and without dealing with certificates in the proxy.
The fix from #11 didn't work in the end. Not sure why though.