CVE-2026-77421
JLine: ReDoS in Nano Editor Regex Search Mode
Description
Summary
When regex search mode is enabled in the JLine3 nano editor, the user-supplied
search term is compiled directly as a Java regular expression with no timeout or
backtracking bound. A crafted pattern such as (a+)+b can hang the editor session
thread at high CPU, causing a denial of service for that session.
Details
In builtins/src/main/java/org/jline/builtins/Nano.java, the search implementation
uses Pattern.LITERAL only when regex mode is disabled. When regex mode is enabled,
the search term is compiled as a raw Java regex:
Pattern pat = Pattern.compile(
searchTerm,
(searchCaseSensitive ? 0 : Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE)
| (searchRegexp ? 0 : Pattern.LITERAL));
This regex is then applied to buffer content. Because Java's regex engine is backtracking-based, nested-quantifier patterns can take exponential time on non-matching input.
Affected source location:
builtins/src/main/java/org/jline/builtins/Nano.javadoSearch(String text)
PoC
- Create a file containing a long run of
acharacters and open it in the JLine3nanoeditor. - Enable regex search mode with the editor's regex toggle.
- Start a search and enter the pattern
(a+)+b.
Expected result:
- The editor stops responding.
- The session 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-builtins and exposing the nano editor are
impacted. In local use, the user can hang their own session. In remote multi-user
deployments, an attacker can occupy a server worker thread indefinitely.
Suggested Fix
The preferred fix for the current git head is to use a linear-time regex engine for regex search mode while preserving literal matching behavior when regex mode is off.
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/Nano.java b/builtins/src/main/java/org/jline/builtins/Nano.java
--- a/builtins/src/main/java/org/jline/builtins/Nano.java
+++ b/builtins/src/main/java/org/jline/builtins/Nano.java
@@
-import java.util.regex.Pattern;
+import com.google.re2j.Pattern;
If a dependency change is not acceptable, a fallback mitigation is to reject dangerous regex constructs or execute regex matching with a strict timeout, but that is weaker than replacing the backtracking engine.
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.0.0, < 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-ph9c-7hw9-vhhw
- 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
