Skip to main content
Menu
Advisories

SpEL injection in the form-flow engine allows Remote Code Execution by configuration admins

GHSA-MW2G-FRP7-66R8Published Updated GitHub

Description

The form-flow engine evaluates the SpEL expressions of a step (onOpen, onComplete, onBack, and nextSteps[].condition) against an unrestricted org.springframework.expression.spel.support.StandardEvaluationContext. That context permits type references T(...), constructor calls and arbitrary method invocation, so a step expression such as ${T(java.lang.Runtime).getRuntime().exec(...)} executes arbitrary Java — and therefore arbitrary OS commands — inside the Valtimo JVM.

These expressions are authored through the form-flow definition management API (POST/PUT /api/management/v1/case-definition/{key}/version/{tag}/form-flow-definition, gated on the ADMIN authority) and are executed the moment any user opens, completes or navigates back a step — endpoints that only require an authenticated session.

This is a privilege-boundary crossing: an application-configuration admin obtains full code execution on the server.

Details

Root cause. SpelExpressionProcessorFactory.kt:27 constructs the context with the bare StandardEvaluationContext(), adds two property accessors (SpelExpressionProcessorFactory.kt:28-29) and hands it to the processor at SpelExpressionProcessorFactory.kt:37. In SpelExpressionProcessor.kt:41, process() calls spelExpression.getValue(evaluationContext, contextMap, resultType). Because StandardEvaluationContext applies no type/method restrictions, the expression string can reach any class on the classpath.

Runtime path. All four step-level expression kinds flow into this evaluator via FormFlowStepInstance.kt:

  • open() → processExpressions(definition.onOpen) (FormFlowStepInstance.kt:85-87)
  • complete() → processExpressions(definition.onComplete) (FormFlowStepInstance.kt:89-103, evaluation at :98)
  • back() → processExpressions(definition.onBack) (FormFlowStepInstance.kt:76-78)
  • determineNextStep() → processExpressions(nextSteps[].condition) (FormFlowStepInstance.kt:105-123)

processExpressions (FormFlowStepInstance.kt:125) obtains the factory, calls factory.create(variables) (:128) and then expressionProcessor.process<T>(expression) (:133).

Privilege boundary.

  • Writing the expressions requires ADMIN (ROLE_ADMIN). The management endpoints are declared in FormFlowManagementResource.kt (POST :98-112, PUT :114-130, DELETE :83-96) and gated in ValtimoFormFlowHttpSecurityConfigurer.kt:48-50 with .hasAuthority(ADMIN) (ADMIN resolves to ROLE_ADMIN, AuthoritiesConstants.java:22).
  • Executing them requires only an authenticated session. The runtime endpoints are declared in FormFlowResource.kt (open :50-71, complete :73-98, back :100-121, save :123-140) and gated in ValtimoFormFlowHttpSecurityConfigurer.kt:33-43 with .authenticated().

An ADMIN can create their own case/form-flow instance and open/complete a step themselves, so no second victim and no user interaction are required to fire the payload.

Proof of Concept

Confirmed in a lab by exercising the real vulnerable factory path (SpelExpressionProcessorFactory → StandardEvaluationContext) with a test in the :backend:form-flow module. Both tests pass (2/2, BUILD SUCCESSFUL), including a fresh re-run with --rerun-tasks:

private fun processor() = SpelExpressionProcessorFactory()
    .apply { setFlowProcessBeans(emptyMap()) }
    .create(emptyMap())

// PoC 1 — type reference reaches arbitrary Java: returns the real OS user
processor().process<String>("\${T(java.lang.System).getProperty('user.name')}")
// == System.getProperty("user.name")

// PoC 2 — Runtime.exec runs a real OS command; the marker file is created on disk
processor().process<Any>(
    "\${T(java.lang.Runtime).getRuntime()" +
    ".exec(new String[]{'/bin/sh','-c','touch <marker>'}).waitFor()}"
)
// marker file exists afterwards -> genuine OS command execution
  • PoC 1 returned the actual OS username via T(java.lang.System).getProperty('user.name').
  • PoC 2 ran T(java.lang.Runtime).getRuntime().exec(...); the marker file was actually written to disk, proving real OS command execution — not merely expression evaluation.

End-to-end, the same effect is reached over HTTP by an ADMIN who saves a form-flow definition whose step carries the payload (e.g. in onOpen), then opens the step.

Impact

Remote Code Execution on the host running Valtimo. An attacker with the ADMIN (configuration) authority — but no legitimate host/OS access — can execute arbitrary OS commands, read environment variables and JVM system properties (secrets, credentials, tokens), read/write files, and pivot from the application to the underlying host. Confidentiality, integrity and availability of the host are all fully compromised.

Severity

  • CVSS v3.1: 9.1 (Critical) — CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H

Scope is treated as Changed because the vulnerable component (the Valtimo application, whose security authority manages application roles) is used to gain control of a different security scope (the host OS / JVM process).

  • CWE-917: Improper Neutralization of Special Elements used in an Expression Language Statement ('Expression Language Injection') (primary; most precise for SpEL). Related: CWE-94 (Code Injection), as used in the sibling advisory.

Remediation

Build the form-flow expression context with the safe SimpleEvaluationContext instead of StandardEvaluationContext, mirroring Condition.kt and DocumentMigrationService.kt, so admin-authored flow expressions can no longer reach arbitrary Java/OS. Concretely, in SpelExpressionProcessorFactory.create() replace:

val context = StandardEvaluationContext()
context.addPropertyAccessor(MapAccessor())
context.addPropertyAccessor(WritableJsonPropertyAccessor())

with a SimpleEvaluationContext built via SimpleEvaluationContext.forPropertyAccessors(MapAccessor(), WritableJsonPropertyAccessor()) (adding DataBindingMethodResolver only if method calls on data objects are genuinely required). This disables T(...) type references and constructor invocation while preserving property/map access used by legitimate flow expressions.

Existing form-flow definitions should be reviewed and re-validated after upgrading, since expressions that previously relied on type references will (correctly) stop resolving.

Workarounds

Until patched: restrict the ADMIN authority to fully trusted operators only, treat form-flow definition write access as equivalent to shell access on the host, and audit existing form-flow definitions for T( / new constructs in onOpen, onComplete, onBack and nextSteps[].condition.

Credits

Reported responsibly by Ray Sabee (whitehatsecurity.nl), independent security researcher — GitHub @raysabee.

Affected versions

References

GitHub · valtimo-platform/valtimo