GHSA-PH9C-7HW9-VHHW

Vulnerability from github – Published: 2026-09-23 18:12 – Updated: 2026-09-23 18:12
VLAI
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.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Maven",
        "name": "org.jline:jline-builtins"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "4.0.0"
            },
            {
              "fixed": "4.3.1"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "package": {
        "ecosystem": "Maven",
        "name": "org.jline:jline-builtins"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "3.0.0"
            },
            {
              "fixed": "3.30.15"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-77421"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-1333"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-09-23T18:12:38Z",
    "nvd_published_at": null,
    "severity": "MODERATE"
  },
  "details": "### Summary\n\nWhen regex search mode is enabled in the JLine3 `nano` editor, the user-supplied\nsearch term is compiled directly as a Java regular expression with no timeout or\nbacktracking bound. A crafted pattern such as `(a+)+b` can hang the editor session\nthread at high CPU, causing a denial of service for that session.\n\n### Details\n\nIn `builtins/src/main/java/org/jline/builtins/Nano.java`, the search implementation\nuses `Pattern.LITERAL` only when regex mode is disabled. When regex mode is enabled,\nthe search term is compiled as a raw Java regex:\n\n```java\nPattern pat = Pattern.compile(\n        searchTerm,\n        (searchCaseSensitive ? 0 : Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE)\n                | (searchRegexp ? 0 : Pattern.LITERAL));\n```\n\nThis regex is then applied to buffer content. Because Java\u0027s regex engine is\nbacktracking-based, nested-quantifier patterns can take exponential time on\nnon-matching input.\n\nAffected source location:\n- `builtins/src/main/java/org/jline/builtins/Nano.java`\n- `doSearch(String text)`\n\n### PoC\n\n1. Create a file containing a long run of `a` characters and open it in the JLine3\n   `nano` editor.\n2. Enable regex search mode with the editor\u0027s regex toggle.\n3. Start a search and enter the pattern `(a+)+b`.\n\nExpected result:\n- The editor stops responding.\n- The session thread consumes high CPU.\n\nReproduction environment:\n- JLine3 on x86_64 Linux\n- OpenJDK 25.0.2\n\n### Impact\n\nThis is a denial-of-service vulnerability caused by catastrophic regex backtracking.\nApplications embedding `org.jline:jline-builtins` and exposing the `nano` editor are\nimpacted. In local use, the user can hang their own session. In remote multi-user\ndeployments, an attacker can occupy a server worker thread indefinitely.\n\n### Suggested Fix\n\nThe preferred fix for the current git head is to use a linear-time regex engine for\nregex search mode while preserving literal matching behavior when regex mode is off.\n\nSuggested patch:\n\n```diff\ndiff --git a/builtins/pom.xml b/builtins/pom.xml\n--- a/builtins/pom.xml\n+++ b/builtins/pom.xml\n@@\n         \u003cdependency\u003e\n+            \u003cgroupId\u003ecom.google.re2j\u003c/groupId\u003e\n+            \u003cartifactId\u003ere2j\u003c/artifactId\u003e\n+            \u003cversion\u003e1.8\u003c/version\u003e\n+        \u003c/dependency\u003e\n+        \u003cdependency\u003e\n             \u003cgroupId\u003eorg.jline\u003c/groupId\u003e\n             \u003cartifactId\u003ejline-reader\u003c/artifactId\u003e\n         \u003c/dependency\u003e\n\ndiff --git a/builtins/src/main/java/org/jline/builtins/Nano.java b/builtins/src/main/java/org/jline/builtins/Nano.java\n--- a/builtins/src/main/java/org/jline/builtins/Nano.java\n+++ b/builtins/src/main/java/org/jline/builtins/Nano.java\n@@\n-import java.util.regex.Pattern;\n+import com.google.re2j.Pattern;\n```\n\nIf a dependency change is not acceptable, a fallback mitigation is to reject dangerous\nregex constructs or execute regex matching with a strict timeout, but that is weaker\nthan replacing the backtracking engine.\n\n### Credits\n\nThis issue was identified by Micha\u0142 Majchrowicz and Marcin Wyczechowski, members of the AFINE Team.",
  "id": "GHSA-ph9c-7hw9-vhhw",
  "modified": "2026-09-23T18:12:38Z",
  "published": "2026-09-23T18:12:38Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/jline/jline3/security/advisories/GHSA-ph9c-7hw9-vhhw"
    },
    {
      "type": "WEB",
      "url": "https://github.com/jline/jline3/pull/2012"
    },
    {
      "type": "WEB",
      "url": "https://github.com/jline/jline3/pull/2018"
    },
    {
      "type": "WEB",
      "url": "https://github.com/jline/jline3/commit/1d5fc3099e77938b971e197211cad2d4fbb17541"
    },
    {
      "type": "WEB",
      "url": "https://github.com/jline/jline3/commit/341ee69ccc57b7733c1b40d6993219b64b3206ae"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/jline/jline3"
    },
    {
      "type": "WEB",
      "url": "https://github.com/jline/jline3/releases/tag/4.3.1"
    },
    {
      "type": "WEB",
      "url": "https://github.com/jline/jline3/releases/tag/jline-3.30.15"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H",
      "type": "CVSS_V3"
    }
  ],
  "summary": "JLine: ReDoS in Nano Editor Regex Search Mode"
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.

Loading…

Loading…

Loading…

Related by attack behaviour

Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.


Loading…