Skip to content
Development preview · 2.0.0-SNAPSHOT

Security Guide

CompileFlow runs process definitions inside the host JVM; compiled mode generates Java code before execution. Treat every process definition as executable code.

This guide explains what to configure before production and how to operate those controls. See the Threat Model for the threats, built-in protections, and risks that the deployment must address.

Execute only trusted, reviewed, and authorized process definitions. XML definitions, Java scripts, other scripts, and host component calls can all use the host application’s privileges. CompileFlow does not provide a sandbox for arbitrary user code.

The application or operations platform is responsible for authenticating users, authorizing operations, isolating tenants, approving changes, and recording audits.

For an embedded engine, focus on definition sources, action permissions, and resource limits. A Workbench Server deployment also needs server authentication, gateway authorization, draft-execution controls, and audits.

Prefer classpath, reviewed repository, or approved database sources:

ProcessDefinition definition =
ProcessDefinition.classpath(ProcessModelType.BPMN, "order.process", "flows/order.bpmn");
engine.runtime().warmUp(definition);

When accepting external XML, authorize the submitter and review the code before running strict preflight in a trusted environment. Preflight checks the root definition and whether the selected execution mode can prepare its runtime, including the declared classes, methods, and script languages. It does not look up business objects or verify external dependencies. A script executor can defer its own compilation until evaluation, as MVEL does, so strict preflight does not guarantee successful script execution. Preflight is not a security sandbox. Keep raw diagnostic messages out of unauthorized responses and ordinary logs because they may contain source literals:

ProcessDefinition definition = ProcessDefinition.inline(ProcessModelType.TBBPM, "order.process", xmlContent);
ProcessPreflightOptions options = ProcessPreflightOptions.strict();
ProcessPreflightReport report = engine.tooling().preflight(definition, options);
if (report.getOverallStatus() == ProcessPreflightReport.OverallStatus.FAIL) {
// Keep the detailed report available only to maintainers authorized to inspect the source.
throw new SecurityException("Flow preflight failed");
}

compileflow-workbench-server authenticates requests using X-API-Key. Configure the key through compileflow.workbench.server.authentication.api-key or COMPILEFLOW_WORKBENCH_SERVER_CONFIG_AUTHENTICATION_API_KEY, and set compileflow.workbench.server.authentication.service-principal to the service account it represents. The server records that account as the actor for control-plane changes.

Authentication defaults to API_KEY. In this mode a missing key or one outside the required length and character set prevents startup. Use a randomly generated production key. Startup validation checks for 32–256 characters from A-Z, a-z, 0-9, ., _, ~, and -; it does not assess randomness. A service principal is required in both modes: 1–128 visible ASCII characters without whitespace. DISABLED requires an explicit dev or test profile and an absent API key. The Server rejects combinations of prod with either local profile even in API_KEY mode.

In production, a trusted gateway authenticates and authorizes end users, then adds the private Workbench Server key to its protected upstream connection. The gateway must first strip client-supplied X-API-Key, internal identity, forwarding, and client-IP headers. Vite exposes all VITE_* values to the browser, so the Web configuration accepts no credentials.

For example, if Alice and Bob reach the Server through a gateway that uses one shared key, the Server records both users’ operations under that key’s service account. It does not read a browser actor header or use it to identify the end user. For per-user accountability, the gateway must retain the authenticated user’s identity, authorization result, and action in its own audit trail. Server audits continue to record the configured service account.

The server validates API keys with a constant-time digest comparison. A valid shared key authenticates requests to all registered non-public endpoints; it does not enforce per-user or per-operation permissions. Those checks belong at the trusted gateway or the integrating application. With the default Actuator paths, only /actuator/health, /actuator/health/liveness, and /actuator/health/readiness allow anonymous access. List allowed paths explicitly so other Actuator, deployment, or control endpoints are not opened accidentally. Keep proxy connection details in protected logs; return a Problem Detail without sensitive information or a generic gateway error to the browser.

In PROCESS execution mode, POST /api/executions/preview compiles and executes a submitted definition with Workbench Server privileges and can produce real side effects. Passing preflight does not establish that execution is safe. The endpoint is absent by default and becomes available only with compileflow.workbench.server.preview-execution.enabled=true.

In DURABLE mode, previews use POST /api/durable/preview-runs and create persisted Runs. The Server requires Run admission to be enabled, the preview flag above, and an isolated PREVIEW host. Its Store, Workers, credentials, and external integrations must be isolated from production; setting the preview flag alone is insufficient. See Durable Workbench.

Keep it disabled in production. If it is required, the gateway must grant a dedicated draft-execution permission only to trusted flow authors. Run the server with minimal filesystem, network, database, and container privileges, and review the Spring business methods invoked by those definitions and the permissions they require. Use preflight when only validation is needed.

class actions, bean actions, and Java scripts run with the host application’s privileges.

The optional MVEL executor is for trusted expressions. Property reads can call getters, and method calls on mapped inputs use the privileges of the host application. See the MVEL execution policy.

The optional QLExpress executor restricts host access, but definitions still require review and resource controls. Before using it, check the accepted types, snapshot behavior, and timeout scope under QLExpress input and execution limits.

A class action generates code that constructs an object and calls its method directly. The engine validates class and method names first. The target class must provide a public no-argument constructor accessible to the generated code. The engine does not substitute private reflection or dependency injection. To call an existing business object, use a bean action with the component lookup described below.

A Java script (language="java") is a method body that CompileFlow places in a generated typed wrapper and compiles with javac --release 17. Core includes the Java executor’s service declaration. Declared inputs and outputs must use Java platform types. An empty compiler classpath prevents accidental dependencies on host-application JARs, but the script still runs with the host process’s privileges. Execute only trusted code in Workbench Server. Untrusted code needs an execution environment outside the CompileFlow deployment, isolated through operating-system or container controls.

With Spring Boot integration, component actions obtain business objects by the declared name and type from the application’s ApplicationContext; no separate extension declaration is needed for these objects. A missing bean or incompatible type fails execution, without constructing the class declared in XML as a substitute.

A plain Java application supplies a ProcessComponentResolver through ProcessEngineFactory.create(config, resolver) to call its existing business objects. The application owns the resolver and those objects; the engine does not close them. See the Extension guide for component lookup. In either integration, review the business methods a definition invokes and the permissions they require.

Variable defaults are data literals, parsed strictly before Java source is generated. @ has no special meaning. Invalid literals and unsupported object defaults fail preflight; they are not converted to null or executed as source.

Converting an integer to a narrower type must preserve its value. Time text uses explicit ISO formats, and conversion errors omit the original value. Instant represents an absolute time. Conversions to and from JDBC local-calendar types (java.sql.Date, Time, and Timestamp) preserve the JDK’s default-timezone behavior, so JVMs exchanging those values should use the same timezone. See Process Data Types and Conversion for the full rules.

A custom ScriptExecutor implementation must define its security, timeout, cache, and ClassLoader policies. Declare the implementation in the Extension service file. The engine creates instances through public no-argument constructors and calls close() on instances that implement AutoCloseable. In production:

  • Admit only reviewed and authorized flow definitions, regardless of script language, including Java, QLExpress, and MVEL.
  • Keep flow-facing business methods in focused components or interfaces, and review their external access and sensitive operations.
  • Run the host application with least-privilege OS, container, database, and network permissions.
  • Configure both COMPILEFLOW_WORKBENCH_SERVER_CONFIG_AUTHENTICATION_API_KEY and COMPILEFLOW_WORKBENCH_SERVER_CONFIG_AUTHENTICATION_SERVICE_PRINCIPAL. Set up the gateway and audits as described under Server Authentication Guard.
  • Serve APIs over HTTPS or through a trusted gateway that terminates TLS. Keep Workbench Server and its database on access-controlled private networks. Do not expose Actuator, deployment, or control APIs directly to the public internet.
  • Transmit the server API key only over protected server-side connections; never send it to the browser. CORS and ordinary ingress routing cannot replace authentication.

Embedded Engine and Deploy namespaces separate logical scopes; they do not authorize users. Workbench supports only default. Use separate deployments for tenant isolation, and separate databases where strict data isolation is required.

Check the operator’s permissions before publishing versions, creating or changing rollouts, promoting, aborting, rolling back, retiring an Alias, executing, or inspecting processes. Alias retirement stops new admission through that Alias once the serving node observes the retirement; it does not cancel admitted work or delete the published versions.

  • Put execution endpoints behind rate limits and request-size limits.
  • Bound worker concurrency and lease duration. Limit asynchronous admission at the application or gateway and monitor the persisted queue backlog; worker concurrency does not bound the number of queued database records.
  • Monitor compilation time, execution duration, memory, and failure rate.
  • Keep compileflow.engine.definition.max-size close to the largest reviewed production definition; increasing it increases the memory each concurrent parse may consume.
  • Reject structurally invalid flow definitions before deployment.
  • In Workbench, treat flow expressions as user input. Client-side simulation must use the allowlisted expression interpreter instead of eval or new Function.

Record the actor, time, tenant or environment, and target for:

  • Flow creation and update.
  • Preflight, publish, rollout create/update/promote/abort, rollback, Alias retirement, and delete operations.
  • Real execution requests.
  • API key and production configuration changes.

Store audit logs in append-only or centrally managed logging infrastructure.

Before production, verify these controls in a controlled environment: unauthenticated requests cannot reach deployment, execution, or control APIs; the gateway rejects users without the required permission; and the preview endpoint is unavailable when draft execution is disabled. Check that the browser build contains no server key and that one authorized operation can be correlated across gateway and Server audits.

The shared BPMN/TBBPM stream parser disables DTDs, external entities, and external DTD access, and limits XML element nesting to 128 levels. When XSD validation is enabled, the schema factory also enables secure processing; both the schema factory and validator prohibit external DTD and schema access. Schema imports are limited to permitted relative classpath resources. If a required security setting cannot be applied, parsing fails before reading the process model.

For ProcessEngine, inline and classpath definitions share compileflow.engine.definition.max-size, which defaults to 4 MiB. Durable has its own compileflow.durable.definition.max-size, also 4 MiB by default. The loader creates one immutable byte snapshot within that limit. For a classpath definition, every matching resource must contain identical bytes; conflicting copies are rejected. Schema validation and model parsing use the selected snapshot. The loader checks classpath URL syntax before opening a stream: only local file, jrt, or nested locations (including supported JAR wrappers) are accepted. Remote authorities, UNC paths, and other protocols are rejected. This is not a sandbox for custom ClassLoaders or URL handlers; trust the host-provided implementations.

The embedded engine does not download process definitions from URLs. When remote artifacts are needed, the application or deployment resolver retrieves them and enforces authentication, network access controls, timeouts, size limits, and digest checks before passing them to the compiler.

The QLExpress 4 executor discovered from the optional compileflow-script-qlexpress module uses a fixed ISOLATED profile, blocks host-object method calls, and exposes a fixed set of safe functions. QL array allocations are limited to 10,000 elements per dimension.

Before each evaluation, the executor snapshots the Action’s explicitly mapped inputs. Every mapped input must meet the following rules, even if the script never reads it. Process variables that are not mapped into the Action are not traversed.

Input category Accepted values
Null and simple scalars null, String, Boolean, Character
Numbers The JDK classes Byte, Short, Integer, Long, Float, Double, BigInteger, and BigDecimal
Containers Maps, Lists, Sets, and arrays whose contents satisfy the rules in this section

Scalar values must use the exact classes listed above; custom scalar implementations and subclasses are rejected. Container copying also follows these rules:

  • Map keys and Set members must be one of the accepted immutable scalars or null.
  • Maps, Lists, and Sets become standard data containers. Their custom classes, comparators, and rules for looking up objects by instance identity are not retained.
  • Shared references and cycles through Map values, List elements, and array elements are preserved within the snapshot. Script assignments modify the copies without mutating the caller’s containers.
  • If distinct Map keys or Set members would be treated as one equal value in the copy, the executor rejects the input with EVALUATION_FAILED.

Application objects outside the accepted types, including Function values and custom scalar implementations, fail with EVALUATION_FAILED. Array copies retain their original component type. If a copied element cannot be stored in an array of that type, evaluation also fails with EVALUATION_FAILED.

Building the snapshot traverses the mapped input objects and their references. For V objects and E references, it takes O(V + E) time and space. This work happens before the interpreter’s one-second cooperative timeout starts, so that timeout does not cap the duration or memory use of the whole call. The 10,000-element limit per array dimension applies to arrays created by the script; it does not bound the total input size. Continue to review definitions and apply resource limits in the application.

Prepared QL programs are retained by the Process runtime that loaded them. The executor holds only heap state, has no global expression cache, and requires no explicit shutdown.

This module’s qlexpress executor cannot enable host access. To use different functions or access rules, implement a public no-argument ScriptExecutor, annotate it with @ExtensionRealization and a higher priority, and list it in the Extension service file. It may use the same language key. See the Extension guide for the complete declaration.

If definitions in one engine must select different language semantics or access policies, expose them under distinct keys. Each language key resolves to the implementation selected by declared priority. Language keys do not enforce permissions or create a sandbox; the application remains responsible for the selected implementation’s security and Durable replay semantics.

The engine normalizes generated Java package, class, and helper-method names through JavaIdentifiers and GeneratedProcessNames. Process variable names must be legal, non-reserved Java identifiers. After validation, they keep their original names so the model, expressions, source mappings, and runtime state agree. These checks prevent invalid identifiers and reduce the risk of injecting code through generated names.

Before writing files, the compiler validates Java fully qualified names and normalizes paths, then writes source and class files under the configured compilation directory. In-memory compilation returns copies of class bytes, so callers cannot modify the internal compiled result.

Report vulnerabilities privately through GitHub Security Advisories.

Do not open public GitHub issues for vulnerabilities.