{"id":"CVE-2026-56740","aliases":["CVE-2026-56740","GHSA-47qp-hqvx-6r3f"],"related":[],"kind":"vulnerability","state":"published","title":"JLine: Unauthenticated Remote Memory Exhaustion via Unbounded Telnet NEW-ENVIRON Variables","summary":"JLine is a Java library for handling console input. Prior to 3.30.14, 4.0.16, and 4.2.1, the JLine3 Telnet server remote-telnet module does not limit the number of environment variables a client may inject via the Telnet NEW-ENVIRON option, and TelnetIO.readNEVariables() in TelnetIO.java:1127-1180 stores each variable pair in a HashMap held by ConnectionData, allowing an unauthenticated attacker to flood unique variable pairs before the terminating IAC SE byte and exhaust JVM heap memory with an OutOfMemoryError. This issue is fixed in versions 3.30.14, 4.0.16, and 4.2.1.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"JLine is a Java library for handling console input. Prior to 3.30.14, 4.0.16, and 4.2.1, the JLine3 Telnet server remote-telnet module does not limit the number of environment variables a client may inject via the Telnet NEW-ENVIRON option, and TelnetIO.readNEVariables() in TelnetIO.java:1127-1180 stores each variable pair in a HashMap held by ConnectionData, allowing an unauthenticated attacker to flood unique variable pairs before the terminating IAC SE byte and exhaust JVM heap memory with an OutOfMemoryError. This issue is fixed in versions 3.30.14, 4.0.16, and 4.2.1.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nThe JLine3 Telnet server (`remote-telnet` module) does not limit the number of\nenvironment variables a client may inject via the Telnet NEW-ENVIRON option. An\nunauthenticated attacker can flood the server with a large number of unique\nvariable pairs before sending the terminating IAC SE byte, exhausting JVM heap\nmemory and causing an OutOfMemoryError (denial of service). Approximately 3–4 MB of\nnetwork traffic is sufficient to consume a 512 MB JVM heap.\n\n### Details\n\n`TelnetIO.readNEVariables()` (TelnetIO.java:1127-1180) processes incoming NEW-ENVIRON\nvariable pairs in a loop and stores each pair in a `HashMap` held by `ConnectionData`:\n\n```java\n// TelnetIO.java:1139-1178\nboolean cont = true;\nif (i == NE_VAR || i == NE_USERVAR) {\n    do {\n        switch (readNEVariableName(sbuf)) {\n            case NE_VAR_OK:\n                TelnetIO.this.connectionData.getEnvironment().put(str, sbuf.toString());\n                // ← no per-connection count limit\n                break;\n            case NE_VAR_UNDEFINED:\n                break; // cont remains true, loop continues\n        }\n    } while (cont);  // cont is never set to false; only exits via return\n}\n```\n\nThe variable accumulator map is a plain `HashMap` initialized with capacity 20 and\n**no maximum size**:\n\n```java\n// ConnectionData.java:98\nenvironment = new HashMap<String, String>(20);\n```\n\nPer-variable limits exist (name: max 50 chars, value: max 1000 chars), but there is no\ncap on the *count* of variables. Each map entry occupies approximately 2 KB of heap\n(String headers + `Map.Entry` + backing char arrays). On a JVM with a 512 MB heap,\napproximately 250,000 unique entries trigger an `OutOfMemoryError`.\n\nNetwork cost: using sequential 1-byte names (e.g., `\\x01`, `\\x02`, ...) and 1-byte\nvalues, each variable pair requires roughly 13 protocol bytes. Sending 250,000 pairs\nrequires only ~3.25 MB of network traffic — feasible in seconds over any reasonable\nnetwork connection.\n\nNo authentication is required. NEW-ENVIRON negotiation occurs before login.\n\nAffected source files:\n- `remote-telnet/src/main/java/org/jline/builtins/telnet/TelnetIO.java` lines 1127-1180\n- `remote-telnet/src/main/java/org/jline/builtins/telnet/ConnectionData.java` line 98\n\n### PoC\n\nConnect to the JLine3 Telnet server and, after completing WILL/DO option negotiation,\nsend a NEW-ENVIRON SEND subneg followed by a single large IS subneg containing\nthousands of unique variable pairs before the final IAC SE.\n\nProtocol structure (no authentication required):\n1. Standard Telnet option negotiation (IAC DO NEW-ENVIRON, IAC WILL NEW-ENVIRON)\n2. Server sends IAC SB NEW-ENVIRON SEND IAC SE\n3. Client responds with: IAC SB NEW-ENVIRON IS\n     [NE_VAR 0x01 NE_VALUE 0x01]  ← variable pair 1\n     [NE_VAR 0x02 NE_VALUE 0x01]  ← variable pair 2\n     ... repeated N times ...\n     IAC SE                        ← only sent after N pairs\n\nEach iteration adds one entry to the per-connection environment map. The connection\nthread blocks reading from the socket while accumulating pairs, so the attacker\ncontrols the timing of the OOM.\n\nReproduction environment:\n- JLine3 built from current master on x86_64 Linux, OpenJDK 25.0.2\n- `remote-telnet` module started with its default configuration\n- Confirmed by source-code analysis; loop exit condition and missing count guard\n  verified by inspection of `readNEVariables()` and `ConnectionData` constructor\n\n### Impact\n\n**Type**: Denial of Service (heap memory exhaustion / OutOfMemoryError)\n**Who is affected**: Any application embedding the JLine3 `remote-telnet` module and\nexposing its Telnet server. No credentials are required. A single connection can exhaust\nthe entire JVM heap, crashing the host process or triggering JVM out-of-memory\nhandling that impacts all users sharing that JVM instance.\n\n### Credits \n\nThis issue was identified by Michał Majchrowicz and Marcin Wyczechowski, members of the AFINE Team.","format":"markdown","source":"ghsa"},{"lang":"es","text":"JLine es una biblioteca Java para manejar la entrada de consola. Antes de las versiones 3.30.14, 4.0.16 y 4.2.1, el módulo remote-telnet del servidor Telnet de JLine3 no limita el número de variables de entorno que un cliente puede inyectar a través de la opción Telnet NEW-ENVIRON, y TelnetIO.readNEVariables() en TelnetIO.java:1127-1180 almacena cada par de variables en un HashMap mantenido por ConnectionData, permitiendo a un atacante no autenticado inundar pares de variables únicos antes del byte IAC SE de terminación y agotar la memoria del montón de la JVM con un OutOfMemoryError. Este problema se ha solucionado en las versiones 3.30.14, 4.0.16 y 4.2.1.","source":"nvd"}],"published":"2026-06-18T13:07:25.000Z","modified":"2026-10-24T20:10:00.137Z","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-400"],"affected":[{"ranges":[{"version":"< 3.30.14","status":"affected"},{"version":">= 4.0.0, < 4.0.16","status":"affected"},{"version":">= 4.1.0, < 4.2.1","status":"affected"}],"vendor":"jline","product":"jline3","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"4.1.0","status":"affected","fixed":"4.2.1"}],"ecosystem":"Maven","package":"org.jline:jline-remote-telnet","purl":"pkg:maven/org.jline/jline-remote-telnet","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"4.0.0","status":"affected","fixed":"4.0.16"}],"ecosystem":"Maven","package":"org.jline:jline-remote-telnet","purl":"pkg:maven/org.jline/jline-remote-telnet","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"3.30.14"}],"ecosystem":"Maven","package":"org.jline:jline-remote-telnet","purl":"pkg:maven/org.jline/jline-remote-telnet","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"3.30.14"},{"status":"affected","introduced":"4.0.0","fixed":"4.0.16"},{"status":"affected","introduced":"4.1.0","fixed":"4.2.1"}],"vendor":"jline","product":"jline","cpe":"cpe:2.3:a:jline:jline:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/jline/jline3/security/advisories/GHSA-47qp-hqvx-6r3f","tags":["exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/jline/jline3/pull/2000","tags":["issue-tracking","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/jline/jline3/pull/2001","tags":["issue-tracking","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/jline/jline3/commit/0389f0ee6d0375901b602671ad5dafd4d1d4ee09","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/jline/jline3/commit/4ee3a73849ffb9a85ec748e4e8cd8f6d81f84f40","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/jline/jline3/commit/934f09e6128cee33c2b13d42b6e859c1ee2d194b","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/jline/jline3/releases/tag/4.0.16","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/jline/jline3/releases/tag/4.2.1","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/jline/jline3/releases/tag/jline-3.30.14","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-56740","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-07-20T13:57:48.412Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-56740","url":"https://www.cve.org/CVERecord?id=CVE-2026-56740","licence":"CVE Terms of Use","modified":"2026-07-20T13:58:00.902Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-47qp-hqvx-6r3f","url":"https://github.com/advisories/GHSA-47qp-hqvx-6r3f","licence":"CC-BY-4.0","modified":"2026-09-10T03:51:07.920Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-56740","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-56740","licence":"Public domain","modified":"2026-10-24T20:10:00.137Z"}],"updatedAt":"2026-11-25T22:59:28.594Z","epss":{"score":0.00592,"percentile":0.49669,"date":"2026-12-01T12:00:22.000Z"}}