T09 · Insecure Skill Coding Practices
- Location
scripts/helpers.py:35- Finding
Lexical sandbox bypass permits arbitrary host-level code execution
- Content
View full analysis
str | None: """Check script for disallowed patterns. Returns error message or None if clean.""" for pattern in BLOCKED_PATTERNS: match = re.search(pattern, script) if match: return f"Blocked: script contains disallowed pattern '{match.group()}'" # Check imports — only allow whitelisted modules for match in re.finditer(r"(?:from|import)\s+([\w.]+)", script): module = match.group(1).split(".")[0] if module not in ALLOWED_IMPORTS: return f"Blocked: import of '{module}' is not allowed. Allowed: {', '.join(sorted(ALLOWED_IMPORTS))}" return None ``` ```python # scripts/helpers.py:78-100 def _extract_user_script(full_script: str) -> str | None: """Extract user code between marker comments, or return None if no markers.""" m = re.search( r"# --- user script ---\n(.*?)# --- end user script ---", full_script, re.DOTALL, ) return m.group ...[truncated 3871 chars]- Remediation
View remediation
