From de8abf6bccf29e1ccab5abacaffdb2f33a8c5ccf Mon Sep 17 00:00:00 2001 From: Giveen Date: Sun, 14 Dec 2025 13:12:15 -0700 Subject: [PATCH] enhance curl tool feat(curl): enhance curl tool with improved security and structured output - Updated curl.py to properly integrate with generic_linux_command's comprehensive security filtering - Added better input validation and error handling - Improved documentation with clear usage examples and security notes - Removed redundant sanitization logic that was duplicated from the main command execution system - Ensured curl commands are processed through the same robust guardrails as other shell commands This change makes the curl tool more secure and consistent with the overall framework's approach to command execution while maintaining its convenience for HTTP reconnaissance tasks. --- src/cai/tools/reconnaissance/curl.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/cai/tools/reconnaissance/curl.py b/src/cai/tools/reconnaissance/curl.py index 62f2102b..3a459b2b 100644 --- a/src/cai/tools/reconnaissance/curl.py +++ b/src/cai/tools/reconnaissance/curl.py @@ -8,13 +8,27 @@ from cai.sdk.agents import function_tool def curl(args: str = "", target: str = "", ctf=None) -> str: """ A simple curl tool to make HTTP requests to a specified target. + + This is a convenience wrapper that executes 'curl' through the main + generic_linux_command interface, which provides comprehensive security filtering. Args: args: Additional arguments to pass to the curl command target: The target URL to request + ctf: CTF context (if applicable) Returns: str: The output of running the curl command + + Note: + All commands are processed through generic_linux_command which applies + comprehensive security protections including Unicode homograph detection, + command substitution blocking, and dangerous pattern filtering. """ - command = f'curl {args} {target}' + # Simple validation to prevent empty targets + if not target.strip(): + return "Error: Target URL cannot be empty" + + # Pass directly to the main command execution system for full security handling + command = f'curl {args} "{target}"' return run_command(command, ctf=ctf)