Skip to content

Your lightweight open-source personal agent.

fix(security): use re.fullmatch per segment instead of re.search

michaelxerf4a7079e65e8
diff --git a/nanobot/agent/tools/shell.py b/nanobot/agent/tools/shell.py
index 26fb9fa90..37d16e1b5 100644
--- a/nanobot/agent/tools/shell.py
+++ b/nanobot/agent/tools/shell.py
@@ -759,7 +759,7 @@ class ExecTool(Tool):
# only explicitly allowed when every top-level shell segment matches.
segments = self._split_shell_segments(lower)
explicitly_allowed = bool(self.allow_patterns) and bool(segments) and all(
- any(re.search(pattern, segment) for pattern in self.allow_patterns)
+ any(re.fullmatch(pattern, segment) for pattern in self.allow_patterns)
for segment in segments
)
if not explicitly_allowed: