fix: harden workflow execution against code injection (RCE)#455
fix: harden workflow execution against code injection (RCE)#455wzg2311 wants to merge 2 commits into
Conversation
Three security hardening measures: 1. Sandbox exec() builtins in PythonExecRuntime — block eval/exec/compile/__import__ and restrict imports to a safe allowlist, preventing arbitrary code execution even when workflow node code unsafely processes inputs. 2. Switch Jinja2 Template to SandboxedEnvironment in LLM and HTTP request nodes, preventing SSTI attacks through template rendering. 3. Add security comment to PUBLIC_PATH_REGEXES warning against adding workflow webhook paths to the auth bypass whitelist (refs AgentFlocks#454). Closes AgentFlocks#454 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Findings [P1] Anonymous workflow webhook triggering still remains when applied to current dev. |
Summary
Addresses the security vulnerabilities reported in #454.
Three hardening measures to prevent code injection / RCE through workflow execution:
exec()builtins inPythonExecRuntime— blockeval/exec/compile/__import__and restrict imports to a safe allowlist, so even if workflow node code unsafely processes inputs (e.g.eval(inputs["expression"])), attackers cannot importos/subprocessor call dangerous builtinsSandboxedEnvironmentin LLM and HTTP request nodes — prevents SSTI through template renderingPUBLIC_PATH_REGEXESwarning against adding workflow webhook paths to the auth bypass whitelistFiles changed
flocks/workflow/repl_runtime.py_make_safe_builtins()with blocked builtins + import allowlist; apply toexec()contextflocks/workflow/engine.pyjinja2.Templatewithjinja2.sandbox.SandboxedEnvironmentin LLM + HTTP request nodesflocks/server/auth.pyPUBLIC_PATH_REGEXESreferencing #454Context
When a workflow webhook trigger has
auth.type="none"(the default) and the webhook path is in the auth bypass whitelist, an anonymous attacker can trigger workflow execution with attacker-controlled inputs. If a Python node then processes those inputs unsafely (e.g.eval(inputs["expr"])), it leads to RCE in the host process.This PR hardens the execution layer so that even in the worst case (auth bypass + unsafe node code), the blast radius is contained:
eval()/exec()/compile()are removed from builtinsSee #454 for full vulnerability details, reproduction steps, and additional recommendations (P0: enforce webhook trigger auth, P2: change
TriggerAuthdefault).Test plan
json,re,datetimeetc. which are in the allowlist)eval()/exec()are blocked in workflow node codeimport os/import subprocessare blocked in workflow node codeCloses #454