Skip to content

Personal AI, On Personal Devices

Python

fix: add SSRF check in WebSearchTool to prevent unsafe URL access

xbsheng9c3803828b91
diff --git a/src/openjarvis/tools/web_search.py b/src/openjarvis/tools/web_search.py
index 0b01f8cc..430e58b3 100644
--- a/src/openjarvis/tools/web_search.py
+++ b/src/openjarvis/tools/web_search.py
@@ -8,6 +8,7 @@ from typing import Any
from openjarvis.core.registry import ToolRegistry
from openjarvis.core.types import ToolResult
from openjarvis.tools._stubs import BaseTool, ToolSpec
+from openjarvis.security.ssrf import check_ssrf
@ToolRegistry.register("web_search")
@@ -76,6 +77,9 @@ class WebSearchTool(BaseTool):
import httpx
url = WebSearchTool._normalize_url(url)
+ ssrf_error = check_ssrf(url)
+ if ssrf_error:
+ raise ValueError(ssrf_error)
resp = httpx.get(
url.strip(),
follow_redirects=True,