Building Custom Detections with Zeek and Spicy
Evan Typanski (Senior Software Engineer · Corelight)
RVAsec 2026 · Day 1 · Madison / Jefferson / Monroe
Overview
In his RVAsec talk, "Building Custom Detections with Zeek and Spicy," Evan Typanski, a Senior Software Engineer at Corelight, delved into the powerful capabilities of Zeek, an open-source network security monitor, when combined with Spicy, an incremental parser generator. The presentation illuminated how security professionals can move beyond generic signature-based detections to craft highly specific, application-layer insights and alerts tailored to their unique network environments and threat landscapes. Typanski, with a background in security and compilers, expertly guided the audience through the technical intricacies of parsing network traffic and programming event-driven detections.

Key moments
- 0:40 What is Zeek? Open-source network security monitor
- 10:20 Analyzing the Redis RCE exploit vulnerability
- 17:00 Introducing Spicy: Incremental parser generator
- 24:00 How Zeek processes network data via events
- 30:00 Writing the Redis command detection script
- 32:00 Viewing custom detection alerts in notice.log
- 34:00 Identifying exploit red flags in redis.log
- 38:35 Q&A: Zeek's passive monitoring and latency impact
Building Custom Detections with Zeek and Spicy
Speakers: Evan Typanski, Senior Software Engineer, Corelight
Conference: RVAsec
YouTube: https://www.youtube.com/watch?v=NPToZ5OJ9zY
Overview
In his RVAsec talk, "Building Custom Detections with Zeek and Spicy," Evan Typanski, a Senior Software Engineer at Corelight, delved into the powerful capabilities of Zeek, an open-source network security monitor, when combined with Spicy, an incremental parser generator. The presentation illuminated how security professionals can move beyond generic signature-based detections to craft highly specific, application-layer insights and alerts tailored to their unique network environments and threat landscapes. Typanski, with a background in security and compilers, expertly guided the audience through the technical intricacies of parsing network traffic and programming event-driven detections.
The core of the talk centered on demonstrating how Zeek's comprehensive logging and event-driven scripting language, coupled with Spicy's ability to define custom protocol parsers, empowers defenders to detect sophisticated attacks that might otherwise evade traditional security tools. Typanski illustrated this by walking through the detection of a Redis Remote Code Execution (RCE) exploit, showcasing how granular visibility into application-level commands and data flows can reveal malicious activity. This approach is critical for organizations seeking deeper insights into their network behavior, proactive threat hunting, and robust incident response capabilities, especially when dealing with custom or obscure protocols not natively supported by off-the-shelf solutions.
Background
▶ Watch: What is Zeek? Open-source network security monitor (0:40)
The landscape of network security often relies on Intrusion Prevention Systems (IPS) and Intrusion Detection Systems (IDS) that operate primarily on signatures or predefined rules. While effective for known threats, these systems frequently struggle with novel attack vectors, custom application protocols, or highly nuanced behavioral anomalies. This is where Zeek, formerly known as Bro, offers a distinct advantage. Zeek is an open-source passive network security monitor that operates by listening to a copy of network traffic, typically via span ports or network taps. Unlike an IPS, Zeek does not actively block traffic; instead, it provides deep analysis and generates rich, comprehensive logs that serve as invaluable metadata for security investigations.
Zeek's analysis involves deep packet inspection and TCP reassembly, allowing it to understand and interpret various network protocols across different layers. The output is a series of structured logs (e.g., conn.log, http.log, dns.log, ssl.log), often in JSON or tab-separated value (TSV) format, which can be ingested by SIEM systems like Elastic, Splunk, or LogScale. These logs offer far more detail than basic NetFlow records, providing insights into connection metadata, application-layer transactions, and file transfers. Furthermore, Zeek is not merely a logging tool; it functions as an event-based programming language, enabling users to write custom scripts that react to specific network events and raise notices (alerts) when suspicious activities are detected. This programmability is crucial for moving beyond generic alerts to highly contextual and actionable intelligence. The challenge, however, arises when encountering protocols that Zeek does not natively understand, necessitating a mechanism for custom parsing – a gap filled by Spicy.
Key Findings
▶ Watch: Introducing Spicy: Incremental parser generator (17:00)
The talk highlighted several critical findings regarding advanced network detection strategies:
- Zeek's Foundational Role: Zeek provides an unparalleled foundation for network visibility through its deep packet inspection, TCP reassembly, and comprehensive log generation. These logs are not merely raw packet captures but processed metadata, significantly reducing storage requirements while enhancing investigative capabilities for current and historical analysis.
- Spicy for Custom Protocol Parsing: The introduction of Spicy is a game-changer for extending Zeek's reach. Spicy is an incremental parser generator specifically designed for network protocols. It allows security engineers to define grammars for any custom, proprietary, or obscure protocol, transforming raw byte streams into structured data that Zeek can then analyze. This capability ensures that no network traffic remains a "black box" simply because its protocol isn't widely recognized.
- Event-Driven Detection: Zeek's core strength lies in its event-based architecture. Spicy parsers can trigger custom events within Zeek scripts upon successful parsing of specific protocol elements. This enables defenders to write highly targeted detection logic that reacts instantaneously to application-layer commands, data patterns, or protocol anomalies, rather than relying on static signatures.
- Beyond Signatures: The demonstration of detecting a Redis RCE exploit underscored that effective security monitoring requires moving beyond simple signatures. By analyzing command sequences, unexpected command usage, and the content of application-layer data (e.g., detecting ELF magic bytes in a database replication stream), defenders can identify sophisticated, behavioral anomalies indicative of compromise.
- Customization and Extensibility: Zeek's scripting language, combined with its package ecosystem, offers immense flexibility. Users can define custom allow lists, configure notice behaviors (e.g., logging, emailing), and even develop and share their own Spicy parsers and Zeek scripts, fostering a collaborative approach to network security.
Technical Deep Dive
▶ Watch: Writing the Redis command detection script (30:00)
At the heart of building custom detections with Zeek and Spicy lies a deep understanding of how network traffic is parsed and how events are triggered and acted upon. Typanski elaborated on this intricate process, starting with the flow of data through the network stack.
Parsing Network Traffic with Spicy:
When network bytes stream in, Zeek automatically handles the lower layers of the protocol stack (physical, IP, TCP). The focus for custom detection often lies at the application layer. This is where Spicy becomes indispensable. Spicy parses data incrementally, processing chunks of network data as they arrive, rather than waiting for entire payloads. This makes it suitable for live traffic analysis.
Spicy is a programming language that acts as a parser generator. You define the structure of your protocol using units and grammars. A unit describes a specific piece of a protocol, like a method, URI, or version in HTTP. A grammar is composed of many such units. For protocols with variable structures, Spicy supports conditional parsing using switch statements, allowing the parser to adapt its behavior based on previously parsed fields (e.g., an opcode determining the subsequent data structure). This is crucial for protocols like Redis Serialization Protocol (RESP).
Redis Serialization Protocol (RESP):
Typanski used RESP as a practical example. RESP is a byte-oriented protocol where the first byte dictates the type of data that follows. For instance:
+: Simple String (e.g.,+OK\r\n)-: Simple Error (e.g.,-ERR unknown command\r\n):: Integer (e.g.,:1000\r\n)$: Bulk String (e.g.,$5\r\nhello\r\n): Array (e.g.,2\r\n$5\r\nhello\r\n$7\r\nrvasec\r\nfor an array of two bulk strings: "hello" and "rvasec").
Writing a Spicy parser for RESP involves defining units for each data type and a main unit that uses a switch statement on the initial byte to invoke the correct sub-unit. This approach significantly simplifies protocol parsing compared to writing raw C++ code, which is prone to buffer overflows and other memory safety issues. Spicy compiles these high-level definitions into efficient C++ parsers that integrate directly into Zeek.
Event-Based Processing with Zeek Scripting:
Once a Spicy parser is integrated, it can be configured to raise events within Zeek. An .evt file defines which events are triggered by the parser and under what conditions. For the Redis example, when the Spicy parser successfully identifies a client command, it triggers a redis_command event, passing relevant parsed data (e.g., the command string, connection details) to Zeek's scripting engine. Similarly, redis_reply or redis_error events can be triggered for server responses.
Zeek's scripting language is then used to write handlers for these events. This allows security analysts to react to specific occurrences on the network. A typical Zeek script for detection might look like this:
This script demonstrates reacting to a redis_command event. It checks if the cmd (command string) is present in a user-defined redis_allowed_commands set. The &redef &read attributes make this set customizable by administrators without modifying the core script, highlighting Zeek's flexibility. If an unknown command is detected, a NOTICE is triggered. Zeek's notice framework then handles this alert, which can be configured to log the event, send an email, or integrate with other security tools. This entire process transforms raw network packets into actionable security intelligence through structured parsing and event-driven logic.
Demo / Proof of Concept
▶ Watch: Viewing custom detection alerts in notice.log (32:00)
Evan Typanski presented a compelling demonstration focused on detecting a Redis Remote Code Execution (RCE) exploit, illustrating the practical application of Zeek and Spicy. The exploit leverages a misconfigured, unauthenticated Redis server, which is a common vulnerability.
The RCE scenario unfolds as follows:
- Replication Attack: An attacker connects to an unauthenticated Redis server and issues a
slaveof(orreplicaof) command, instructing the vulnerable server to act as a replica of the attacker's controlled malicious server. - Malicious Payload Transfer: During the replication synchronization process, the attacker's server sends an ELF file (a Linux executable/shared library) instead of a legitimate Redis database file. The magic bytes
\x7fELFwithin the stream identify it as an ELF file. - Code Execution: The attacker then uses the
MODULE LOADcommand to load this malicious shared library onto the Redis server, effectively executing arbitrary code with the privileges of the Redis process.
To detect this, Typanski outlined a multi-faceted approach using Zeek and Spicy:
- Custom RESP Parser (Spicy): First, a Spicy parser for the Redis Serialization Protocol (RESP) is deployed. This parser decodes the byte stream into structured Redis commands and replies, triggering specific Zeek events like
redis_command. - Zeek Script for Command Analysis: A Zeek script is then written to handle the
redis_commandevent. The core of this detection involves maintaining an allow list of legitimate Redis commands. Any command received that is not on this predefined list is flagged as suspicious. For instance, commands likeslaveof(orreplicaof),module load, orsystem.exec(which might be loaded by a malicious module) would typically not be on an allow list for a production Redis instance. - Triggering Notices: When a command not present in the
redis_allowed_commandsset is observed, the Zeek script triggers a notice (e.g.,Redis::Disallowed_Command). This notice is recorded in Zeek'snotice.log, providing details such as the originating host, responding host, and the disallowed command.
Typanski showcased the output in the command line using cat notice.log and the zcut utility, demonstrating how the notice.log would clearly indicate "Disallowed Redis command" along with the specific malicious command (slaveof, module load).
Beyond the explicit command detection, the talk also highlighted how Zeek's general logging capabilities could provide additional indicators:
redis.logAnalysis: Theredis.log(generated by Zeek's native Redis analyzer, which can be extended by Spicy) would show commands likesystem.exec– a clear red flag as it's not a standard Redis command.- ELF File Detection: Crucially, the logs would also reveal the presence of the ELF magic bytes (
\x7fELF) during the database synchronization phase, specifically after afullresynccommand. This anomaly – an executable file being transferred where a database dump is expected – is a strong indicator of compromise, detectable through deep content inspection provided by Zeek.
This proof of concept effectively demonstrated that Zeek, augmented by Spicy, can perform granular, application-layer behavioral analysis to detect sophisticated attacks that leverage legitimate protocol mechanisms in an illegitimate way.
Defensive Implications
▶ Watch: Q&A: Zeek's passive monitoring and latency impact (38:35)
The capabilities demonstrated with Zeek and Spicy offer significant advantages for network defenders, enabling a shift towards more proactive and nuanced security postures:
- Enhanced Visibility for Custom Protocols: For organizations with proprietary applications or unique internal protocols, Zeek with Spicy provides the means to achieve deep visibility that traditional security tools often lack. Defenders can develop custom parsers for these protocols, ensuring that all network communication is understood and monitored, eliminating blind spots.
- Behavioral Anomaly Detection: Instead of relying solely on signatures of known exploits, defenders can leverage Zeek's event-driven scripting to establish baselines of normal behavior for specific services and protocols. Any deviation from these baselines – such as unexpected commands for a Redis server (
slaveof,module load), unusual file transfers, or atypical connection patterns – can trigger immediate alerts. - Application-Layer Threat Hunting: The detailed logs generated by Zeek, including application-level data, empower security analysts to perform sophisticated threat hunting. By querying
redis.logfor commands likesystem.execorfile.logfor unexpected ELF transfers during database replication, analysts can proactively search for indicators of compromise that might have bypassed initial alerts. - Customized Alerting and Response: Zeek's flexible notice framework allows defenders to tailor alerting mechanisms to their specific operational needs. Critical detections can trigger high-priority alerts integrated into a SIEM, while less severe anomalies might generate logs for later review. This customization ensures that security teams receive actionable intelligence without being overwhelmed by noise.
- Reinforcing Security Best Practices: While Zeek can detect unauthenticated access, the primary defensive implication is to enforce strong authentication and authorization controls on all services, especially those exposed to the network. Zeek acts as a vital safety net, detecting when these primary defenses fail or are bypassed.
- Leveraging Community and Ecosystem: The Zeek Package Browser and the broader Zeek community provide a rich ecosystem of shared parsers and scripts. Defenders should actively explore and contribute to this ecosystem, benefiting from collective intelligence and accelerating their ability to monitor new protocols and detect emerging threats.
- Forensic Investigation and Retrospective Analysis: The long-term storage of Zeek logs, which are significantly smaller and more structured than raw PCAPs, facilitates retrospective analysis. If a new vulnerability or attack technique emerges, defenders can re-examine historical logs to determine if their network was compromised in the past, even years later, without needing to reprocess massive amounts of raw packet data.
By integrating Zeek and Spicy into their security operations, organizations can move from a reactive, signature-centric defense to a proactive, behavior-based security posture, gaining deeper insights and control over their network environments.
Key Takeaways
- Zeek is a powerful, open-source network security monitor that provides deep packet inspection, TCP reassembly, and generates rich, structured metadata logs for comprehensive network visibility and forensic analysis.
- Spicy is an incremental parser generator specialized for network protocols, enabling security analysts to define and parse custom or proprietary protocols, thereby extending Zeek's monitoring capabilities to previously "dark" traffic.
- The combination of Zeek and Spicy facilitates highly granular and behavior-based custom detections at the application layer, moving beyond generic signatures to identify subtle anomalies indicative of sophisticated attacks.
- Zeek's event-driven scripting language allows for flexible and immediate reactions to specific network events (e.g.,
redis_command), enabling tailored alerts and automated responses based on organizational policies. - Detecting application-layer anomalies, such as unexpected commands (e.g.,
slaveof,module loadon Redis) or malicious file transfers (e.g., ELF magic bytes during database replication), is crucial for catching exploits like the Redis RCE that evade traditional perimeter defenses. - Defenders should leverage Zeek's capabilities for proactive threat hunting, behavioral analysis, and customizing security monitoring to their unique environment, integrating Zeek logs and notices with their SIEM for enhanced situational awareness.
About the Speaker(s)
Evan Typanski is a Senior Software Engineer at Corelight, a company that provides network detection and response solutions based on Zeek. His work primarily involves contributing to the development of Zeek, the open-source network security monitor. Typanski's professional background is rooted in security, with past experience in static code analysis. He also identifies as a "compiler nerd," highlighting his deep technical expertise in programming languages and their underlying mechanisms, which is particularly relevant to his work on Spicy and Zeek's scripting language.
Reviews
Dr. Zero (Offensive Security Researcher) — SOLID
Corelight engineer Evan Typanski walks through building custom protocol parsers using Zeek and Spicy. It's a competent, practical tutorial on moving beyond generic signatures to catch application-layer abuse. Doesn't break new ground, but it's a highly actionable defensive engineering session.
Heather Calloway (CISO) — SOLID
This is a strong capability demonstration for detection engineers dealing with proprietary or obscure network protocols. For security leadership, the takeaway isn't the specific tooling, but the operational reality that off-the-shelf IPS appliances will rarely catch application-layer abuse of internal services.