Skip to content

fix: Remove eval() from workflow condition evaluation#88

Closed
Joshua-Medvinsky wants to merge 1 commit into
themanojdesai:mainfrom
Joshua-Medvinsky:fix/eval-rce
Closed

fix: Remove eval() from workflow condition evaluation#88
Joshua-Medvinsky wants to merge 1 commit into
themanojdesai:mainfrom
Joshua-Medvinsky:fix/eval-rce

Conversation

@Joshua-Medvinsky

Copy link
Copy Markdown

Summary

  • Removes unsafe eval() call used to evaluate workflow condition strings
  • Forces callers to supply a proper callable (e.g. lambda) instead of a raw expression string
  • Eliminates remote code execution risk when condition values originate from user-supplied input

Vulnerability

python_a2a/workflow.py evaluated the condition parameter with Python's eval() if it was not callable:

self.condition_func = lambda: eval(self.condition, {"agent": self.agent})

An attacker who controls the condition argument (e.g. via a serialised workflow definition or API call) can pass any Python expression — including __import__('os').system('...') — resulting in arbitrary code execution with the privileges of the server process.

Severity: Critical
CWE: CWE-94 (Code Injection)

Fix

if not callable(self.condition):
    raise ValueError("Condition must be a callable, not a string. Use lambda instead.")

Callers that previously passed strings must migrate to lambdas:

# Before (unsafe)
Workflow(condition="some_expression")

# After (safe)
Workflow(condition=lambda: some_expression)

Test plan

  • Confirm ValueError is raised when a string condition is passed
  • Confirm existing callable conditions continue to work
  • No regression in existing workflow tests

Replaces dangerous eval() call in workflow condition handling with explicit callable requirement.

Fixes: Code Injection in python_a2a/workflow.py:47
@Joshua-Medvinsky

Copy link
Copy Markdown
Author

Closing — duplicate of #89 which was submitted moments later with the same fix. Sorry for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant