Back to blog
protocol-violationshttptlssmtppacket-analysislearning

When packets break the rules: investigating protocol violations

Every protocol has rules, and attackers love breaking them. Learn to identify HTTP framing violations, TLS handshake failures, and SMTP command sequence abuse using PcapHub's packet viewer.

PcapHubSeptember 28, 20269 min read

Every protocol has rules. HTTP expects a valid request line before headers. TLS requires a proper handshake before encrypting anything. SMTP insists you say hello before you start sending mail. These rules exist because distributed systems need shared expectations, and when those expectations break, interesting things happen.

Protocol violations occur when network traffic deviates from the standards defined in RFCs. Sometimes the cause is innocent: a misconfigured load balancer, a legacy client that predates the current spec, or a developer who read the RFC but skipped the part about MUST vs. SHOULD. Other times, the violations are deliberate, crafted by attackers to probe, confuse, or exploit. Either way, learning to spot them in packet captures is one of the most practical skills in network analysis.

This article walks through three common categories of protocol violations, why they happen, and how to investigate them. We have included purpose-built reference captures for each section, and you can open them directly in PcapHub's packet viewer to follow along.

HTTP Framing Violations: When Requests Go Off Script

HTTP is deceptively simple on the surface. A request line, some headers, maybe a body. But the framing rules, how a receiver knows where one message ends and the next begins, are where things get subtle. And subtle is where vulnerabilities hide.

Malformed Request Lines

RFC 9110 defines the request line format as METHOD SP URI SP HTTP-version CRLF. Every piece matters. The method must be a recognized token. The URI must be properly formatted. The version must follow the HTTP/x.y pattern. When any of these are wrong, you have a protocol violation.

In practice, malformed request lines show up in a few ways. Sometimes a client sends an HTTP request to a non-HTTP port, and the server interprets the bytes as garbage. Sometimes a scanner throws deliberately broken requests at a server to see how it responds, because error handling paths are where bugs live. And sometimes, someone is testing for request smuggling by sending ambiguous framing.

The interesting question is always: what does the server do with it? A well-behaved server returns 400 Bad Request and moves on. A poorly implemented one might try to parse the garbage, and that parsing attempt is where memory corruption, injection, or other vulnerabilities emerge.

Content-Length Mismatches and Chunked Encoding Confusion

The most dangerous HTTP framing violations involve disagreements about message boundaries. When a request includes both Content-Length and Transfer-Encoding: chunked, or when Content-Length does not match the actual body size, different intermediaries may interpret the stream differently. A reverse proxy might see one request where the backend sees two. This is the foundation of HTTP request smuggling.

In a capture, look for responses with status codes like 400, 405, or 501 following requests with unusual header combinations. If a server receives a method it does not support or a content framing it cannot parse, the error response tells you something went wrong. Multiple rapid errors from the same source often indicate automated probing.

How to investigate: Open the capture in PcapHub's viewer and type http.request in the display filter bar to isolate HTTP requests. Examine the request line in the packet detail pane. Switch the filter to http.response.code >= 400 to find error responses. To see the raw bytes as they were sent, right-click a packet and select "Follow TCP Stream" to open the stream viewer, which shows the full bidirectional conversation with client and server data clearly separated.

trypcaphub/learn-http-framing-and-request-line-violations-2

View this capture on PcapHub

Open Capture

Use the display filter presets in PcapHub's viewer toolbar. The "HTTP" preset is a quick way to isolate web traffic. If you see a burst of 400/405/501 responses to a single client in the Info column, that is almost certainly a scanner or a smuggling attempt, not a confused browser.

TLS Handshake Failures: Encryption's Awkward First Date

TLS is the protocol that makes HTTPS, SMTPS, IMAPS, and dozens of other secure protocols work. Before any encrypted data flows, client and server must complete a handshake: agree on a protocol version, select a cipher suite, exchange certificates, and derive session keys. When any step fails, you get a protocol violation. And TLS violations are surprisingly common.

Port Confusion: Speaking Plaintext to an Encrypted Listener

One of the most frequent TLS violations is not a TLS problem at all. It happens when a client sends plaintext (usually HTTP) to a port expecting TLS. The TLS listener receives bytes that do not start with a valid ClientHello (which always begins with byte 0x16, the TLS handshake content type), and responds with a fatal alert or simply drops the connection.

This is the digital equivalent of walking into a meeting and speaking French when everyone expects English. It is not hostile, just incompatible. You will see this when someone types http:// instead of https://, when a load balancer health check hits the wrong port, or when an application is misconfigured to use plaintext on a TLS-enabled endpoint.

In a capture, the signature is clear: a TCP connection to a known TLS port (443, 8443, 465) where the first client payload is not a TLS record. The server typically responds with a TLS alert (content type 0x15) containing alert level 2 (fatal) and description 70 (protocol_version) or 40 (handshake_failure).

Version and Cipher Mismatches

Even when both sides speak TLS, they might not speak the same dialect. A client offering only TLS 1.0 to a server that requires 1.2 or higher will be rejected. A client proposing cipher suites that the server considers too weak (RC4, export ciphers, NULL encryption) will receive a handshake_failure alert.

These violations often indicate outdated clients. Legacy devices, old API integrations, and embedded systems running ancient TLS libraries are the usual suspects. The security implications are real: these clients are often the ones most vulnerable to downgrade attacks, and their presence on your network tells you something about your technical debt.

Certificate Problems

The TLS handshake includes certificate validation, and violations here range from expired certificates (the most common) to self-signed certificates, hostname mismatches, and untrusted CAs. In the packet viewer, you can see the handshake fail: the client sends a ClientHello, the server responds with its certificate, and then... nothing. No client key exchange. Just a TCP RST or a TLS alert. Expand the TLS layer in the packet detail pane to inspect the certificate fields and alert descriptions.

How to investigate: Filter with tls.alert_message to find all TLS alerts. Use tls.handshake.type == 1 to see ClientHellos and expand the TLS layer in the packet detail pane to check what versions and ciphers the client offered. Click on a packet and look at the hex dump to compare the first bytes of client payloads: 0x16 0x03 indicates a TLS record, anything else is plaintext hitting a TLS port. Filter with tls.handshake.type == 2 (ServerHello) to see what the server selected, if it got that far.

trypcaphub/learn-tls-port-confusion-and-handshake-failures-2

View this capture on PcapHub

Open Capture

Not every TLS alert is an attack. Expired certificates, version mismatches, and SNI failures are routine operational issues. The key is volume and pattern: a single handshake failure is Tuesday. Fifty from the same source in ten minutes is worth investigating.

SMTP Command Sequence Violations: Skipping the Pleasantries

SMTP is a protocol with manners. Before you can send an email, you must introduce yourself (EHLO), specify the sender (MAIL FROM), declare the recipient (RCPT TO), and only then begin transmitting message data (DATA). Skip a step, repeat one out of order, or say something unexpected, and the server will let you know with a pointed error code.

The Required Sequence

The SMTP state machine is strict about ordering:

  1. Connect and receive the server's 220 greeting
  2. Send EHLO (or HELO for the truly old-school)
  3. Optionally negotiate STARTTLS
  4. MAIL FROM to set the envelope sender
  5. RCPT TO to set the envelope recipient (can be repeated for multiple recipients)
  6. DATA to begin the message body
  7. A lone . on a line to end the message
  8. QUIT to close the session

Violating this sequence, sending DATA before MAIL FROM, sending RCPT TO before EHLO, or issuing commands the server has not advertised, results in 500-series error codes. Error 503 ("Bad sequence of commands") is the server's way of saying "we are not there yet in our conversation."

Why Sequence Violations Happen

Legitimate sequence violations usually come from buggy email clients or poorly implemented SMTP libraries that do not properly track session state. The client might assume the server supports PIPELINING (sending multiple commands without waiting for responses) when it does not, or it might skip EHLO and jump straight to MAIL FROM because "it worked on the test server."

Malicious sequence violations are different. Spambots and email exploitation tools often blast through the SMTP sequence as fast as possible, ignoring errors and hoping something sticks. They might skip EHLO entirely, attempt RCPT TO for hundreds of addresses without a MAIL FROM, or try to send DATA payloads containing exploit code for known mail server vulnerabilities. The error responses they receive (and ignore) tell the whole story.

The STARTTLS Dance

STARTTLS adds another opportunity for protocol violations. The command upgrades a plaintext SMTP connection to TLS, but the transition has to be clean. The client sends STARTTLS, the server responds with 220 (go ahead), and the very next bytes must be a TLS ClientHello. If the client sends another SMTP command instead of initiating TLS, or if it sends TLS records before receiving the 220 response, the session is in an undefined state.

Some implementations handle this gracefully by resetting the connection. Others... do not. STARTTLS stripping attacks work by intercepting the 220 response and replacing it with an error, causing the client to fall back to plaintext, now sending credentials and message content in the clear.

How to investigate: Filter with smtp.req.command to see all SMTP commands in order. Check for 5xx response codes, especially 503 (bad sequence) and 550 (mailbox not found, often indicating enumeration). Look at the timing between commands: legitimate email clients wait for each response before sending the next command; bots and scanners fire commands in rapid succession. Right-click on any SMTP packet and use "Follow TCP Stream" to see the full conversation laid out in order, making it easy to spot where the sequence went wrong and whether STARTTLS was offered, attempted, and completed.

trypcaphub/learn-smtp-command-sequence-violations-2

View this capture on PcapHub

Open Capture

SMTP captures from production mail servers may contain email addresses, message headers, and potentially message content. Always check what is in a capture before sharing it. The reference captures above were generated in an isolated lab environment with no real email data.

Putting It All Together

Protocol violations are not just technical curiosities. They are diagnostic signals. Each one tells a story:

  • HTTP 400 errors in bursts point to scanners probing your web infrastructure, testing for request smuggling, or looking for misconfigured endpoints.
  • TLS handshake failures reveal outdated clients, misconfigured services, or port confusion that might indicate infrastructure changes that did not fully propagate.
  • SMTP sequence errors expose spam bots, misconfigured mail clients, or someone poking at your mail server to enumerate valid addresses.

The common thread is that protocol violations rarely happen in isolation. A single malformed request is noise. Ten malformed requests from the same source in the same minute is a pattern. Patterns lead to investigations, and investigations lead to answers.

Quick Reference: Display Filters

What to FindDisplay Filter
HTTP errorshttp.response.code >= 400
HTTP requestshttp.request
TLS alertstls.alert_message
TLS ClientHellotls.handshake.type == 1
Plaintext on TLS portFirst payload byte != 0x16 on port 443/8443
SMTP commandssmtp.req.command
SMTP errorssmtp.response.code >= 500
SMTP STARTTLSsmtp.req.command == "STARTTLS"

The three reference captures linked throughout this article are available for hands-on analysis. Open them in PcapHub's packet viewer, apply the filters from the table above, and use the stream viewer to trace full conversations. The best way to learn what abnormal looks like is to study it next to normal traffic, and that is exactly what these captures provide.