hermes - 💡(How to fix) Fix [workflow-engine] CRITICAL: variable substitution crashes on regex metachars in user input

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

user_message / issue_context are fully attacker/user-controlled via POST /runs. A user_message of hello \1 raises re.error (verified), failing every prompt/bash/script node that references $USER_MESSAGE. Worse, a crafted \g<...> could pull unintended capture content.

Fix Action

Fix

Use literal replacement — str.replace, or a lambda replacement so the value is never parsed:

result = re.sub(r"\$USER_MESSAGE", lambda _m: user_message, result)

or precompile and use re.sub(pat, lambda _m: val, result) uniformly.


Filed from opus-4.8 plugin audit (workflow-engine) vs upstream NousResearch plugin conventions.

Code Example

result = re.sub(r"\$USER_MESSAGE", user_message, result)
result = re.sub(r"\$ARGUMENTS", user_message, result)
...
result = re.sub(r"\$CONTEXT", issue_context, result)

---

result = re.sub(r"\$USER_MESSAGE", lambda _m: user_message, result)
RAW_BUFFERClick to expand / collapse

Severity: CRITICAL (correctness, user-input-triggered)

substitute_workflow_variables passes user-controlled values as the replacement argument to re.sub, which interprets \1, \g<0>, \\ as backreferences/escapes.

Evidence

plugins/workflow-engine/engine/core/executor_shared.py:157-177

result = re.sub(r"\$USER_MESSAGE", user_message, result)
result = re.sub(r"\$ARGUMENTS", user_message, result)
...
result = re.sub(r"\$CONTEXT", issue_context, result)

user_message / issue_context are fully attacker/user-controlled via POST /runs. A user_message of hello \1 raises re.error (verified), failing every prompt/bash/script node that references $USER_MESSAGE. Worse, a crafted \g<...> could pull unintended capture content.

Impact

Any workflow run whose user message contains a backslash-digit sequence crashes substitution. Denial-of-functionality; potential surprising text injection.

Fix

Use literal replacement — str.replace, or a lambda replacement so the value is never parsed:

result = re.sub(r"\$USER_MESSAGE", lambda _m: user_message, result)

or precompile and use re.sub(pat, lambda _m: val, result) uniformly.


Filed from opus-4.8 plugin audit (workflow-engine) vs upstream NousResearch plugin conventions.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING