security: add SSRF protection, untrusted content marking, and internal URL blocking

This commit is contained in:
Xubin Ren
2026-03-16 15:05:26 +08:00
committed by Xubin Ren
parent d6df665a2c
commit 6e2b6396a4
9 changed files with 370 additions and 4 deletions
+4
View File
@@ -154,6 +154,10 @@ class ExecTool(Tool):
if not any(re.search(p, lower) for p in self.allow_patterns):
return "Error: Command blocked by safety guard (not in allowlist)"
from nanobot.security.network import contains_internal_url
if contains_internal_url(cmd):
return "Error: Command blocked by safety guard (internal/private URL detected)"
if self.restrict_to_workspace:
if "..\\" in cmd or "../" in cmd:
return "Error: Command blocked by safety guard (path traversal detected)"