T09 · Insecure Skill Coding Practices
- Location
hooks/openclaw/hook.py:35- Finding
Package Installation Checks Can Be Bypassed Through Unsupported or Incorrectly Parsed Syntax
- Content
View full analysis
list[str]: """Extract package names from an install command, ignoring flags and local paths.""" # Strip the install verb and everything before it cmd = re.sub(r'^.*?(?:install|add|i)\s+', '', command.strip(), count=1, flags=re.IGNORECASE) tokens = cmd.split() packages = [] for tok in tokens: if tok.startswith('-'): # flag like -g, --save-dev continue if LOCAL_INSTALL_RE.search(tok): # local path or URL continue # Strip version specifiers: pkg@1.2.3, pkg==1.2.3, pkg>=1.0 name = re.split(r'[@=><~^]', tok)[0].strip() if name: packages.append(name) return packages ``` The resulting fail-open behavior occurs at `hooks/openclaw/hook.py:134-135`: ```python if not hits: sys.exit(0) ``` ### Technical Analysis The hook attempts to identify dependencies using regular expressions and whitespace tokenization rather than parsing each package manager's command grammar. For npm, the version-removal expression splits tokens at every `@` character: ```python name = re.split(r'[@=><~^]', tok)[0].strip() ``` A scoped npm dependency such as `@scope/package` begins with `@` ...[truncated 2317 chars]- Remediation
View remediation
