Replace unconstrained expression evaluation in calculate_math tool handlers with safe_eval_math(), which parses into an AST and only allows literal numbers and basic arithmetic operators. Function calls, attribute access, and name lookups are rejected, preventing arbitrary code execution via prompt injection through LLM-generated tool calls. Affected files: - scripts/web_demo.py (Streamlit demo) - scripts/eval_toolcall.py (tool call testing) - trainer/train_agent.py (agent training) |
||
|---|---|---|
| .. | ||
| chat_api.py | ||
| convert_model.py | ||
| eval_toolcall.py | ||
| serve_openai_api.py | ||
| web_demo.py | ||