Skip to content

Response, New York. Noah Park: Check Point Patches Actively Exploited Management Server Path Traversal. Detection, Dallas. Ava Okello: Report Finds Nearly Half of Deployed Detections Need Attention Before SOCs Can Trust Them.

SOCtember

Always First. Fast SOC News.

Book of Zeek page on conn.log, the connection log that tracks both TCP and UDP.
Screenshot: Book of Zeek, Common Logs, conn.log, the Zeek Project (fair use).

Tools

Did You Know: A Zeek conn.log Entry Does Not Mean Two Hosts Talked, and the conn_state and history Fields Show Whether Anyone Answered

Zeek writes a conn.log record for connection attempts as well as completed sessions, for UDP as well as TCP. The conn_state code says how the exchange began and ended, and the history string records which side sent what. Reading both before calling a hit "contact" can separate a refused probe from a real conversation.

James Whitford, ToolsAustin3 min read

AUSTIN - A line in Zeek's conn.log that pairs an internal host with a suspicious address is not, on its own, evidence that the two exchanged anything. The Zeek documentation calls the connection log one of the most important logs Zeek creates and notes that it tracks stateless UDP as well as stateful TCP. It also records attempts that never got an answer. The fields that tell those cases apart are conn_state and history, and both are easy to skip when an analyst is matching addresses against an indicator list.

Book of Zeek explaining an SF connection state and the ShADadFf history string, letter by letter.
Screenshot: Book of Zeek, conn.log, Understanding the Second conn.log Entry, the Zeek Project (fair use).

The Conn::Info script reference lists the possible conn_state values. S0 means a connection attempt was seen with no reply. REJ means the attempt was rejected. RSTOS0 means the originator sent a SYN followed by a RST and Zeek never saw a SYN-ACK, and SH means a SYN followed by a FIN with no SYN-ACK. SF means normal establishment and termination, S1 means established but not terminated, and OTH means no SYN was seen, only midstream traffic. An S0 or REJ record for a command-and-control address shows a host tried to reach it. It does not show that the server answered.

Zeek script reference listing the possible conn_state values, from S0 to OTH.
Screenshot: Zeek script reference, base/protocols/conn/main.zeek, Conn::Info conn_state, the Zeek Project (fair use).

UDP needs extra care. The Book of Zeek says UDP has no concept of state, and that SF on a UDP flow means Zeek assessed the conversation as a normal establishment and termination. In the conn_state function in Zeek's source, a UDP flow is SF when both sides were active and S0 when only the originator was. The documentation's DNS example shows SF with a history of just Dd, meaning each side sent data.

The history string carries the detail. Uppercase letters are actions by the originator and lowercase letters are actions by the responder. The Book of Zeek walks through ShADadFf for an HTTP session: the originator sent a SYN, the responder a SYN-ACK, the originator an ACK and then data, the responder an ACK and data, and each side a FIN. A history with no lowercase d means Zeek saw no payload from the responder. The script reference adds two limits. The a, d, i and q flags are recorded at most once in each direction, so Dd does not count packets. The c, g, t and w flags are logarithmic, so a second instance means the event was seen at least 10 times and a third at least 100.

Zeek script reference table of history letters, including bad checksums, content gaps and the caret for a flipped connection.
Screenshot: Zeek script reference, base/protocols/conn/main.zeek, Conn::Info history, the Zeek Project (fair use).

Direction is not always what it seems either. Zeek's connection handling documentation says the first packet usually decides which endpoint is the originator, but when that packet's source port is in likely_server_ports, Zeek flips the roles and adds a caret (^) to the history. A record that starts with ^ has had its originator and responder swapped by that heuristic.

Zeek developer documentation on flipping connections and the caret added to history.
Screenshot: Zeek documentation, Connection Handling, Flipping Connections, the Zeek Project (fair use).

Two more fields shape what the rest of the record can prove. The script reference says missed_bytes counts bytes missed in content gaps, which is representative of packet loss, and that a nonzero value will normally cause protocol analysis to fail. It also says local_orig and local_resp stay empty if Site::local_nets is not defined.

For a SOC team, the checks are short. Read conn_state before treating a conn.log hit as contact, and keep S0, REJ, RSTOS0 and SH records as attempts, not sessions. Look for a lowercase d in history before saying a remote server sent anything back. Check for a leading ^ before writing up who initiated. Check missed_bytes before reading the absence of an HTTP or TLS log as proof nothing happened there. Make sure Site::local_nets is set so the local fields mean something.

About the Author

James Whitford

James Whitford covers SOC tooling and detection-as-code workflows for SOCtember from Austin.

Related stories

Tools desk