Summary
A critical code-injection vulnerability in Yamcs allows an authorized user with the ControlArchiving system privilege to cause user-controlled StreamSQL column names to become part of generated Java source code.
When the affected query path compiles this source with Janino, the Yamcs server process may execute attacker-controlled Java code, potentially exposing sensitive mission data and credentials or disrupting operations.
Affected context
The vulnerability occurs in Yamcs deployments where an authorized archiving-control user can submit SQL through the archive execution API and where StreamSQL expressions are compiled into Java source. It is associated with generated code for aggregate expressions, including sum operations, when a crafted double-quoted column name reaches the source-generation and compilation path.
Exploit preconditions
- Attack surface: The Yamcs archive SQL execution API
- Required access: An authenticated user or service account with
SystemPrivilege.ControlArchiving - Trigger point: Processing a StreamSQL query containing a specially constructed double-quoted column name that reaches an aggregate expression
- Why exploitation is possible: User-controlled identifier text is interpolated into generated Java source before Janino compiles it, allowing source-level code injection within the Yamcs server process
Why this happens
The underlying bug is improper neutralization of user-controlled identifiers during dynamic source-code generation. StreamSQL column names are incorporated into Java source by expression code-generation logic, while sanitization does not reliably preserve the boundary between data and executable source.
This behavior maps to CWE-94: Improper Control of Generation of Code, because externally influenced input can alter dynamically generated code that is subsequently compiled and executed.
Potential impact
- An attacker may execute arbitrary Java code in the Yamcs server process.
- Sensitive mission data, credentials, or configuration secrets could be exposed.
- Telemetry or other operational data could be altered or poisoned.
- Mission-control services could experience denial of service.
- The compromise could enable further access to connected systems, depending on server privileges and network exposure.
General mitigation guidance
Mitigation generally focuses on preventing untrusted input from entering generated source code and reducing the privileges available to query-processing components.
Common defensive patterns include:
- Avoiding runtime compilation of source code derived from user-controlled identifiers.
- Representing expressions with a constrained internal syntax tree or fixed operation mapping instead of string interpolation.
- Applying strict allowlisting and context-aware encoding to identifiers before any code-generation step.
- Separating query parsing from execution and enforcing authorization at every query entry point.
- Running Yamcs services with least-privilege operating-system, database, filesystem, and network permissions.
- Restricting archive SQL execution to trusted administrative workflows and isolating mission-control components where practical.
- Treating generated code and dynamic compilation as high-risk capabilities subject to dedicated security review.
How teams detect issues like this
Detection can combine source review, runtime monitoring, and policy enforcement:
- Use static analysis rules to identify string concatenation or interpolation of request-controlled values into Java source or compiler inputs.
- Review identifier sanitization functions for context confusion, incomplete allowlists, and transformations that do not guarantee valid non-executable identifiers.
- Search for dynamic compiler calls, including Janino compilation, on paths reachable from API or query inputs.
- Add security tests covering quoted identifiers, aggregate expressions, and other parser boundaries.
- Monitor archive SQL API activity for unusual query patterns, unexpected compilation errors, and requests from accounts not normally performing archival operations.
- Enforce policies requiring security review for dynamic code generation and for privileged query-execution endpoints.
- Automated code-review and software-composition tools may help identify unsafe source-generation and compiler usage patterns.

