Skip to content

armgit / strix

Public Imported from GitHub
0

Open-source AI penetration testing tool to find and fix your app’s vulnerabilities.

fix: add timeout to sandbox tool execution HTTP calls

0xallambd8d927f34e9
diff --git a/strix/tools/executor.py b/strix/tools/executor.py
index 6dd1b04d..d99da60a 100644
--- a/strix/tools/executor.py
+++ b/strix/tools/executor.py
@@ -17,6 +17,10 @@ from .registry import (
)
+SANDBOX_EXECUTION_TIMEOUT = float(os.getenv("STRIX_SANDBOX_EXECUTION_TIMEOUT", "120"))
+SANDBOX_CONNECT_TIMEOUT = float(os.getenv("STRIX_SANDBOX_CONNECT_TIMEOUT", "10"))
+
+
async def execute_tool(tool_name: str, agent_state: Any | None = None, **kwargs: Any) -> Any:
execute_in_sandbox = should_execute_in_sandbox(tool_name)
sandbox_mode = os.getenv("STRIX_SANDBOX_MODE", "false").lower() == "true"
@@ -62,10 +66,15 @@ async def _execute_tool_in_sandbox(tool_name: str, agent_state: Any, **kwargs: A
"Content-Type": "application/json",
}
+ timeout = httpx.Timeout(
+ timeout=SANDBOX_EXECUTION_TIMEOUT,
+ connect=SANDBOX_CONNECT_TIMEOUT,
+ )
+
async with httpx.AsyncClient(trust_env=False) as client:
try:
response = await client.post(
- request_url, json=request_data, headers=headers, timeout=None
+ request_url, json=request_data, headers=headers, timeout=timeout
)
response.raise_for_status()
response_data = response.json()