CVE-2026-77423
jline3 leads to ReDoS in Built-in Less Viewer Search
Description
Summary
The JLine3 built-in less pager compiles user-supplied search patterns directly as
Java regular expressions with no sanitization, timeout, or backtracking bound. A
malicious pattern such as (a+)+b can trigger catastrophic backtracking and hang the
session thread at 100% CPU. In deployments that expose less over Telnet or SSH,
this becomes a denial-of-service issue for the affected session and can be used to
exhaust a bounded session pool.
Details
Less.getPattern() in builtins/src/main/java/org/jline/builtins/Less.java compiles
the user-controlled search string directly with Pattern.compile():
private Pattern getPattern(boolean doDisplayPattern) {
Pattern compiled = null;
String _pattern = doDisplayPattern ? displayPattern : pattern;
if (_pattern != null) {
boolean insensitive =
ignoreCaseAlways || ignoreCaseCond && _pattern.toLowerCase().equals(_pattern);
compiled = Pattern.compile(
"(" + _pattern + ")", insensitive ? Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE : 0);
}
return compiled;
}
The resulting pattern is then applied repeatedly against file content with
compiled.matcher(line).find() in the less search path. Because Java's
java.util.regex engine is backtracking-based and has no built-in timeout, patterns
with nested quantifiers can take exponential time on non-matching input.
Affected source locations:
builtins/src/main/java/org/jline/builtins/Less.javagetPattern(boolean doDisplayPattern)- search callers using
compiled.matcher(line).find()
PoC
- Create a file with a long run of
acharacters:
printf 'aaaaaaaaaaaaaaaaaaaaaaaaa\n' > /tmp/testfile.txt
- Open the file with the JLine3
lessviewer. - Press
/to enter search mode. - Enter the pattern
(a+)+band press Enter.
Expected result:
- The
lesssession stops responding. - The session thread consumes high CPU.
Variation:
- The same behavior can be triggered through the display-filter path using
&because that path also compiles user input as a raw Java regex.
Reproduction environment:
- JLine3 on x86_64 Linux
- OpenJDK 25.0.2
Impact
This is a denial-of-service vulnerability caused by catastrophic regex backtracking.
Any application embedding org.jline:jline-builtins and exposing the less viewer
is impacted. In local use, the affected user can hang their own session. In multi-user
Telnet or SSH deployments, one attacker can occupy one session thread indefinitely and
multiple attackers or sessions can exhaust the server's available worker pool.
Suggested Fix
The preferred fix for the current git head is to move user-controlled regex matching to a linear-time engine such as RE2/J.
Suggested patch:
diff --git a/builtins/pom.xml b/builtins/pom.xml
--- a/builtins/pom.xml
+++ b/builtins/pom.xml
@@
<dependency>
+ <groupId>com.google.re2j</groupId>
+ <artifactId>re2j</artifactId>
+ <version>1.8</version>
+ </dependency>
+ <dependency>
<groupId>org.jline</groupId>
<artifactId>jline-reader</artifactId>
</dependency>
diff --git a/builtins/src/main/java/org/jline/builtins/Less.java b/builtins/src/main/java/org/jline/builtins/Less.java
--- a/builtins/src/main/java/org/jline/builtins/Less.java
+++ b/builtins/src/main/java/org/jline/builtins/Less.java
@@
-import java.util.regex.Pattern;
+import com.google.re2j.Pattern;
@@
if (_pattern != null) {
boolean insensitive =
ignoreCaseAlways || ignoreCaseCond && _pattern.toLowerCase().equals(_pattern);
compiled = Pattern.compile(
"(" + _pattern + ")",
insensitive ? Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE : 0);
}
If introducing RE2/J is not acceptable, a weaker fallback is to perform regex matching in a worker with a strict timeout and reject patterns that exceed the time budget.
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-builtins | < 3.30.15>= 4.0.0, < 4.3.1 | 3.30.15, 4.3.1 |
Blast radius
58% of the dependent artifacts (357) still pull an affected version in their latest release.
| Depth | Dependent versions |
|---|---|
| Direct | 657 |
| 2 hops | 1,965 |
| 3 hops | 2,180 |
| 4 hops | 3,059 |
| 5 hops | 1,454 |
| 6 hops | 1,133 |
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
- org.apache.hive » hive-common305 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-2v9w-34q6-wpqx
- Advisoryhttps://nvd.nist.gov/vuln/detail/CVE-2026-77423
- 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
