{"id":"CVE-2026-77421","aliases":["CVE-2026-77421","GHSA-ph9c-7hw9-vhhw"],"related":[],"kind":"vulnerability","state":"published","title":"JLine: ReDoS in Nano Editor Regex Search Mode","summary":"JLine is a Java library for handling console input. From 3.0.0 until 3.30.15 and 4.3.1, the JLine built-in nano editor's regex search mode passes a user-controlled search term from doSearch(String text) in builtins/src/main/java/org/jline/builtins/Nano.java to Java's backtracking regular expression engine without a timeout or backtracking bound. A nested-quantifier expression evaluated against non-matching buffer content can consume excessive CPU and indefinitely block the editor session thread, and remote multi-user deployments can lose a worker thread for each affected session. This issue is fixed in versions 3.30.15 and 4.3.1.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"JLine is a Java library for handling console input. From 3.0.0 until 3.30.15 and 4.3.1, the JLine built-in nano editor's regex search mode passes a user-controlled search term from doSearch(String text) in builtins/src/main/java/org/jline/builtins/Nano.java to Java's backtracking regular expression engine without a timeout or backtracking bound. A nested-quantifier expression evaluated against non-matching buffer content can consume excessive CPU and indefinitely block the editor session thread, and remote multi-user deployments can lose a worker thread for each affected session. This issue is fixed in versions 3.30.15 and 4.3.1.","source":"cvelist"},{"lang":"en","text":"### 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's 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's 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         <dependency>\n+            <groupId>com.google.re2j</groupId>\n+            <artifactId>re2j</artifactId>\n+            <version>1.8</version>\n+        </dependency>\n+        <dependency>\n             <groupId>org.jline</groupId>\n             <artifactId>jline-reader</artifactId>\n         </dependency>\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ł Majchrowicz and Marcin Wyczechowski, members of the AFINE Team.","format":"markdown","source":"ghsa"}],"published":"2026-09-23T18:07:21.134Z","modified":"2026-09-30T16:44:39.840Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","score":6.5,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","score":6.5,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","score":6.5,"rating":"MEDIUM"}],"cwes":["CWE-1333"],"affected":[{"ranges":[{"version":">= 3.0.0, < 3.30.15","status":"affected"},{"version":">= 4.0.0, < 4.3.1","status":"affected"}],"vendor":"jline","product":"jline3","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"4.0.0","status":"affected","fixed":"4.3.1"}],"ecosystem":"Maven","package":"org.jline:jline-builtins","purl":"pkg:maven/org.jline/jline-builtins","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"3.0.0","status":"affected","fixed":"3.30.15"}],"ecosystem":"Maven","package":"org.jline:jline-builtins","purl":"pkg:maven/org.jline/jline-builtins","source":"ghsa"}],"references":[{"url":"https://github.com/jline/jline3/security/advisories/GHSA-ph9c-7hw9-vhhw","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/jline/jline3/pull/2012","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/jline/jline3/pull/2018","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/jline/jline3/commit/1d5fc3099e77938b971e197211cad2d4fbb17541","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/jline/jline3/commit/341ee69ccc57b7733c1b40d6993219b64b3206ae","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/jline/jline3/releases/tag/4.3.1","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/jline/jline3/releases/tag/jline-3.30.15","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/jline/jline3","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2026-09-23T19:05:07.485Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-77421","url":"https://www.cve.org/CVERecord?id=CVE-2026-77421","licence":"CVE Terms of Use","modified":"2026-09-23T19:43:56.607Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-ph9c-7hw9-vhhw","url":"https://github.com/advisories/GHSA-ph9c-7hw9-vhhw","licence":"CC-BY-4.0","modified":"2026-09-23T18:27:57.317Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-77421","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-77421","licence":"Public domain","modified":"2026-09-30T16:44:39.840Z"}],"updatedAt":"2026-11-25T22:59:40.664Z","epss":{"score":0.00434,"percentile":0.39464,"date":"2026-12-02T12:00:21.000Z"}}