diff --git a/SECURITY.md b/SECURITY.md index 7f98faf..193a993 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -5,7 +5,7 @@ If you discover a security vulnerability in nanobot, please report it by: 1. **DO NOT** open a public GitHub issue -2. Email the maintainers at [security@nanobot.ai] or create a private security advisory on GitHub +2. Create a private security advisory on GitHub or contact the repository maintainers 3. Include: - Description of the vulnerability - Steps to reproduce diff --git a/nanobot/agent/tools/shell.py b/nanobot/agent/tools/shell.py index 5d17448..5319c57 100644 --- a/nanobot/agent/tools/shell.py +++ b/nanobot/agent/tools/shell.py @@ -10,8 +10,7 @@ from nanobot.agent.tools.base import Tool # List of potentially dangerous command patterns DANGEROUS_PATTERNS = [ - r'rm\s+-rf\s+/\s*$', # rm -rf / (at root only) - r'rm\s+-rf\s+/(?![\w/])', # rm -rf / followed by whitespace or end + r'rm\s+-rf\s+/(?:\s|$)', # rm -rf / (at root, followed by space or end) r':\(\)\{\s*:\|:&\s*\};:', # fork bomb r'mkfs\.', # format filesystem r'dd\s+if=.*\s+of=/dev/(sd|hd)', # overwrite disk @@ -19,7 +18,7 @@ DANGEROUS_PATTERNS = [ ] -def _is_dangerous_command(command: str) -> tuple[bool, str | None]: +def validate_command_safety(command: str) -> tuple[bool, str | None]: """ Check if a command contains dangerous patterns. @@ -66,7 +65,7 @@ class ExecTool(Tool): async def execute(self, command: str, working_dir: str | None = None, **kwargs: Any) -> str: # Check for dangerous command patterns - is_dangerous, warning = _is_dangerous_command(command) + is_dangerous, warning = validate_command_safety(command) if is_dangerous: return f"Error: Refusing to execute dangerous command. {warning}"