Security Fix: Replace eval() with json.loads() in Tree-of-Thought solver#1946
Open
paipeline wants to merge 1 commit intoFoundationAgents:mainfrom
Open
Security Fix: Replace eval() with json.loads() in Tree-of-Thought solver#1946paipeline wants to merge 1 commit intoFoundationAgents:mainfrom
paipeline wants to merge 1 commit intoFoundationAgents:mainfrom
Conversation
Fixes FoundationAgents#1933 - Remote Code Execution vulnerability in ToT solver The Tree-of-Thought solver was using eval() to parse LLM responses, which could execute arbitrary Python code if an attacker influenced the LLM output through prompt injection. Changes: - Replace eval(thoughts) with json.loads(thoughts) for safe JSON parsing - Add proper error handling with try/except block - Log parsing errors and return empty list on failure - Add comprehensive security tests to prevent regression This maintains the expected JSON parsing functionality while eliminating the RCE attack vector. The fix follows security best practices by using a safe parser that only handles the expected data format (JSON). Security Impact: Eliminates Remote Code Execution (RCE) vulnerability with CVSS score 8.1 (High severity)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔒 Security Fix - Critical RCE Vulnerability
Fixes #1933 - Remote Code Execution (RCE) vulnerability in Tree-of-Thought solver
🐛 Issue Description
The Tree-of-Thought solver was using Python's
eval()function to parse LLM responses without validation. This created a critical Remote Code Execution vulnerability where attackers could execute arbitrary Python code by influencing LLM output through prompt injection.Vulnerable code path:
✅ Solution
Replace the dangerous
eval()call with safejson.loads()parsing:🛠️ Changes Made
eval(thoughts)withjson.loads(thoughts)🔬 Security Testing
Created test suite that verifies:
📊 Impact Assessment
json.loads()is faster thaneval()This is a critical security fix that should be merged and released promptly to protect users from potential Remote Code Execution attacks.