Back to skill

Security audit

MayGuard

Security checks for vulnerabilities and agentic risk

Overview

MayGuard is a local skill-auditing script with no apparent harmful payload, but it can read outside the chosen audit folder through symlinks and can miss hidden files, so it should be reviewed before use.

Use this only as a lightweight helper, not as a definitive safety gate. Audit untrusted skills in a sandbox, do not rely on a `SAFE` result unless hidden files, archives, and symlinks have also been handled, and prefer a fixed version that rejects symlinks and reports skipped files.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (2)

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
scripts/audit.py:27
Finding
Symlink Traversal Allows Reads Outside the Audit Target<![CDATA[ ## Vulnerability Details **File Location**: `scripts/audit.py:27-35` **Vulnerability Type**: Symlink traversal and out-of-scope file access **Risk Level**: Medium ### Vulnerable Code ```python for root, dirs, files in os.walk(target_path): for file in files: # Skip hidden files or specific extensions if needed if file.startswith('.') or file.endswith(('.pyc', '.skill', '.zip')): continue file_path = os.path.join(root, file) try: with open(file_path, "r", encoding="utf-8", errors="ignore") as f: content = f.read() ``` ### Technical Analysis The scanner recursively enumerates a user-supplied directory and opens each discovered file without verifying whether it is a symbolic link or whether its resolved path remains inside the requested audit root. Although `os.walk()` does not follow symlinked directories by default, symlinked files can still appear in the `files` collection. Python's `open()` follows such links. Consequently, an untrusted Skill can include a file symlink pointing to any file readable by the user running the auditor. Reading files outside the selected directory exceeds the minimum privileges needed for static analysis of that directory. The file contents are not printed or transmitted directly, which limits immediate disclosure, but pattern matches can reveal properties of external files and alter the generated risk report. Links to special files may also block or disrupt the audit. ### Attack Path 1. An attacker creates a Skill directory containing a non-hidden file symlink to a sensitive local file, such as an SSH private key or application credential file. 2. A victim runs `python3 scripts/audit.py <attacker-controlled-directory>`. 3. `os.walk()` lists the symlink as a file. 4. `open(file_path, ...)` follows the link and reads the external target with the victim's filesystem privileges. 5. Content from the out-of-scope file is tested again ...[truncated 722 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Reject symbolic links before opening candidates, using `os.path.islink()` or `os.stat(..., follow_symlinks=False)`. - Resolve the audit root and each candidate with `os.path.realpath()`, then verify that the candidate remains beneath the resolved root with `os.path.commonpath()`. - Process only regular files and reject devices, sockets, FIFOs, and other special file types. - Handle race conditions by opening files without following symlinks where the operating system supports `O_NOFOLLOW`, then validate the opened descriptor with `fstat()`. - Add file-size and read-time limits to reduce denial-of-service risk. Example boundary validation: ```python root_real = os.path.realpath(target_path) candidate_real = os.path.realpath(file_path) if os.path.commonpath([root_real, candidate_real]) != root_real: continue if os.path.islink(file_path) or not os.path.isfile(file_path): continue ``` Descriptor-based checks should be preferred when protection against time-of-check/time-of-use races is required. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/audit.py:29
Finding
Hidden-File Exclusion Creates a Direct Static-Analysis Bypass<![CDATA[ ## Vulnerability Details **File Location**: `scripts/audit.py:29-30` **Vulnerability Type**: Security scanner detection bypass **Risk Level**: Medium ### Vulnerable Code ```python for root, dirs, files in os.walk(target_path): for file in files: # Skip hidden files or specific extensions if needed if file.startswith('.') or file.endswith(('.pyc', '.skill', '.zip')): continue ``` The exclusion also conflicts with the credential-theft signature declared in `references/threat_patterns.json:2-10`: ```json "credential_theft": [ "\\.env", "id_rsa", "openclaw\\.json", "credentials", "passwd", "shadow", "~/.config" ] ``` ### Technical Analysis All filenames beginning with `.` are silently skipped. This creates a predictable bypass because attackers can place malicious source code, instructions, or credential-access logic in a hidden file. The behavior also prevents meaningful detection of `.env` files even though `.env` is explicitly listed as a credential-theft pattern. The scanner tests file contents rather than filenames, so the mere presence of a `.env` file cannot trigger the `\\.env` expression, and the file itself is excluded from content analysis. Files ending in `.skill` or `.zip` are also ignored without being inspected or reported as unsupported. Therefore, a `SAFE` result does not establish that all relevant content in the supplied directory was examined. ### Attack Path 1. An attacker places a malicious script or agent instruction in a file such as `.payload`, `.config-hook`, or `.env`. 2. The victim audits the directory before installation. 3. The scanner reaches the exclusion condition and skips the malicious file without producing a warning. 4. No threat expressions are evaluated against that content. 5. If the remaining visible files contain no matching patterns, the scanner can return `SAFE`. 6. The victim may install or execute the Skill based on this incomplete result. ### Impact Asse ...[truncated 531 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Scan hidden files by default because dotfiles commonly contain executable configuration, secrets, and agent instructions. - Evaluate threat patterns against both relative filenames and file contents so signatures such as `\\.env` can detect relevant filenames. - Replace silent exclusions with explicit report entries that distinguish `not scanned`, `unsupported`, and `safe`. - If exclusions are needed for performance, make them configurable and clearly disclose them in the final status. - Safely inspect supported `.zip` and `.skill` packages in an isolated temporary directory with archive traversal, symlink, nesting-depth, expanded-size, and file-count protections. - Prevent the overall result from being reported as `SAFE` when relevant files were skipped or could not be read. - Add regression tests demonstrating that malicious patterns in `.env`, `.hidden-script`, and supported package files are detected. ]]>
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (8)

Tool Parameter Abuse

High
Category
Tool Misuse
Content
ClawGuard maintains a database of threat patterns in `references/threat_patterns.json`, including:
- **Credential Theft:** Access to `.env`, SSH keys, or config files.
- **Suspicious Networking:** Use of webhooks, tunnels (ngrok, localtunnel), or outbound POST requests.
- **Destructive Commands:** `rm -rf /`, disk formatting, or privilege escalation.
- **Obfuscation:** Use of `eval`, `exec`, or base64 decoding to hide logic.

## 🤝 Community Responsibility
Confidence
85% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Credential Access

High
Category
Privilege Escalation
Content
{
  "credential_theft": [
    "\\.env",
    "id_rsa",
    "openclaw\\.json",
    "credentials",
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
"aiohttp"
  ],
  "destructive_commands": [
    "rm -rf /",
    "truncate",
    "chmod 777",
    "chown root",
Confidence
90% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Tool Parameter Abuse

High
Category
Tool Misuse
Content
"aiohttp"
  ],
  "destructive_commands": [
    "rm -rf /",
    "truncate",
    "chmod 777",
    "chown root",
Confidence
90% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Tool Parameter Abuse

High
Category
Tool Misuse
Content
"aiohttp"
  ],
  "destructive_commands": [
    "rm -rf /",
    "truncate",
    "chmod 777",
    "chown root",
Confidence
85% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Tool Parameter Abuse

High
Category
Tool Misuse
Content
"destructive_commands": [
    "rm -rf /",
    "truncate",
    "chmod 777",
    "chown root",
    "mkfs",
    "dd if=/dev/zero"
Confidence
80% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Lp3

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding
Without declared permissions the skill's intent is opaque and cannot be validated.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
"destructive_commands": [
    "rm -rf /",
    "truncate",
    "chmod 777",
    "chown root",
    "mkfs",
    "dd if=/dev/zero"
Confidence
80% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Static analysis

No suspicious patterns detected.