GHSA-ph9c-7hw9-vhhw

Suggest an improvement
Source
https://github.com/advisories/GHSA-ph9c-7hw9-vhhw
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/09/GHSA-ph9c-7hw9-vhhw/GHSA-ph9c-7hw9-vhhw.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-ph9c-7hw9-vhhw
Aliases
  • CVE-2026-77421
Published
2026-09-23T18:12:38Z
Modified
2026-09-23T18:27:57Z
Severity
  • 6.5 (Medium) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H CVSS Calculator
Summary
JLine: ReDoS in Nano Editor Regex Search Mode
Details

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.java
  • doSearch(String text)

PoC

  1. Create a file containing a long run of a characters and open it in the JLine3 nano editor.
  2. Enable regex search mode with the editor's regex toggle.
  3. 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.

Database specific
{
    "cwe_ids":  [
        "CWE-1333"
    ],
    "github_reviewed":  true,
    "github_reviewed_at":  "2026-09-23T18:12:38Z",
    "nvd_published_at":  null,
    "severity":  "MODERATE"
}
References

Affected packages

Maven / org.jline:jline-builtins

Package

Name
org.jline:jline-builtins
View open source insights on deps.dev
Purl
pkg:maven/org.jline/jline-builtins

Affected ranges

Type
ECOSYSTEM
Events
Introduced
4.0.0
Fixed
4.3.1

Affected versions

4.*
4.0.0
4.0.2
4.0.3
4.0.4
4.0.5
4.0.6
4.0.7
4.0.8
4.0.9
4.0.10
4.0.11
4.0.12
4.0.13
4.0.14
4.0.15
4.0.16
4.1.0
4.1.1
4.1.2
4.1.3
4.2.0
4.2.1
4.3.0

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/09/GHSA-ph9c-7hw9-vhhw/GHSA-ph9c-7hw9-vhhw.json"

Maven / org.jline:jline-builtins

Package

Name
org.jline:jline-builtins
View open source insights on deps.dev
Purl
pkg:maven/org.jline/jline-builtins

Affected ranges

Type
ECOSYSTEM
Events
Introduced
3.0.0
Fixed
3.30.15

Affected versions

3.*
3.2.0
3.3.0
3.3.1
3.4.0
3.5.0
3.5.1
3.5.2
3.6.0
3.6.1
3.6.2
3.7.0
3.7.1
3.8.0
3.8.1
3.8.2
3.9.0
3.10.0
3.11.0
3.12.0
3.12.1
3.13.0
3.13.1
3.13.2
3.13.3
3.14.0
3.14.1
3.15.0
3.16.0
3.17.0
3.17.1
3.18.0
3.19.0
3.20.0
3.21.0
3.22.0
3.23.0
3.24.0
3.24.1
3.25.0
3.25.1
3.26.0
3.26.1
3.26.2
3.26.3
3.27.0
3.27.1
3.28.0
3.29.0
3.30.0
3.30.1
3.30.2
3.30.3
3.30.4
3.30.5
3.30.6
3.30.7
3.30.8
3.30.9
3.30.10
3.30.11
3.30.12
3.30.13
3.30.14

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/09/GHSA-ph9c-7hw9-vhhw/GHSA-ph9c-7hw9-vhhw.json"