CVE-2026-77420
JLine: ReDoS via `HISTORY_IGNORE` Configuration Variable
Description
Summary
The JLine3 HISTORY_IGNORE variable is converted into a Java regular expression with
only partial escaping. As a result, regex metacharacters other than * and : are
passed through to the regex engine. A crafted value such as (a+)+b can cause
catastrophic backtracking each time a command line is added to history, hanging the
reader thread at high CPU.
Details
In reader/src/main/java/org/jline/reader/impl/history/DefaultHistory.java,
matchPatterns() converts HISTORY_IGNORE into a regex:
for (int i = 0; i < patterns.length(); i++) {
char ch = patterns.charAt(i);
if (ch == '\\') {
ch = patterns.charAt(++i);
sb.append(ch);
} else if (ch == ':') {
sb.append('|');
} else if (ch == '*') {
sb.append('.').append('*');
} else {
sb.append(ch);
}
}
return line.matches(sb.toString());
This logic translates wildcard syntax but does not escape regex metacharacters such as
(, ), +, ?, {, }, [, and ]. Those characters therefore reach the Java
regex engine unchanged.
Affected source location:
reader/src/main/java/org/jline/reader/impl/history/DefaultHistory.javamatchPatterns(String patterns, String line)
PoC
- Configure
HISTORY_IGNOREto a malicious pattern, for example:
set history-ignore "(a+)+b"
- At the JLine prompt, enter a long non-matching line:
aaaaaaaaaaaaaaaaaaaaaaaaaaax
- Press Enter.
Expected result:
- The prompt does not return.
- The reader thread consumes high CPU.
Reproduction environment:
- JLine3 on x86_64 Linux
- OpenJDK 25.0.2
Impact
This is a denial-of-service vulnerability caused by catastrophic regex backtracking.
Applications embedding org.jline:jline-reader are impacted if they allow
HISTORY_IGNORE to be configured through user configuration or application settings.
The issue is lower severity than the interactive editor findings because the attacker
must control configuration, but it can still reliably hang a reader session.
Suggested Fix
The safest fix for the current git head is to stop treating arbitrary HISTORY_IGNORE
content as a regex. Instead, escape all characters by default and translate only the
intended JLine wildcard syntax (*) and separator syntax (:).
Suggested patch:
diff --git a/reader/src/main/java/org/jline/reader/impl/history/DefaultHistory.java b/reader/src/main/java/org/jline/reader/impl/history/DefaultHistory.java
--- a/reader/src/main/java/org/jline/reader/impl/history/DefaultHistory.java
+++ b/reader/src/main/java/org/jline/reader/impl/history/DefaultHistory.java
@@
StringBuilder sb = new StringBuilder();
for (int i = 0; i < patterns.length(); i++) {
char ch = patterns.charAt(i);
if (ch == '\\') {
ch = patterns.charAt(++i);
- sb.append(ch);
+ sb.append(Pattern.quote(Character.toString(ch)));
} else if (ch == ':') {
sb.append('|');
} else if (ch == '*') {
sb.append('.').append('*');
} else {
- sb.append(ch);
+ sb.append(Pattern.quote(Character.toString(ch)));
}
}
return line.matches(sb.toString());
Credits
This issue was identified by Michał Majchrowicz and Marcin Wyczechowski, members of the AFINE Team.
Affected Maven artifacts (1)
| Artifact | Affected versions | Fixed in |
|---|---|---|
| org.jline » jline-reader | >= 3.0.0, < 3.30.15>= 4.0.0, < 4.3.1 | 3.30.15, 4.3.1 |
Blast radius
66% of the dependent artifacts (1,736) still pull an affected version in their latest release.
| Depth | Dependent versions |
|---|---|
| Direct | 5,688 |
| 2 hops | 21,839 |
| 3 hops | 19,507 |
| 4 hops | 15,768 |
| 5 hops | 22,973 |
| 6 hops | 8,906 |
Most used dependents
- org.apache.maven » maven-core6,117 usages
- org.apache.spark » spark-sql3,174 usages
- org.apache.spark » spark-core2,899 usages
- org.apache.maven » maven-compat1,596 usages
- org.scala-sbt » sbt1,240 usages
- org.apache.spark » spark-mllib831 usages
- org.apache.hive » hive-exec699 usages
- org.apache.spark » spark-streaming670 usages
- org.apache.spark » spark-hive633 usages
- org.apache.spark » spark-catalyst502 usages
- org.apache.hive » hive-metastore480 usages
- org.apache.groovy » groovy-groovysh473 usages
- org.apache.hive » hive-jdbc404 usages
- org.apache.maven » maven-embedder379 usages
- com.lihaoyi » mill-scalalib320 usages
Computed from the dependency graph of build 20261124.0621 (compile and runtime scopes, nearest version wins). Exclusions and dependency management in consuming projects are not applied, so dependents are potentially affected. When several artifacts are affected, a dependent version that pulls more than one of them is counted once per artifact.
References
- Webhttps://github.com/jline/jline3/security/advisories/GHSA-5q95-hrpc-m3w3
- Webhttps://github.com/jline/jline3/pull/2012
- Webhttps://github.com/jline/jline3/pull/2018
- Webhttps://github.com/jline/jline3/commit/1d5fc3099e77938b971e197211cad2d4fbb17541
- Webhttps://github.com/jline/jline3/commit/341ee69ccc57b7733c1b40d6993219b64b3206ae
- Packagehttps://github.com/jline/jline3
- Webhttps://github.com/jline/jline3/releases/tag/4.3.1
- Webhttps://github.com/jline/jline3/releases/tag/jline-3.30.15
