CVE-2026-13503 Overview
CVE-2026-13503 is a path traversal vulnerability [CWE-22] affecting ANTLR4 versions up to 4.13.2. The flaw resides in the getImportedVocabFile function within tool/src/org/antlr/v4/parse/TokenVocabParser.java, part of the tokenVocab Grammar Option Handler. Attackers can manipulate the token vocabulary file reference to traverse directory boundaries and access files outside the intended scope. The exploit is publicly disclosed and can be executed remotely. The vendor was contacted about this disclosure but did not respond.
Critical Impact
Remote attackers can leverage path traversal in ANTLR4 grammar processing to read arbitrary files accessible to the parser process, exposing sensitive source files or configuration data.
Affected Products
- ANTLR ANTLR4 versions up to and including 4.13.2
- Applications and build pipelines invoking the ANTLR4 tool with untrusted grammar files
- Development environments processing third-party .g4 grammars using the tokenVocab option
Discovery Timeline
- 2026-06-28 - CVE-2026-13503 published to NVD
- 2026-06-29 - Last updated in NVD database
Technical Details for CVE-2026-13503
Vulnerability Analysis
The vulnerability exists in ANTLR4's grammar tooling, which processes .g4 grammar definitions and supports a tokenVocab option for importing token vocabularies from external files. The getImportedVocabFile method in TokenVocabParser.java constructs a file path from the tokenVocab grammar option without adequate sanitization of directory traversal sequences. An attacker who supplies or influences a grammar file can specify a tokenVocab value containing ../ sequences or absolute path components. The parser then reads the referenced file from an arbitrary location on the filesystem. This exposes any file readable by the process invoking the ANTLR4 tool, including source code, credentials, and configuration data.
Root Cause
The root cause is missing input validation on the tokenVocab grammar option value. The getImportedVocabFile function concatenates the option value with a base directory but does not canonicalize the resulting path or verify it remains within the expected boundary [CWE-22].
Attack Vector
Exploitation requires an attacker to control or influence a grammar file processed by ANTLR4. This occurs in scenarios such as build systems that compile third-party grammars, hosted services that accept user-supplied grammars, or CI/CD pipelines processing untrusted repositories. The attack is network-reachable when grammars are ingested from remote sources.
No verified proof-of-concept code has been published. Technical details are referenced in the VulDB CVE entry and the GitHub Issue Report.
Detection Methods for CVE-2026-13503
Indicators of Compromise
- Grammar files containing tokenVocab option values with ../ sequences or absolute path prefixes such as /etc/ or C:\
- ANTLR4 tool invocations reading files outside the grammar working directory
- Unexpected file access patterns from Java processes executing org.antlr.v4.Tool
Detection Strategies
- Scan repository grammar files (.g4) for suspicious tokenVocab values referencing parent directories or absolute paths
- Monitor build agents for ANTLR4 processes reading files outside the designated grammar source directory
- Enable filesystem audit logging on developer workstations and CI runners that execute ANTLR4 tooling
Monitoring Recommendations
- Log all invocations of the ANTLR4 tool along with the working directory and grammar file paths processed
- Alert when Java processes launched by build systems access sensitive paths such as /etc/passwd, SSH keys, or cloud credential stores
- Correlate grammar ingestion events from source control with subsequent file reads by parser processes
How to Mitigate CVE-2026-13503
Immediate Actions Required
- Inventory all uses of ANTLR4 4.13.2 and earlier across development, build, and runtime environments
- Restrict ANTLR4 execution to grammars from trusted sources and reject externally supplied .g4 files without review
- Run ANTLR4 tooling under a least-privilege account with filesystem access limited to the grammar working directory
Patch Information
The vendor did not respond to disclosure at the time of publication and no official patch is referenced in the advisory. Monitor the ANTLR4 project for a fixed release and consult the VulDB Vulnerability Info for updates.
Workarounds
- Sanitize grammar files before processing by rejecting any tokenVocab option containing path separators or parent directory references
- Execute the ANTLR4 tool inside a container or sandbox with a read-only, minimal filesystem mount
- Apply mandatory access controls such as AppArmor or SELinux to constrain filesystem access for build tooling
# Example: grep grammar files for suspicious tokenVocab values
grep -rnE 'tokenVocab\s*=\s*["\\x27]?[^"\\x27]*(\.\.|/|\\)' --include='*.g4' .
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

