CVE-2026-13500 Overview
CVE-2026-13500 is a code injection vulnerability affecting ANTLR4 versions up to 4.13.2. The flaw resides in the OutputFile.java source file within the Grammar Action Block Handler component of the ANTLR parser generator toolchain. An attacker can manipulate grammar action blocks to inject code that executes during grammar processing. The vulnerability is remotely exploitable and a public exploit is available. The vendor was contacted before public disclosure but did not respond. This weakness maps to CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component.
Critical Impact
Remote attackers can inject code through crafted grammar action blocks processed by ANTLR4, leading to unauthorized code execution in build and code generation environments.
Affected Products
- ANTLR ANTLR4 versions through 4.13.2
- tool/src/org/antlr/v4/codegen/model/OutputFile.java component
- Build pipelines and toolchains that invoke ANTLR4 on untrusted grammar files
Discovery Timeline
- 2026-06-28 - CVE-2026-13500 published to NVD
- 2026-06-29 - Last updated in NVD database
Technical Details for CVE-2026-13500
Vulnerability Analysis
ANTLR4 is a widely used parser generator that consumes grammar (.g4) files and produces parser and lexer source code in a target language. Grammar files may contain action blocks—embedded target-language code that ANTLR emits directly into generated output. The vulnerability affects how OutputFile.java handles these action blocks during code generation. Insufficient neutralization of embedded content allows an attacker who supplies a grammar file to inject arbitrary code fragments into the generated output artifacts. When developers or automated pipelines compile and execute the generated parser, the injected code runs with the privileges of that process.
Root Cause
The root cause is improper output neutralization ([CWE-74]) in the Grammar Action Block Handler. The OutputFile.java model does not sufficiently sanitize or constrain content propagated from grammar action blocks into the emitted source files. Content boundaries between ANTLR-controlled scaffolding and user-supplied action text are not enforced, enabling injection.
Attack Vector
The attack requires an attacker-controlled grammar file to be processed by ANTLR4. Delivery paths include pull requests to open-source repositories, third-party grammar packages, CI/CD jobs that fetch grammars from remote sources, and shared developer environments. No authentication or user interaction beyond normal build execution is required. Because ANTLR is commonly invoked during builds, exploitation can pivot into developer workstations and build agents.
No verified proof-of-concept code is available for reproduction here. Refer to the VulDB Vulnerability Details and the GitHub Issue Report for technical specifics.
Detection Methods for CVE-2026-13500
Indicators of Compromise
- Unexpected code fragments, imports, or system calls appearing in ANTLR-generated parser or lexer source files
- Grammar .g4 files containing action blocks with escape sequences or unusual delimiters near @header, @members, or inline { ... } actions
- Outbound network connections or shell process spawns originating from build agents during ANTLR code generation
- Modifications to OutputFile.java output that do not correspond to grammar changes in version control
Detection Strategies
- Perform static review and diffing of ANTLR-generated sources against expected templates for each build
- Scan grammar files for suspicious patterns in action blocks before invoking the ANTLR tool
- Monitor build-agent process trees for anomalous child processes spawned by java -jar antlr-4.*.jar invocations
- Compare hashes of generated artifacts across builds to detect non-deterministic or injected content
Monitoring Recommendations
- Log all ANTLR invocations in CI/CD pipelines with grammar file paths and source origins
- Alert on newly introduced grammar files or action-block edits in pull requests
- Track outbound network traffic from build runners during code generation stages
- Retain generated source artifacts for forensic comparison after suspected incidents
How to Mitigate CVE-2026-13500
Immediate Actions Required
- Treat all third-party or externally sourced ANTLR grammar files as untrusted input and review action blocks before use
- Isolate ANTLR code generation to ephemeral, network-restricted build containers
- Pin ANTLR4 to a known internal build and disallow ad hoc upgrades until a vendor fix is available
- Review recent CI/CD build logs and generated sources for signs of injected content
Patch Information
At the time of publication, no vendor patch is referenced in the NVD entry. The vendor was contacted prior to disclosure but did not respond. Monitor the ANTLR4 project and the VulDB CVE Record for release updates addressing OutputFile.java.
Workarounds
- Restrict ANTLR execution to trusted grammars authored and reviewed in-house
- Enforce code review on every change to .g4 files, with particular attention to action blocks and header sections
- Run ANTLR in sandboxed environments without credentials, secrets, or network egress
- Add automated linting to reject grammar files containing action-block patterns that exceed a defined allow-list
# Example: run ANTLR inside a network-isolated container with read-only inputs
docker run --rm --network=none \
-v "$(pwd)/grammars:/in:ro" \
-v "$(pwd)/generated:/out" \
antlr/antlr4:4.13.2 \
-o /out /in/MyGrammar.g4
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

