{"id":"CVE-2026-77423","aliases":["CVE-2026-77423","GHSA-2v9w-34q6-wpqx"],"related":[],"kind":"vulnerability","state":"published","title":"JLine: ReDoS in Built-in Less Viewer Search","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 less viewer passes user-controlled search and display-filter patterns from getPattern(boolean doDisplayPattern) in builtins/src/main/java/org/jline/builtins/Less.java directly to Java's backtracking regular expression engine and repeatedly applies them to file content. A nested-quantifier expression evaluated against non-matching lines can consume excessive CPU and indefinitely block the session thread, and repeated sessions in Telnet or SSH deployments can exhaust a bounded worker pool. 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 less viewer passes user-controlled search and display-filter patterns from getPattern(boolean doDisplayPattern) in builtins/src/main/java/org/jline/builtins/Less.java directly to Java's backtracking regular expression engine and repeatedly applies them to file content. A nested-quantifier expression evaluated against non-matching lines can consume excessive CPU and indefinitely block the session thread, and repeated sessions in Telnet or SSH deployments can exhaust a bounded worker pool. This issue is fixed in versions 3.30.15 and 4.3.1.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nThe JLine3 built-in `less` pager compiles user-supplied search patterns directly as\nJava regular expressions with no sanitization, timeout, or backtracking bound. A\nmalicious pattern such as `(a+)+b` can trigger catastrophic backtracking and hang the\nsession thread at 100% CPU. In deployments that expose `less` over Telnet or SSH,\nthis becomes a denial-of-service issue for the affected session and can be used to\nexhaust a bounded session pool.\n\n### Details\n\n`Less.getPattern()` in `builtins/src/main/java/org/jline/builtins/Less.java` compiles\nthe user-controlled search string directly with `Pattern.compile()`:\n\n```java\nprivate Pattern getPattern(boolean doDisplayPattern) {\n    Pattern compiled = null;\n    String _pattern = doDisplayPattern ? displayPattern : pattern;\n    if (_pattern != null) {\n        boolean insensitive =\n                ignoreCaseAlways || ignoreCaseCond && _pattern.toLowerCase().equals(_pattern);\n        compiled = Pattern.compile(\n                \"(\" + _pattern + \")\", insensitive ? Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE : 0);\n    }\n    return compiled;\n}\n```\n\nThe resulting pattern is then applied repeatedly against file content with\n`compiled.matcher(line).find()` in the `less` search path. Because Java's\n`java.util.regex` engine is backtracking-based and has no built-in timeout, patterns\nwith nested quantifiers can take exponential time on non-matching input.\n\nAffected source locations:\n- `builtins/src/main/java/org/jline/builtins/Less.java`\n- `getPattern(boolean doDisplayPattern)`\n- search callers using `compiled.matcher(line).find()`\n\n### PoC\n\n1. Create a file with a long run of `a` characters:\n\n```sh\nprintf 'aaaaaaaaaaaaaaaaaaaaaaaaa\\n' > /tmp/testfile.txt\n```\n\n2. Open the file with the JLine3 `less` viewer.\n3. Press `/` to enter search mode.\n4. Enter the pattern `(a+)+b` and press Enter.\n\nExpected result:\n- The `less` session stops responding.\n- The session thread consumes high CPU.\n\nVariation:\n- The same behavior can be triggered through the display-filter path using `&` because\n  that path also compiles user input as a raw Java regex.\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.\nAny application embedding `org.jline:jline-builtins` and exposing the `less` viewer\nis impacted. In local use, the affected user can hang their own session. In multi-user\nTelnet or SSH deployments, one attacker can occupy one session thread indefinitely and\nmultiple attackers or sessions can exhaust the server's available worker pool.\n\n### Suggested Fix\n\nThe preferred fix for the current git head is to move user-controlled regex matching\nto a linear-time engine such as RE2/J.\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/Less.java b/builtins/src/main/java/org/jline/builtins/Less.java\n--- a/builtins/src/main/java/org/jline/builtins/Less.java\n+++ b/builtins/src/main/java/org/jline/builtins/Less.java\n@@\n-import java.util.regex.Pattern;\n+import com.google.re2j.Pattern;\n@@\n         if (_pattern != null) {\n             boolean insensitive =\n                     ignoreCaseAlways || ignoreCaseCond && _pattern.toLowerCase().equals(_pattern);\n             compiled = Pattern.compile(\n                     \"(\" + _pattern + \")\",\n                     insensitive ? Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE : 0);\n         }\n```\n\nIf introducing RE2/J is not acceptable, a weaker fallback is to perform regex matching\nin a worker with a strict timeout and reject patterns that exceed the time budget.\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:17:49.635Z","modified":"2026-11-23T21:15:06.209Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"}],"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":"0","status":"affected","fixed":"3.30.15"}],"ecosystem":"Maven","package":"org.jline:jline-builtins","purl":"pkg:maven/org.jline/jline-builtins","source":"ghsa"},{"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"}],"references":[{"url":"https://github.com/jline/jline3/security/advisories/GHSA-2v9w-34q6-wpqx","tags":["exploit","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://nvd.nist.gov/vuln/detail/CVE-2026-77423","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/jline/jline3","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-09-24T14:10:41.490Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-77423","url":"https://www.cve.org/CVERecord?id=CVE-2026-77423","licence":"CVE Terms of Use","modified":"2026-09-24T14:10:52.736Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-2v9w-34q6-wpqx","url":"https://github.com/advisories/GHSA-2v9w-34q6-wpqx","licence":"CC-BY-4.0","modified":"2026-11-23T21:15:06.209Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-77423","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-77423","licence":"Public domain","modified":"2026-09-30T16:44:39.840Z"}],"updatedAt":"2026-11-25T22:59:40.665Z","epss":{"score":0.00461,"percentile":0.41672,"date":"2026-12-01T12:00:22.000Z"}}