Back to skill

Security audit

Security Checker

Security checks for vulnerabilities and agentic risk

Overview

This security-checker is not malicious, but its documented automated gate fails open and can let flagged code proceed as if it passed.

Use this only as an advisory scanner unless the exit-code bug is fixed. Do not rely on its documented shell examples to block commits or publishing, because warnings and scan errors currently still return success.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/security_scan.py:120
Finding

Security Scan Fails Open Because Findings Do Not Produce a Nonzero Exit Status

Content
View full analysis

Vulnerability Details

File Location: scripts/security_scan.py, lines 120-154
Vulnerability Type: Fail-open security control caused by incorrect process exit-status handling
Risk Level: High

Vulnerable Code

python
def main():
    if len(sys.argv) < 2:
        print("Security Scanner - Scan Python code before publishing")
        print("\nUsage: security_scan.py <file_or_directory>")
        print("\nChecks for:")
        print("  • Dangerous imports (os, subprocess, etc.)")
        print("  • Dangerous functions (eval, exec, system)")
        print("  • Hardcoded secrets/tokens")
        print("  • Unsafe file operations")
        return
    
    target = Path(sys.argv[1])
    
    print(f"\n🔒 Security Scan: {target}")
    print("=" * 60)
    
    if target.is_file():
        issues = scan_file(target)
        if issues:
            print(f"\n⚠️  Found {len(issues)} issue(s):\n")
            for issue in issues:
                print(issue)
        else:
            print("\n✅ No security issues found")
    elif target.is_dir():
        all_issues = scan_directory(target)
        total_issues = sum(len(file_issues) for _, file_issues in all_issues)
        
        print("\n" + "=" * 60)
        if total_issues > 0:
            print(f"\n⚠️  Found {total_issues} total issue(s) across {len(all_issues)} file(s)")
        else:
            print("\n✅ All clear - No security issues found")
    else:
        print(f"Error: {target} is not a valid file or directory")

if __name__ == "__main__":
    main()

Technical Analysis

The scanner reports findings only through console output. It never returns a nonzero result from main() and does not pass a result to sys.exit(). Consequently, the Python interpreter terminates with exit status 0 in all of the following situations:

  • Dangerous patterns or possible secrets are detected.

...[truncated 2178 chars]

Remediation
View remediation

Remediation Suggestions

Refactor main() to return explicit status codes and terminate through sys.exit(main()). Exit status 0 should be reserved exclusively for a completed scan with no findings.

Recommended status policy:

  • 0: Scan completed and no issues were found.
  • 1: One or more security findings were detected.
  • 2: Invalid invocation, invalid target, unreadable input, or another operational scanning error.

Example hardened structure:

python
def main():
    if len(sys.argv) != 2:
        print("Usage: security_scan.py <file_or_directory>", file=sys.stderr)
        return 2

    target = Path(sys.argv[1])

    if target.is_file():
        issues = scan_file(target)
        if issues:
            for issue in issues:
                print(issue)
            return 1
        return 0

    if target.is_dir():
        all_issues = scan_directory(target)
        total_issues = sum(len(file_issues) for _, file_issues in all_issues)
        return 1 if total_issues else 0

    print(f"Error: {target} is not a valid file or directory", file=sys.stderr)
    return 2


if __name__ == "__main__":
    sys.exit(main())

Operational errors should be represented separately from security findings rather than being returned as ordinary finding strings. Add subprocess-based regression tests that assert the expected exit status for:

  1. A clean Python file.
  2. A file containing a recognized dangerous pattern.
  3. A directory containing at least one flagged file.
  4. A nonexistent target.
  5. Missing command-line arguments.
  6. An unreadable or otherwise unscannable file.

The documented pre-commit and publication examples should then retain fail-closed handling and abort on every nonzero status.

Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (2)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding

The skill documentation references capabilities that imply reading files, making network requests, and invoking shell commands, but the skill metadata declares no explicit tool restrictions such as permissions or allowed-tools. In an agent ecosystem, missing scope declarations can cause the skill to run with broader ambient authority than intended, increasing the blast radius if the scanner is misused or extended unsafely.

Content

No source excerpt is available for this finding.

Unrestricted Tool Access

Medium
Category
Excessive Agency
Confidence
80% confidence
Finding

Skill grants unrestricted tool access without appropriate constraints. An agent with unfettered tool access can perform arbitrary actions including file modification, network requests, and code execution.

Content

Scanner excerpt · SKILL.md (reported line 47)May include surrounding context.

md
- `eval()` - Executes arbitrary code
- `exec()` - Executes arbitrary code

**Why dangerous?** These can execute arbitrary commands or code, leading to remote code execution vulnerabilities.

### Hardcoded Secrets
Detects tokens, keys, and passwords:

Static analysis

Detected: suspicious.exposed_secret_literal

File appears to expose a hardcoded API secret or token.

Critical
Code
suspicious.exposed_secret_literal
Location
SKILL.md:116