Trapped By The CLI - William Robinet
William Robinet (CTO · small company in Luxembourg)
Nullcon Goa 2025 · Main Stage
Overview
William Robinet's Nullcon talk, "Trapped By The CLI," delves into subtle yet critical vulnerabilities within widely used cryptographic command-line interface (CLI) tools, primarily focusing on OpenSSL. The presentation exposes how meticulously crafted X.509 certificates and Certificate Signing Requests (CSRs), containing terminal control characters and escape sequences, can manipulate the output displayed by tools like openssl x509 -text. This manipulation can lead to significant security risks, including visual spoofing, information hiding, and potentially the unauthorized issuance of certificates for sensitive domains.

Key moments
- 0:00 Introduction: Trapped by cryptographic toolkits like OpenSSL
- 3:20 Presentation outline: standards, tools, experiments, findings
- 4:00 Understanding x509 certificates and related standards (ASN.1, DER, PEM)
- 4:30 Using openssl x509 to pretty-print certificate details
- 5:30 Explanation of PEM format as Base64 encoded binary objects
- 7:20 Analyzing binary structures with openssl asn1parse
- 8:00 Simplified ASN.1 structure of an x509 certificate
Trapped By The CLI - William Robinet
Speakers: William Robinet, CTO, Small Company in Luxembourg
Conference: Nullcon
YouTube: https://www.youtube.com/watch?v=0wW8lGjJuBM
Overview
William Robinet's Nullcon talk, "Trapped By The CLI," delves into subtle yet critical vulnerabilities within widely used cryptographic command-line interface (CLI) tools, primarily focusing on OpenSSL. The presentation exposes how meticulously crafted X.509 certificates and Certificate Signing Requests (CSRs), containing terminal control characters and escape sequences, can manipulate the output displayed by tools like openssl x509 -text. This manipulation can lead to significant security risks, including visual spoofing, information hiding, and potentially the unauthorized issuance of certificates for sensitive domains.
Robinet, a veteran open-source developer and CTO, highlights a long-standing oversight in how CLI tools render text-based representations of binary cryptographic objects. While modern terminals have mitigated some of the more severe arbitrary code execution risks associated with rogue control characters, the visual deception demonstrated in this talk presents a clear and present danger, particularly in environments where human operators visually inspect certificate requests before signing them. The core message is a stark reminder for both developers of cryptographic toolkits and security professionals: the visual integrity of CLI output is paramount, and raw data should always be treated with suspicion until explicitly sanitized.
The implications of these findings are far-reaching. For Certificate Authorities (CAs), especially private enterprise CAs, a lack of stringent input validation and reliance on default CLI output for verification could enable attackers to trick administrators into signing certificates for domains they do not control. This talk not only uncovers specific vulnerabilities but also advocates for a fundamental shift in how security-critical textual representations are handled, urging defenders to adopt practices that reveal the true, underlying binary content rather than relying on potentially deceptive formatted output.
Background
▶ Watch: Introduction: Trapped by cryptographic toolkits like OpenSSL (0:00)
The foundation of this talk lies in the ubiquitous X.509 certificates, which are central to secure communication protocols like TLS/SSL. These certificates are essentially ASN.1 (Abstract Syntax Notation One) structures, a formal language for describing data structures, encoded in a binary format, typically DER (Distinguished Encoding Rules). For human readability and transport over text-based channels (like email), DER-encoded certificates are often converted to PEM (Privacy-Enhanced Mail) format, which is essentially Base64-encoded DER.
OpenSSL, the de facto toolkit for cryptographic operations, provides several CLI applications to interact with these structures. Key among them are openssl x509, used for displaying and manipulating certificates, and openssl asn1parse, which provides a low-level, hierarchical view of an ASN.1 structure. While x509 -text offers a human-friendly "pretty print," asn1parse reveals the raw, nested Type-Length-Value (TLV) structure characteristic of DER.
ASN.1 defines various data types, from simple primitives (integers, strings) to complex constructed types (sequences, sets) that act as containers. DER encoding ensures a deterministic binary representation for any given ASN.1 structure, where each object is prefixed with a "Type" byte, a "Length" field, and then the "Value" data. The Type byte itself contains information about the ASN.1 class (e.g., universal, application-specific) and whether the type is primitive or constructed.
The inspiration for Robinet's work dates back to a practical problem encountered when addressing a CVE (CVE-2021-3712). This vulnerability, discovered by Tavis Ormandy from Google, involved specific elliptic curve parameters that could cause OpenSSL to loop indefinitely. Exploiting this required precise modification of deeply nested ASN.1 structures within a certificate. Manually hex-editing such structures is incredibly challenging, as modifying any element's length necessitates recalculating and updating the lengths of all its parent containers—a tedious and error-prone process. This difficulty prompted Robinet to revisit and present his custom tool, asn1template, which he originally developed in 2010, designed to simplify this precise modification of DER-encoded ASN.1 objects. The talk then pivots from the tool's original purpose to how its underlying mechanism—parsing asn1parse output and reconstructing DER—revealed a new class of vulnerabilities related to terminal output interpretation.
Key Findings
▶ Watch: Understanding x509 certificates and related standards (ASN.1, DER, PEM) (4:00)
The talk uncovers several critical findings related to the handling and display of certificate data by OpenSSL and other cryptographic tools:
- Challenges in ASN.1 Structure Manipulation (Pre-existing Context): The initial motivation stemmed from the difficulty of precisely modifying deeply nested ASN.1 structures, such as those required to exploit CVE-2021-3712. Robinet's tool,
asn1template, was developed to address this, convertingasn1parseoutput into a human-editable text template and then reconstructing the DER binary, automatically handling length recalculations. This capability allowed for the controlled injection of arbitrary data.
- Unintended Control Character Interpretation in Distinguished Names (OpenSSL 3.0.4+): Robinet discovered that recent versions of OpenSSL, specifically from version 3.0.4 onwards, began to interpret UTF-8 characters within the distinguished name (DN) fields of certificates (e.g., Common Name, Organization, Organizational Unit) when displayed using
openssl x509 -text. This change, introduced by Pull Request #15222, had an unintended side effect: it also enabled the interpretation of terminal control characters and escape sequences embedded within these fields. While earlier versions would escape these characters, OpenSSL 3.0.4+ would evaluate them, leading to unexpected terminal behavior like cursor movement, color changes, or even screen clearing. Robinet reported this to the OpenSSL project, which initially considered it a security implication but later classified it as a bug, leading to a fix. However, many systems might still run vulnerable versions.
- Terminal Output Blocking: A particularly insidious finding was the ability to inject specific terminal control sequences that can effectively block or truncate further output from being displayed on the terminal. Robinet demonstrated that certain sequences, when rendered, prevent subsequent lines of text from appearing. This behavior, while terminal-dependent (observed on Gnome Terminal, but not all), allows an attacker to hide the legitimate content of a certificate or CSR, presenting only a manipulated, attacker-controlled view. For instance, an attacker could print a fake header or content and then use this blocking mechanism to prevent the actual, potentially suspicious, certificate details from being seen.
- Raw Control Character Evaluation in Subject Alternative Name (SAN) DNS Fields (Persistent Vulnerability): The most critical and persistent finding is the observation that control characters injected into the DNS field of the Subject Alternative Name (SAN) extension of a certificate or CSR are consistently evaluated raw by
openssl x509 -textacross all OpenSSL versions tested, and crucially, by other cryptographic toolkits like GnuTLS and Java Key Tool. Unlike the DN fields where interpretation was version-dependent and subsequently patched, the SAN DNS field appears to be rendered without escaping these characters. This enables a powerful visual spoofing attack: an attacker can craft a CSR that, when displayed, appears benign (e.g.,CN=blah.com), but secretly contains an injectedDNS:*.google.com(or any other target domain) within the SAN, hidden by control characters in other fields (like the Country field). This allows an attacker to trick a human operator or a less-than-robust automated system into signing a certificate for an unintended, high-value domain.
Technical Deep Dive
▶ Watch: Using openssl x509 to pretty-print certificate details (4:30)
The core of the demonstrated vulnerabilities hinges on the interplay between ASN.1 structure, DER encoding, and the way OpenSSL's command-line tools parse and render these binary objects into human-readable text, especially in a terminal environment.
ASN.1 and DER Basics:
An X.509 certificate is fundamentally an ASN.1 SEQUENCE containing a TBSCertificate (To Be Signed Certificate), the signature algorithm, and the signature itself. The TBSCertificate holds all the actual certificate data: version, serial number, issuer, subject, validity period, and extensions like Subject Alternative Names (SAN).
DER (Distinguished Encoding Rules) is a specific set of rules for encoding ASN.1 structures into a binary format. It's a TLV (Type-Length-Value) encoding.
- Type: The first byte (or more, for high tag numbers) identifies the ASN.1 type. Its bits indicate the class (universal, application, context-specific, private) and whether the type is primitive (self-contained, like an integer) or constructed (a container, like a sequence or set).
- Length: Follows the Type byte, indicating the length of the Value field in bytes. This is crucial for navigating the structure.
- Value: The actual data for the object.
OpenSSL's asn1parse tool is invaluable for dissecting these structures. When run with openssl asn1parse -i -dump -in cert.der, it outputs a hierarchical representation, showing the type, length, and content of each nested ASN.1 object. For example, a SEQUENCE will show its overall length, and then list its constituent members, each with their own type, length, and value.
The asn1template Tool:
Robinet's asn1template tool addresses the complexity of manually modifying DER structures. It works by:
- Taking the output of
openssl asn1parse -i -dumpas input. - Parsing this textual representation to create an internal, recursive structure representing the ASN.1 hierarchy.
- Generating a human-readable template file (
template.txt) that mirrors theasn1parseoutput but is easily modifiable. - When provided with a modified
template.txtand the-g(generate) option, it reconstructs the DER binary. Crucially, it automatically recalculates all the nested length fields based on the modifications made to the values, eliminating the manual hex-editing pain. This capability is key to injecting arbitrary content, including control characters, into specific fields while maintaining a valid DER structure.
Terminal Control Characters and Escape Sequences:
The exploit relies on terminal control characters and ANSI escape sequences. These are special byte sequences that, instead of being displayed as text, instruct the terminal to perform specific actions:
- Simple Control Characters: The first 32 ASCII characters (0x00-0x1F), like
0x0A(Newline),0x0D(Carriage Return),0x08(Backspace),0x1B(Escape). - Control Sequence Introducer (CSI) Sequences: These typically start with
ESC(0x1B) followed by[and then a series of parameters and a final character. Examples: ESC[31m: Set foreground color to red.ESC[0m: Reset all attributes (colors, bold, etc.).ESC[2J: Clear screen.ESC[?25l: Hide cursor.ESC[2K: Erase line.
The talk referenced an excellent presentation by "stock" that details various exploitation techniques using these characters, highlighting their historical use for terminal-based attacks.
The openssl x509 -text Vulnerability Details:
The vulnerability has two main facets:
- Distinguished Name (DN) Fields (Fixed in 3.0.4+): Prior to OpenSSL 3.0.4,
openssl x509 -textwould escape non-printable characters in DN fields like Common Name (CN), Organization (O), or Organizational Unit (OU). However, OpenSSL PR #15222 introduced support for interpreting UTF-8 characters in these fields. As an unintended side effect, this also enabled the raw interpretation of embedded control characters. So, if a certificate's CN containedCN=Hellofollowed byESC[31mWorld, it would print "Hello" and then "World" in red, rather thanCN=Hello\x1b[31mWorld. Robinet's report led to this being classified as a bug, and subsequent versions (likely 3.0.5 or later, or specific patches) have addressed this by reimplementing proper escaping.
- Subject Alternative Name (SAN) DNS Fields (Persistent): This is the more critical and persistent vulnerability. When control characters are injected into the
DNS:field within the SAN extension of a certificate or CSR,openssl x509 -textrenders them raw, without any escaping, regardless of the OpenSSL version. This also applies to other tools like GnuTLS and Java Key Tool. This means an attacker can embedESC[2J(clear screen),ESC[H(cursor home), and other sequences directly into the SAN. This is particularly dangerous because the SAN is a critical field for hostname validation, and its raw display can be completely spoofed. An attacker can craft a CSR where theCountryfield (C) contains an injectedESC[2Jfollowed byESC[Hand thenDNS:*.google.com, making theopenssl req -textoutput appear to be for a benignCN=blah.comwhile actually requesting a wildcard certificate forgoogle.com. The control characters hide the malicious SAN entry, making visual inspection unreliable.
The ability to inject characters that block further output (e.g., by hiding the cursor and then moving it to an off-screen position, or using specific terminal-dependent sequences that cause the terminal to interpret further data differently) further exacerbates the problem, allowing attackers to completely control the visible output of the certificate or CSR.
Demo / Proof of Concept
▶ Watch: Analyzing binary structures with openssl asn1parse (7:20)
William Robinet showcased several compelling demonstrations, illustrating the practical implications of injecting terminal control characters into certificates and CSRs.
The initial demonstration focused on the ability to print ANSI art using openssl x509 -text. By crafting a certificate where the distinguished name contained various control characters for color, cursor movement, and screen clearing, Robinet was able to make openssl x509 -text output a custom, colored graphic. This proved the fundamental concept: if complex ANSI sequences could be interpreted, simpler, malicious ones could too. He noted that achieving this required careful tuning due to character restrictions within certificate fields.
A more advanced demo highlighted the output blocking technique. Robinet presented a certificate containing a specific control sequence that, when printed by openssl x509 -text (on a Gnome Terminal), would cause the output to abruptly stop after a certain point. The terminal would display only the attacker-controlled text, effectively "eating" the rest of the legitimate certificate content that followed. This demonstrated that an attacker could not only inject custom visual elements but also selectively hide parts of the certificate, preventing a human operator from seeing potentially suspicious details.
The most critical proof-of-concept involved Certificate Signing Request (CSR) injection targeting the Subject Alternative Name (SAN) field. Robinet crafted a CSR that, when viewed with openssl req -text, initially appeared completely benign. The Common Name (CN) might show something innocuous like bl.ah.com. However, when this exact same output was piped to less (a tool that reveals control characters), it exposed the true malicious intent: the Country (C) field within the CSR's subject contained a sequence of control characters (e.g., clear screen, cursor home) followed by DNS:.google.com. This meant a CA administrator, performing a casual visual inspection of the CSR using openssl req -text, would see a request for bl.ah.com and might approve it, unknowingly signing a certificate for .google.com. This is a direct impersonation attack vector. Robinet explicitly stated that while public CAs like Let's Encrypt would likely reject such a complex value in a certificate field due to strict policy validation, private CAs, especially those using tools like Easy-RSA for OpenVPN, are highly vulnerable. These environments often rely on visual inspection of openssl output and might not have the same rigorous input validation as public CAs.
Finally, for a dramatic flourish, Robinet demonstrated the extreme extent of this vulnerability by presenting a 23-megabyte certificate that, when printed by openssl x509 -text, would output a short, rudimentary video composed of 16 frames of ANSI art. This "video-in-certificate" proof-of-concept showcased the massive amount of control character data that can be embedded and rendered, including sequences for "pausing" between frames by repeatedly writing and erasing large blocks of characters. This vividly illustrated the potential for extensive data injection and manipulation through these overlooked CLI rendering behaviors.
Defensive Implications
▶ Watch: Simplified ASN.1 structure of an x509 certificate (8:00)
The findings presented in "Trapped By The CLI" necessitate immediate and robust defensive measures for anyone involved in PKI operations, certificate issuance, or simply interacting with cryptographic CLI tools.
- Never Blindly Trust CLI Output for Critical Verification: The most crucial takeaway is to never rely solely on the default pretty-printed output of
openssl x509 -text,openssl req -text, or similar tools from other cryptographic toolkits for verifying the content of certificates or CSRs, especially before signing. These tools are susceptible to visual spoofing.
- Sanitize or Reveal Raw Content:
- Pipe to
lessorcat -v: When inspecting certificates or CSRs, always pipe the output ofopenssl x509 -textoropenssl req -texttoless(which displays control characters with^notation) orcat -v(which visualizes non-printable characters). This will expose any embedded control characters or escape sequences that would otherwise be interpreted by the terminal. - Dedicated Parsing Tools: Develop or use dedicated parsing tools that explicitly sanitize or escape all non-printable characters before rendering any certificate or CSR field. This ensures that the displayed information accurately reflects the underlying data without any hidden commands for the terminal.
- Strict Input Validation for Certificate Authorities (CAs):
- Automated Validation: CAs, particularly private enterprise CAs, must implement stringent, automated input validation for all fields within CSRs. This validation should go beyond basic format checks and explicitly disallow or escape all terminal control characters (ASCII 0x00-0x1F, especially 0x1B for ESC) and suspicious Unicode sequences in distinguished names and extensions, particularly in the SAN DNS fields.
- Policy Enforcement: Ensure that the CA's certificate policy explicitly prohibits values that could lead to such spoofing. Public CAs already have strict policies that would likely reject many of the crafted examples, but private CAs often have more lenient rules.
- Parsing, Not Display: Automated signing processes should extract and validate certificate fields from the raw DER structure, not from a parsed text representation that might have been influenced by terminal control characters.
- Update OpenSSL and Other Toolkits: While the specific issue with distinguished name interpretation (OpenSSL 3.0.4+) has been reported and addressed as a bug by the OpenSSL team, other vulnerabilities might persist or be discovered. Keeping cryptographic toolkits updated to the latest patched versions is a fundamental security practice. However, as demonstrated, the SAN DNS field issue appears to be more fundamental and might not be fully mitigated by simple OpenSSL updates without specific parsing logic changes.
- Review Internal PKI Processes: Companies utilizing internal PKI systems, especially those using simpler tools like Easy-RSA for OpenVPN or similar deployments, are particularly at risk. These environments often rely on manual, visual inspection by administrators. Organizations should immediately review their certificate issuance workflows to ensure that CSRs are never approved based solely on the visual output of
openssl req -text. Implement a "reveal control characters" step as mandatory.
- Educate Administrators: Train system administrators and anyone involved in certificate management about the risks of terminal control character injection. Emphasize the techniques for revealing hidden characters and the importance of skepticism towards CLI output.
- Consider Terminal Hardening (Limited Impact for This Attack): While not a direct mitigation for the certificate spoofing attack, general terminal hardening (e.g., disabling obscure escape sequence interpretation, using secure terminal emulators) can reduce the risk of more severe arbitrary code execution if such vulnerabilities were discovered in conjunction with control character injection. However, for the visual spoofing demonstrated, the primary defense lies in robust validation and inspection of the data itself.
Key Takeaways
- OpenSSL CLI tools can be visually spoofed: Crafted certificates and CSRs containing terminal control characters can manipulate the output of
openssl x509 -textandopenssl req -text, leading to deceptive displays. - Subject Alternative Name (SAN) DNS fields are critically vulnerable: Control characters injected into the
DNS:field of a SAN extension are evaluated raw, allowing an attacker to hide malicious domain requests (e.g.,*.google.com) behind benign-looking CSRs. - Output blocking is possible: Specific control sequences can prevent further output from being displayed, enabling attackers to selectively hide legitimate certificate details or present only their spoofed content.
- Risk of unauthorized certificate issuance: Human operators or automated systems that rely on visual inspection of
openssloutput are vulnerable to being tricked into signing certificates for unintended, high-value domains. - Always verify raw content: To defend against this, always pipe critical
openssloutput (e.g.,x509 -text,req -text) to tools likelessorcat -vto reveal hidden control characters. - Implement stringent input validation: Certificate Authorities and internal PKI systems must enforce strict, automated input validation for all certificate fields, especially SANs, to disallow or escape control characters. Update OpenSSL and other cryptographic toolkits regularly.
About the Speaker(s)
William Robinet is a seasoned open-source enthusiast with over 25 years of experience in the field. He currently serves as the CTO for a small company in Luxembourg, where his technical expertise guides the organization. Beyond his professional role, William is a community builder, being one of the founders of the Luxembourg Network Operator Group. He is also actively involved in the security conference scene, contributing to the BSides Luxembourg Revival team and serving on the review team for the Hack.lu cybersecurity conference. William is the creator of several open-source tools, including SSLdump (for extracting SSL flow metadata), asn1template (the tool central to this talk, for modifying binary ASN.1 structures), and disposable-pki (for generating test PKI infrastructures). He can be found on Mastodon.
Reviews
Dr. Zero (Offensive Security Researcher) — STRONG ACCEPT
Robinet found a real, overlooked bug class — terminal control character injection through X.509/ASN.1 fields — and demonstrated it with escalating, credible proofs of concept from ANSI art to a forged wildcard CSR for .google.com. The SAN DNS field finding is the headline: unescaped control characters across OpenSSL, GnuTLS, and Java Key Tool is a multi-toolkit failure with a concrete, practical attack path against private CAs. Not world-ending, but genuinely novel and under-discussed.
Heather Calloway (CISO) — WEAK
Technically legitimate research on a real attack surface — CLI rendering of certificate fields is an underappreciated spoofing vector. But the talk stays inside the tool and never climbs to the institutional layer where the risk actually lives: private CA governance, signing workflow accountability, and PKI program design.