[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M76YB3YK03T1WGDQ2QHWKNA7":3,"skill-same:01M76YB3YK03T1WGDQ2QHWKNA7":61},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":38,"commitSha":39,"skillDirectory":40,"forksCount":41,"repositoryHtmlUrl":42,"repositoryHomepageUrl":43,"ownerHtmlUrl":44,"ownerBlogUrl":6,"ownerDescription":45,"updatedAt":46,"install":47,"resources":60},"01M76YB3YK03T1WGDQ2QHWKNA7","security-audit",null,"Audit codebases, infrastructure, AND agentic AI systems for security issues. Covers traditional security (dependencies, secrets, OWASP web top 10, SSL\u002FTLS, file permissions) PLUS agentic security (prompt injection scanning, identity spoofing detection, memory poisoning checks, multi-agent communication audit, OWASP Agentic Top 10). Use when scanning for vulnerabilities, detecting hardcoded secrets, reviewing agent workspace configuration, checking prompt injection vectors, or auditing agent permissions and boundaries.","Lord1Egypt\u002Fawesome-skill-forge","Lord1Egypt","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F99746359?v=4","01M7592YDNT0XK9WJ0T2MQVPDN","Mohamed Mounir Ali AL Keshita","01M75GRFNHC8VZNWEB8DKDE433",3,"MIT","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fclawhub\u002Fa\u002Fagentic-security-audit\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: security-audit\ndescription: Audit codebases, infrastructure, AND agentic AI systems for security issues. Covers traditional security (dependencies, secrets, OWASP web top 10, SSL\u002FTLS, file permissions) PLUS agentic security (prompt injection scanning, identity spoofing detection, memory poisoning checks, multi-agent communication audit, OWASP Agentic Top 10). Use when scanning for vulnerabilities, detecting hardcoded secrets, reviewing agent workspace configuration, checking prompt injection vectors, or auditing agent permissions and boundaries.\nmetadata: {\"clawdbot\":{\"emoji\":\"🔒\",\"requires\":{\"anyBins\":[\"npm\",\"pip\",\"git\",\"openssl\",\"curl\"]},\"os\":[\"linux\",\"darwin\",\"win32\"]}}\n---\n\n# Security Audit\n\nScan, detect, and fix security issues in codebases and infrastructure. Covers dependency vulnerabilities, secret detection, OWASP top 10, SSL\u002FTLS verification, file permissions, and secure coding patterns.\n\n## When to Use\n\n- Scanning project dependencies for known vulnerabilities\n- Detecting hardcoded secrets, API keys, or credentials in source code\n- Reviewing code for OWASP top 10 vulnerabilities (injection, XSS, CSRF, etc.)\n- Verifying SSL\u002FTLS configuration for endpoints\n- Auditing file and directory permissions\n- Checking authentication and authorization patterns\n- Preparing for a security review or compliance audit\n\n## Dependency Vulnerability Scanning\n\n### Node.js\n\n```bash\n# Built-in npm audit\nnpm audit\nnpm audit --json | jq '.vulnerabilities | to_entries[] | {name: .key, severity: .value.severity, via: .value.via[0]}'\n\n# Fix automatically where possible\nnpm audit fix\n\n# Show only high and critical\nnpm audit --audit-level=high\n\n# Check a specific package\nnpm audit --package-lock-only\n\n# Alternative: use npx to scan without installing\nnpx audit-ci --high\n```\n\n### Python\n\n```bash\n# pip-audit (recommended)\npip install pip-audit\npip-audit\npip-audit -r requirements.txt\npip-audit --format=json\n\n# safety (alternative)\npip install safety\nsafety check\nsafety check -r requirements.txt --json\n\n# Check a specific package\npip-audit --requirement=- \u003C\u003C\u003C \"requests==2.25.0\"\n```\n\n### Go\n\n```bash\n# Built-in vuln checker\ngo install golang.org\u002Fx\u002Fvuln\u002Fcmd\u002Fgovulncheck@latest\ngovulncheck .\u002F...\n\n# Check specific binary\ngovulncheck -mode=binary .\u002Fmyapp\n```\n\n### Rust\n\n```bash\n# cargo-audit\ncargo install cargo-audit\ncargo audit\n\n# With fix suggestions\ncargo audit fix\n```\n\n### Universal: Trivy (scans any project)\n\n```bash\n# Install: https:\u002F\u002Faquasecurity.github.io\u002Ftrivy\n# Scan filesystem\ntrivy fs .\n\n# Scan specific language\ntrivy fs --scanners vuln --severity HIGH,CRITICAL .\n\n# Scan Docker image\ntrivy image myapp:latest\n\n# JSON output\ntrivy fs --format json -o results.json .\n```\n\n## Secret Detection\n\n### Manual grep patterns\n\n```bash\n# AWS keys\ngrep -rn 'AKIA[0-9A-Z]\\{16\\}' --include='*.{js,ts,py,go,java,rb,env,yml,yaml,json,xml,cfg,conf,ini}' .\n\n# Generic API keys and tokens\ngrep -rn -i 'api[_-]\\?key\\|api[_-]\\?secret\\|access[_-]\\?token\\|auth[_-]\\?token\\|bearer ' \\\n  --include='*.{js,ts,py,go,java,rb,env,yml,yaml,json}' .\n\n# Private keys\ngrep -rn 'BEGIN.*PRIVATE KEY' .\n\n# Passwords in config\ngrep -rn -i 'password\\s*[:=]' --include='*.{env,yml,yaml,json,xml,cfg,conf,ini,toml}' .\n\n# Connection strings with credentials\ngrep -rn -i 'mongodb:\u002F\u002F\\|mysql:\u002F\u002F\\|postgres:\u002F\u002F\\|redis:\u002F\u002F' --include='*.{js,ts,py,go,env,yml,yaml,json}' . | grep -v 'localhost\\|127.0.0.1\\|example'\n\n# JWT tokens (three base64 segments separated by dots)\ngrep -rn 'eyJ[A-Za-z0-9_-]*\\.eyJ[A-Za-z0-9_-]*\\.' --include='*.{js,ts,py,go,log,json}' .\n```\n\n### Automated scanning with git\n\n```bash\n# Scan git history for secrets (not just current files)\n# Using git log + grep\ngit log -p --all | grep -n -i 'api.key\\|password\\|secret\\|token' | head -50\n\n# Check staged files before commit\ngit diff --cached --name-only | xargs grep -l -i 'api.key\\|password\\|secret\\|token' 2>\u002Fdev\u002Fnull\n```\n\n### Pre-commit hook for secrets\n\n```bash\n#!\u002Fbin\u002Fbash\n# .git\u002Fhooks\u002Fpre-commit - Block commits containing potential secrets\n\nPATTERNS=(\n    'AKIA[0-9A-Z]{16}'\n    'BEGIN.*PRIVATE KEY'\n    'password\\s*[:=]\\s*[\"\\x27][^\"\\x27]+'\n    'api[_-]?key\\s*[:=]\\s*[\"\\x27][^\"\\x27]+'\n    'sk-[A-Za-z0-9]{20,}'\n    'ghp_[A-Za-z0-9]{36}'\n    'xox[bpoas]-[A-Za-z0-9-]+'\n)\n\nSTAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM)\n[ -z \"$STAGED_FILES\" ] && exit 0\n\nEXIT_CODE=0\nfor pattern in \"${PATTERNS[@]}\"; do\n    matches=$(echo \"$STAGED_FILES\" | xargs grep -Pn \"$pattern\" 2>\u002Fdev\u002Fnull)\n    if [ -n \"$matches\" ]; then\n        echo \"BLOCKED: Potential secret detected matching pattern: $pattern\"\n        echo \"$matches\"\n        EXIT_CODE=1\n    fi\ndone\n\nif [ $EXIT_CODE -ne 0 ]; then\n    echo \"\"\n    echo \"To proceed anyway: git commit --no-verify\"\n    echo \"To remove secrets: replace with environment variables\"\nfi\nexit $EXIT_CODE\n```\n\n### .gitignore audit\n\n```bash\n# Check if sensitive files are tracked\necho \"--- Files that should probably be gitignored ---\"\nfor pattern in '.env' '.env.*' '*.pem' '*.key' '*.p12' '*.pfx' 'credentials.json' \\\n               'service-account*.json' '*.keystore' 'id_rsa' 'id_ed25519'; do\n    found=$(git ls-files \"$pattern\" 2>\u002Fdev\u002Fnull)\n    [ -n \"$found\" ] && echo \"  TRACKED: $found\"\ndone\n\n# Check if .gitignore exists and has common patterns\nif [ ! -f .gitignore ]; then\n    echo \"WARNING: No .gitignore file found\"\nelse\n    for entry in '.env' 'node_modules' '*.key' '*.pem'; do\n        grep -q \"$entry\" .gitignore || echo \"  MISSING from .gitignore: $entry\"\n    done\nfi\n```\n\n## OWASP Top 10 Code Patterns\n\n### 1. Injection (SQL, Command, LDAP)\n\n```bash\n# SQL injection: string concatenation in queries\ngrep -rn \"query\\|execute\\|cursor\" --include='*.{py,js,ts,go,java,rb}' . | \\\n  grep -i \"f\\\"\\|format(\\|%s\\|\\${\\|+ \\\"\\|concat\\|sprintf\" | \\\n  grep -iv \"parameterized\\|placeholder\\|prepared\"\n\n# Command injection: user input in shell commands\ngrep -rn \"exec(\\|spawn(\\|system(\\|popen(\\|subprocess\\|os\\.system\\|child_process\" \\\n  --include='*.{py,js,ts,go,java,rb}' .\n\n# Check for parameterized queries (good)\ngrep -rn \"\\\\$[0-9]\\|\\\\?\\|%s\\|:param\\|@param\\|prepared\" --include='*.{py,js,ts,go,java,rb}' .\n```\n\n### 2. Broken Authentication\n\n```bash\n# Weak password hashing (MD5, SHA1 used for passwords)\ngrep -rn \"md5\\|sha1\\|sha256\" --include='*.{py,js,ts,go,java,rb}' . | grep -i \"password\\|passwd\"\n\n# Hardcoded credentials\ngrep -rn -i \"admin.*password\\|password.*admin\\|default.*password\" \\\n  --include='*.{py,js,ts,go,java,rb,yml,yaml,json}' .\n\n# Session tokens in URLs\ngrep -rn \"session\\|token\\|jwt\" --include='*.{py,js,ts,go,java,rb}' . | grep -i \"url\\|query\\|param\\|GET\"\n\n# Check for rate limiting on auth endpoints\ngrep -rn -i \"rate.limit\\|throttle\\|brute\" --include='*.{py,js,ts,go,java,rb}' .\n```\n\n### 3. Cross-Site Scripting (XSS)\n\n```bash\n# Unescaped output in templates\ngrep -rn \"innerHTML\\|dangerouslySetInnerHTML\\|v-html\\|\\|html(\" \\\n  --include='*.{js,ts,jsx,tsx,vue,html}' .\n\n# Template injection\ngrep -rn \"{{{.*}}}\\|\u003C%=\\|\u003C%-\\|\\$\\!{\" --include='*.{html,ejs,hbs,pug,erb}' .\n\n# Document.write\ngrep -rn \"document\\.write\\|document\\.writeln\" --include='*.{js,ts,html}' .\n\n# eval with user input\ngrep -rn \"eval(\\|new Function(\\|setTimeout.*string\\|setInterval.*string\" \\\n  --include='*.{js,ts}' .\n```\n\n### 4. Insecure Direct Object References\n\n```bash\n# Direct ID usage in routes without authz check\ngrep -rn \"params\\.id\\|params\\[.id.\\]\\|req\\.params\\.\\|request\\.args\\.\\|request\\.GET\\.\" \\\n  --include='*.{py,js,ts,go,java,rb}' . | \\\n  grep -i \"user\\|account\\|profile\\|order\\|document\"\n```\n\n### 5. Security Misconfiguration\n\n```bash\n# CORS wildcard\ngrep -rn \"Access-Control-Allow-Origin.*\\*\\|cors({.*origin.*true\\|cors()\" \\\n  --include='*.{py,js,ts,go,java,rb}' .\n\n# Debug mode in production configs\ngrep -rn \"DEBUG\\s*=\\s*True\\|debug:\\s*true\\|NODE_ENV.*development\" \\\n  --include='*.{py,js,ts,yml,yaml,json,env}' .\n\n# Verbose error messages exposed to clients\ngrep -rn \"stack\\|traceback\\|stackTrace\" --include='*.{py,js,ts,go,java,rb}' . | \\\n  grep -i \"response\\|send\\|return\\|res\\.\"\n```\n\n## SSL\u002FTLS Verification\n\n### Check endpoint SSL\n\n```bash\n# Full SSL check\nopenssl s_client -connect example.com:443 -servername example.com \u003C \u002Fdev\u002Fnull 2>\u002Fdev\u002Fnull | \\\n  openssl x509 -noout -subject -issuer -dates -fingerprint\n\n# Check certificate expiry\necho | openssl s_client -connect example.com:443 -servername example.com 2>\u002Fdev\u002Fnull | \\\n  openssl x509 -noout -enddate\n\n# Check supported TLS versions\nfor v in tls1 tls1_1 tls1_2 tls1_3; do\n  result=$(openssl s_client -connect example.com:443 -$v \u003C \u002Fdev\u002Fnull 2>&1)\n  if echo \"$result\" | grep -q \"Cipher is\"; then\n    echo \"$v: SUPPORTED\"\n  else\n    echo \"$v: NOT SUPPORTED\"\n  fi\ndone\n\n# Check cipher suites\nopenssl s_client -connect example.com:443 -cipher 'ALL' \u003C \u002Fdev\u002Fnull 2>&1 | \\\n  grep \"Cipher    :\"\n\n# Check for weak ciphers\nopenssl s_client -connect example.com:443 -cipher 'NULL:EXPORT:DES:RC4:MD5' \u003C \u002Fdev\u002Fnull 2>&1 | \\\n  grep \"Cipher    :\"\n```\n\n### Verify certificate chain\n\n```bash\n# Download and verify full chain\nopenssl s_client -connect example.com:443 -showcerts \u003C \u002Fdev\u002Fnull 2>\u002Fdev\u002Fnull | \\\n  awk '\u002FBEGIN CERTIFICATE\u002F,\u002FEND CERTIFICATE\u002F{print}' > chain.pem\n\n# Verify chain\nopenssl verify -CAfile \u002Fetc\u002Fssl\u002Fcerts\u002Fca-certificates.crt chain.pem\n\n# Check certificate details\nopenssl x509 -in chain.pem -noout -text | grep -A2 \"Subject:\\|Issuer:\\|Not Before\\|Not After\\|DNS:\"\n```\n\n### Check SSL from code\n\n```bash\n# Verify SSL isn't disabled in code\ngrep -rn \"verify\\s*=\\s*False\\|rejectUnauthorized.*false\\|InsecureSkipVerify.*true\\|CURLOPT_SSL_VERIFYPEER.*false\\|NODE_TLS_REJECT_UNAUTHORIZED.*0\" \\\n  --include='*.{py,js,ts,go,java,rb,yml,yaml}' .\n```\n\n## File Permission Audit\n\n```bash\n# Find world-writable files\nfind . -type f -perm -o=w -not -path '*\u002Fnode_modules\u002F*' -not -path '*\u002F.git\u002F*' 2>\u002Fdev\u002Fnull\n\n# Find executable files that shouldn't be\nfind . -type f -perm -u=x -not -name '*.sh' -not -name '*.py' -not -path '*\u002Fnode_modules\u002F*' \\\n  -not -path '*\u002F.git\u002F*' -not -path '*\u002Fbin\u002F*' 2>\u002Fdev\u002Fnull\n\n# Check sensitive file permissions\nfor f in .env .env.* *.pem *.key *.p12 id_rsa id_ed25519; do\n    [ -f \"$f\" ] && ls -la \"$f\"\ndone\n\n# Find files with SUID\u002FSGID bits (Linux)\nfind \u002F -type f \\( -perm -4000 -o -perm -2000 \\) 2>\u002Fdev\u002Fnull | head -20\n\n# Check SSH key permissions\nif [ -d ~\u002F.ssh ]; then\n    echo \"--- SSH directory permissions ---\"\n    ls -la ~\u002F.ssh\u002F\n    echo \"\"\n    # Should be: dir=700, private keys=600, public keys=644, config=600\n    [ \"$(stat -c %a ~\u002F.ssh 2>\u002Fdev\u002Fnull || stat -f %Lp ~\u002F.ssh)\" != \"700\" ] && echo \"WARNING: ~\u002F.ssh should be 700\"\nfi\n```\n\n## Full Project Security Audit Script\n\n```bash\n#!\u002Fbin\u002Fbash\n# security-audit.sh - Run a comprehensive security check on a project\nset -euo pipefail\n\nPROJECT_DIR=\"${1:-.}\"\ncd \"$PROJECT_DIR\"\n\necho \"=========================================\"\necho \"Security Audit: $(basename \"$(pwd)\")\"\necho \"Date: $(date -u '+%Y-%m-%dT%H:%M:%SZ')\"\necho \"=========================================\"\necho \"\"\n\nISSUES=0\nwarn() { echo \"  [!] $1\"; ((ISSUES++)); }\nok() { echo \"  [OK] $1\"; }\nsection() { echo \"\"; echo \"--- $1 ---\"; }\n\n# 1. Secrets detection\nsection \"Secret Detection\"\nfor pattern in 'AKIA[0-9A-Z]\\{16\\}' 'BEGIN.*PRIVATE KEY' 'sk-[A-Za-z0-9]\\{20,\\}' \\\n               'ghp_[A-Za-z0-9]\\{36\\}' 'xox[bpoas]-'; do\n    count=$(grep -rn \"$pattern\" --include='*.{js,ts,py,go,java,rb,env,yml,yaml,json,xml}' . 2>\u002Fdev\u002Fnull | \\\n            grep -v 'node_modules\\|\\.git\\|vendor\\|__pycache__' | wc -l)\n    if [ \"$count\" -gt 0 ]; then\n        warn \"Found $count matches for pattern: $pattern\"\n    fi\ndone\ngrep -rn -i 'password\\s*[:=]\\s*[\"'\"'\"'][^\"'\"'\"']*[\"'\"'\"']' \\\n  --include='*.{js,ts,py,go,yml,yaml,json,env}' . 2>\u002Fdev\u002Fnull | \\\n  grep -v 'node_modules\\|\\.git\\|example\\|test\\|mock\\|placeholder\\|changeme\\|xxxx' | \\\n  while read -r line; do warn \"Hardcoded password: $line\"; done\n\n# 2. Dependency audit\nsection \"Dependency Vulnerabilities\"\nif [ -f package-lock.json ] || [ -f package.json ]; then\n    npm audit --audit-level=high 2>\u002Fdev\u002Fnull && ok \"npm: no high\u002Fcritical vulns\" || warn \"npm audit found issues\"\nfi\nif [ -f requirements.txt ]; then\n    pip-audit -r requirements.txt 2>\u002Fdev\u002Fnull && ok \"pip: no known vulns\" || warn \"pip-audit found issues\"\nfi\nif [ -f go.sum ]; then\n    govulncheck .\u002F... 2>\u002Fdev\u002Fnull && ok \"Go: no known vulns\" || warn \"govulncheck found issues\"\nfi\n\n# 3. Gitignore check\nsection \".gitignore Coverage\"\nif [ ! -f .gitignore ]; then\n    warn \"No .gitignore file\"\nelse\n    for entry in '.env' 'node_modules' '*.key' '*.pem' '.DS_Store'; do\n        grep -q \"$entry\" .gitignore 2>\u002Fdev\u002Fnull && ok \".gitignore has $entry\" || warn \".gitignore missing: $entry\"\n    done\nfi\n\n# 4. SSL verification disabled\nsection \"SSL Verification\"\ndisabled=$(grep -rn \"verify\\s*=\\s*False\\|rejectUnauthorized.*false\\|InsecureSkipVerify.*true\" \\\n  --include='*.{py,js,ts,go,java,rb}' . 2>\u002Fdev\u002Fnull | \\\n  grep -v 'node_modules\\|\\.git\\|test\\|spec\\|mock' | wc -l)\n[ \"$disabled\" -gt 0 ] && warn \"SSL verification disabled in $disabled location(s)\" || ok \"No SSL bypasses found\"\n\n# 5. CORS wildcard\nsection \"CORS Configuration\"\ncors=$(grep -rn \"Access-Control-Allow-Origin.*\\*\\|cors({.*origin.*true\" \\\n  --include='*.{py,js,ts,go,java,rb}' . 2>\u002Fdev\u002Fnull | \\\n  grep -v 'node_modules\\|\\.git' | wc -l)\n[ \"$cors\" -gt 0 ] && warn \"CORS wildcard found in $cors location(s)\" || ok \"No CORS wildcard\"\n\n# 6. Debug mode\nsection \"Debug\u002FDevelopment Settings\"\ndebug=$(grep -rn \"DEBUG\\s*=\\s*True\\|debug:\\s*true\" \\\n  --include='*.{py,yml,yaml,json}' . 2>\u002Fdev\u002Fnull | \\\n  grep -v 'node_modules\\|\\.git\\|test\\|jest\\|vitest' | wc -l)\n[ \"$debug\" -gt 0 ] && warn \"Debug mode enabled in $debug location(s)\" || ok \"No debug flags found\"\n\necho \"\"\necho \"=========================================\"\necho \"Audit complete. Issues found: $ISSUES\"\necho \"=========================================\"\n[ \"$ISSUES\" -eq 0 ] && exit 0 || exit 1\n```\n\n## Secure Coding Quick Reference\n\n### Environment variables instead of hardcoded secrets\n\n```bash\n# Bad: hardcoded in source\nAPI_KEY=\"sk-abc123...\"\n\n# Good: from environment\nAPI_KEY=\"${API_KEY:?Error: API_KEY not set}\"\n\n# Good: from .env file (loaded at startup, never committed)\n# .env\nAPI_KEY=sk-abc123...\n# .gitignore\n.env\n```\n\n### Input validation checklist\n\n```\n- [ ] All user input validated (type, length, format)\n- [ ] SQL queries use parameterized statements (never string concat)\n- [ ] Shell commands never include user input directly\n- [ ] File paths validated (no path traversal: ..\u002F)\n- [ ] URLs validated (no SSRF: restrict to expected domains)\n- [ ] HTML output escaped (no XSS: use framework auto-escaping)\n- [ ] JSON parsing has error handling (no crash on malformed input)\n- [ ] File uploads checked (type, size, no executable content)\n```\n\n### HTTP security headers\n\n```bash\n# Check security headers on a URL\ncurl -sI https:\u002F\u002Fexample.com | grep -i 'strict-transport\\|content-security\\|x-frame\\|x-content-type\\|referrer-policy\\|permissions-policy'\n\n# Expected headers:\n# Strict-Transport-Security: max-age=31536000; includeSubDomains\n# Content-Security-Policy: default-src 'self'\n# X-Frame-Options: DENY\n# X-Content-Type-Options: nosniff\n# Referrer-Policy: strict-origin-when-cross-origin\n# Permissions-Policy: camera=(), microphone=(), geolocation=()\n```\n\n## Tips\n\n- Run `npm audit` \u002F `pip-audit` \u002F `govulncheck` in CI on every pull request, not just occasionally.\n- Secret detection in git history matters: even if a secret is removed from HEAD, it exists in git history. Use `git filter-branch` or `git-filter-repo` to purge, then rotate the credential.\n- The most dangerous vulnerabilities are often the simplest: SQL injection via string concatenation, command injection via unsanitized input, XSS via `innerHTML`.\n- CORS `Access-Control-Allow-Origin: *` is safe for truly public, read-only APIs. It's dangerous for anything that uses cookies or auth tokens.\n- Always verify SSL in production. `verify=False` or `rejectUnauthorized: false` should only appear in test code, never in production paths.\n- Defense in depth: validate input, escape output, use parameterized queries, enforce least privilege, and assume every layer might be bypassed.\n\n---\n\n## 🤖 Agentic Security Audit (Bổ sung 25\u002F02\u002F2026)\n\n> *Từ paper \"Agents of Chaos\" (arXiv:2602.20021) + OWASP Top 10 for Agentic Applications 2026.*\n> *Traditional security audit chỉ cover code\u002Finfra. Agentic systems có attack surface hoàn toàn mới.*\n\n### When to Use (Agentic)\n\n- Auditing OpenClaw\u002Fagent workspace configuration\n- Reviewing agent permissions and access boundaries\n- Scanning for prompt injection vectors in agent-facing content\n- Assessing multi-agent communication security\n- Evaluating identity verification mechanisms\n- Checking persistent memory for poisoning\n\n### OWASP Agentic Top 10 Checklist (2026)\n\n```\n- [ ] ASI01: Agent Goal Hijack (prompt injection — direct & indirect)\n- [ ] ASI02: Tool Misuse and Exploitation (shell, filesystem, API abuse)\n- [ ] ASI03: Identity and Privilege Abuse (confused deputy, over-privilege)\n- [ ] ASI04: Memory Poisoning (SOUL.md, MEMORY.md, persistent context)\n- [ ] ASI05: Supply Chain Attacks (malicious skills\u002Fplugins — e.g., ClawHub)\n- [ ] ASI06: Rogue Agents (operating outside intended boundaries)\n- [ ] ASI07: Data Leakage via Agentic Channels (cross-channel PII exposure)\n- [ ] ASI08: Orchestration Manipulation (sub-agent hijacking)\n- [ ] ASI09: Insufficient Logging and Observability\n- [ ] ASI10: Insecure Agent Communication (agent-to-agent trust)\n```\n\n### 1. Workspace Configuration Audit\n\n```bash\n# Check if agent config files are world-readable\necho \"--- Agent Config Permissions ---\"\nfor f in SOUL.md MEMORY.md AGENTS.md TOOLS.md IDENTITY.md USER.md HEARTBEAT.md; do\n    [ -f \"$f\" ] && echo \"$(stat -f '%Sp %N' \"$f\" 2>\u002Fdev\u002Fnull || stat -c '%A %n' \"$f\")\" || echo \"  NOT FOUND: $f\"\ndone\n\n# Check for secrets leaked into agent memory\u002Fconfig\necho \"--- Secrets in Agent Files ---\"\ngrep -rn -i 'api.key\\|password\\|token\\|secret\\|bearer' \\\n  SOUL.md MEMORY.md TOOLS.md IDENTITY.md USER.md memory\u002F*.md 2>\u002Fdev\u002Fnull | \\\n  grep -v 'example\\|placeholder\\|REDACTED'\n\n# Check for over-permissive shell access\necho \"--- Shell Access Check ---\"\ngrep -rn -i 'sudo\\|chmod 777\\|unrestricted' AGENTS.md TOOLS.md 2>\u002Fdev\u002Fnull\n```\n\n### 2. Prompt Injection Scan (Agent-Facing Content)\n\n```bash\n# Scan content that agents read\u002Fprocess for injection patterns\nSCAN_DIRS=\"${1:-.}\"\n\necho \"--- Prompt Injection Patterns ---\"\nINJECTION_PATTERNS=(\n    'ignore\\s+(previous|all|above)\\s+instructions'\n    'you\\s+are\\s+now\\s+'\n    'new\\s+system\\s+prompt'\n    '\\[SYSTEM\\]'\n    '\u003CSYSTEM_ADMIN_OVERRIDE>'\n    'AUTHORIZED_OVERRIDE'\n    'forget\\s+your\\s+(rules|instructions|guidelines)'\n    'act\\s+as\\s+if\\s+you\\s+are'\n    'disregard\\s+(all|your|previous)'\n    'jailbreak'\n    'DAN\\s+mode'\n)\n\nfor pattern in \"${INJECTION_PATTERNS[@]}\"; do\n    matches=$(grep -rn -iP \"$pattern\" \"$SCAN_DIRS\" \\\n      --include='*.{md,txt,json,html,yml,yaml}' 2>\u002Fdev\u002Fnull | \\\n      grep -v 'node_modules\\|\\.git\\|SKILL.md' | head -5)\n    [ -n \"$matches\" ] && echo \"  [!] Injection pattern '$pattern':\" && echo \"$matches\"\ndone\n\n# Steganographic: zero-width Unicode characters\necho \"--- Zero-Width Unicode Characters ---\"\ngrep -rPn '[\\x{200B}\\x{200C}\\x{200D}\\x{FEFF}\\x{00AD}\\x{2060}]' \"$SCAN_DIRS\" \\\n  --include='*.{md,txt,json,html}' 2>\u002Fdev\u002Fnull | head -10\n\n# Suspicious base64 strings (>50 chars, could be encoded payloads)\necho \"--- Suspicious Base64 Strings ---\"\ngrep -rPn '[A-Za-z0-9+\u002F=]{50,}' \"$SCAN_DIRS\" \\\n  --include='*.{md,txt,json}' 2>\u002Fdev\u002Fnull | \\\n  grep -v 'node_modules\\|\\.git\\|\\.png\\|\\.jpg\\|package-lock' | head -10\n```\n\n### 3. Identity & Authorization Audit\n\n```bash\n# Check if agent verifies owner identity beyond display name\necho \"--- Identity Verification ---\"\n\n# OpenClaw: check if authorized senders are configured\ngrep -n 'authorizedSenders\\|authorized_senders\\|allowlist' \\\n  ~\u002F.config\u002Fopenclaw\u002Fconfig.yaml ~\u002F.openclaw\u002Fconfig.* 2>\u002Fdev\u002Fnull\n\n# Check if agent trusts display names (vulnerable to spoofing)\ngrep -rn -i 'display.name\\|username\\|sender.name' \\\n  AGENTS.md SOUL.md TOOLS.md 2>\u002Fdev\u002Fnull | \\\n  grep -iv 'user.id\\|sender.id\\|verified'\n\n# Check for cross-channel trust assumptions\necho \"--- Cross-Channel Trust ---\"\ngrep -rn -i 'if.*channel\\|trust.*channel\\|verify.*channel' \\\n  AGENTS.md SOUL.md 2>\u002Fdev\u002Fnull\n```\n\n### 4. Memory Poisoning Check\n\n```bash\n# Check memory files for suspicious patterns\necho \"--- Memory Integrity ---\"\n\n# External URLs stored as \"governing documents\" (Case #10: Agent Corruption)\necho \"URLs in memory that agent may follow as instructions:\"\ngrep -rn 'https\\?:\u002F\u002F\\|gist\\.github\\|pastebin\\|hastebin' \\\n  MEMORY.md memory\u002F*.md HEARTBEAT.md 2>\u002Fdev\u002Fnull\n\n# Check if memory files were recently modified by non-owner actions\necho \"Recent memory file changes:\"\nfind memory\u002F MEMORY.md SOUL.md AGENTS.md -newer IDENTITY.md -type f 2>\u002Fdev\u002Fnull | \\\n  while read f; do echo \"  $(stat -f '%Sm %N' \"$f\" 2>\u002Fdev\u002Fnull || stat -c '%y %n' \"$f\")\"; done\n\n# Check for instructions in memory that override safety rules\ngrep -rn -i 'override\\|bypass\\|ignore.*rule\\|disable.*safety\\|skip.*check' \\\n  MEMORY.md memory\u002F*.md HEARTBEAT.md 2>\u002Fdev\u002Fnull\n\n# Check git blame for who modified critical files\necho \"--- SOUL.md modification history ---\"\ngit log --oneline -10 -- SOUL.md 2>\u002Fdev\u002Fnull || echo \"  (not in git)\"\necho \"--- AGENTS.md modification history ---\"\ngit log --oneline -10 -- AGENTS.md 2>\u002Fdev\u002Fnull || echo \"  (not in git)\"\n```\n\n### 5. Multi-Agent Communication Audit\n\n```bash\n# Check for agent-to-agent trust without verification\necho \"--- Multi-Agent Trust ---\"\n\n# Shared channels where agents interact (Discord, forum, email)\ngrep -rn -i 'discord\\|forum\\|moltbook\\|clawstr\\|email.*agent' \\\n  TOOLS.md MEMORY.md memory\u002F*.md 2>\u002Fdev\u002Fnull\n\n# Check if agent auto-executes actions from other agents\ngrep -rn -i 'webhook\\|auto.reply\\|auto.respond\\|on.*mention' \\\n  AGENTS.md HEARTBEAT.md TOOLS.md scripts\u002F*.sh 2>\u002Fdev\u002Fnull\n\n# Check for infinite loop risks (agent A ↔ agent B relay)\ngrep -rn -i 'relay\\|forward.*message\\|pass.*along\\|tell.*agent' \\\n  MEMORY.md memory\u002F*.md 2>\u002Fdev\u002Fnull\n\n# Check cron\u002Fheartbeat for tasks triggered by external content\necho \"--- Scheduled Tasks ---\"\ngrep -rn -i 'check.*forum\\|check.*moltbook\\|reply.*comment\\|respond.*mention' \\\n  HEARTBEAT.md 2>\u002Fdev\u002Fnull\n```\n\n### 6. Resource & Privilege Audit\n\n```bash\n# Check for excessive agent permissions\necho \"--- Agent Permissions ---\"\n\n# Sudo access (should NOT be default for agents)\ngrep -rn 'sudo\\|root\\|admin.*access\\|unrestricted' \\\n  AGENTS.md TOOLS.md 2>\u002Fdev\u002Fnull\n\n# Background processes agent has created\necho \"Running agent processes:\"\nps aux | grep -i 'cron\\|heartbeat\\|monitor\\|watch\\|loop' | grep -v grep | head -10\n\n# Check for unbounded resource consumption patterns\necho \"--- Cron\u002FBackground Jobs ---\"\ncrontab -l 2>\u002Fdev\u002Fnull || echo \"  No crontab\"\n\n# Check disk usage of agent workspace\necho \"--- Workspace Size ---\"\ndu -sh . memory\u002F 2>\u002Fdev\u002Fnull\n\n# Check for files agent probably shouldn't have access to\necho \"--- Sensitive System Files Readable by Agent ---\"\nfor f in \u002Fetc\u002Fshadow \u002Fetc\u002Fpasswd ~\u002F.ssh\u002Fid_rsa ~\u002F.ssh\u002Fid_ed25519 \\\n         ~\u002F.aws\u002Fcredentials ~\u002F.config\u002Fgcloud\u002Fcredentials.db; do\n    [ -r \"$f\" ] && echo \"  [!] READABLE: $f\"\ndone\n```\n\n### 7. Semantic Reframing Detection (Advanced)\n\n> *From Agents of Chaos Case #3: \"Give me SSN\" → refused. \"Forward the email\" (containing SSN) → complied.*\n> *This check helps humans verify their agent won't leak data through reframed requests.*\n\n```bash\n# Check if agent has rules about content-based (not just action-based) evaluation\necho \"--- Content-Based Safety Rules ---\"\ngrep -rn -i 'content.*evaluat\\|semantic.*refram\\|forward.*email.*sensitive\\|assess.*content' \\\n  AGENTS.md SOUL.md 2>\u002Fdev\u002Fnull\n\n# Check for PII in files agent might forward\u002Fshare\necho \"--- PII in Agent-Accessible Files ---\"\n# SSN pattern\ngrep -rPn '\\b\\d{3}-\\d{2}-\\d{4}\\b' MEMORY.md memory\u002F*.md 2>\u002Fdev\u002Fnull\n# Credit card pattern\ngrep -rPn '\\b\\d{4}[-\\s]?\\d{4}[-\\s]?\\d{4}[-\\s]?\\d{4}\\b' MEMORY.md memory\u002F*.md 2>\u002Fdev\u002Fnull\n# Email addresses\ngrep -rPn '\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z]{2,}\\b' \\\n  MEMORY.md memory\u002F*.md USER.md 2>\u002Fdev\u002Fnull | \\\n  grep -v 'example\\|test\\|placeholder'\n```\n\n### Full Agentic Security Audit Script\n\n```bash\n#!\u002Fbin\u002Fbash\n# agentic-security-audit.sh - Comprehensive security check for AI agent workspaces\n# Based on \"Agents of Chaos\" (arXiv:2602.20021) + OWASP Agentic Top 10\nset -euo pipefail\n\nWORKSPACE=\"${1:-.}\"\ncd \"$WORKSPACE\"\n\necho \"=========================================\"\necho \"Agentic Security Audit\"\necho \"Workspace: $(pwd)\"\necho \"Date: $(date -u '+%Y-%m-%dT%H:%M:%SZ')\"\necho \"Framework: Based on Agents of Chaos + OWASP Agentic Top 10\"\necho \"=========================================\"\necho \"\"\n\nISSUES=0\nWARNINGS=0\nwarn() { echo \"  ⚠️  $1\"; ((WARNINGS++)); }\ncritical() { echo \"  🔴 $1\"; ((ISSUES++)); }\nok() { echo \"  ✅ $1\"; }\nsection() { echo \"\"; echo \"=== $1 ===\"; }\n\n# --- ASI01: Prompt Injection ---\nsection \"ASI01: Prompt Injection Vectors\"\ninjection_count=0\nfor pattern in 'ignore.*previous.*instructions' 'you are now' 'new system prompt' \\\n               '\\[SYSTEM\\]' 'SYSTEM_ADMIN_OVERRIDE' 'forget your' 'act as if'; do\n    count=$(grep -rin \"$pattern\" --include='*.md' --include='*.txt' --include='*.json' . 2>\u002Fdev\u002Fnull | \\\n            grep -v 'SKILL.md\\|security-audit\\|node_modules\\|\\.git' | wc -l | tr -d ' ')\n    injection_count=$((injection_count + count))\ndone\n[ \"$injection_count\" -gt 0 ] && critical \"Found $injection_count prompt injection patterns in workspace\" || ok \"No injection patterns found\"\n\n# Zero-width Unicode\nzw_count=$(grep -rPc '[\\x{200B}\\x{200C}\\x{200D}\\x{FEFF}]' --include='*.md' . 2>\u002Fdev\u002Fnull | \\\n           awk -F: '{s+=$2}END{print s+0}')\n[ \"$zw_count\" -gt 0 ] && critical \"Found $zw_count zero-width Unicode chars (possible steganographic injection)\" || ok \"No hidden Unicode\"\n\n# --- ASI02: Tool Misuse ---\nsection \"ASI02: Tool Permissions\"\ngrep -rn 'sudo\\|chmod 777\\|unrestricted.*shell\\|full.*access' AGENTS.md TOOLS.md 2>\u002Fdev\u002Fnull && \\\n  critical \"Over-permissive access configured\" || ok \"No sudo\u002Funrestricted access\"\n\n# --- ASI03: Identity & Privilege ---\nsection \"ASI03: Identity Verification\"\nif grep -q 'authorizedSenders\\|Authorized Senders\\|Telegram.*ID' AGENTS.md 2>\u002Fdev\u002Fnull; then\n    ok \"Authorized sender verification configured\"\nelse\n    critical \"No authorized sender verification found — vulnerable to non-owner compliance\"\nfi\n\n# Anti-spoofing rules\nif grep -qi 'display.name.*identity\\|verify.*identity\\|spoofing\\|user.*ID.*verify' AGENTS.md 2>\u002Fdev\u002Fnull; then\n    ok \"Identity spoofing awareness in config\"\nelse\n    warn \"No anti-spoofing rules — vulnerable to Case #8 Identity Hijack\"\nfi\n\n# --- ASI04: Memory Poisoning ---\nsection \"ASI04: Memory Integrity\"\next_urls=$(grep -rn 'https\\?:\u002F\u002F.*gist\\|https\\?:\u002F\u002F.*pastebin\\|https\\?:\u002F\u002F.*hastebin' \\\n  MEMORY.md memory\u002F*.md HEARTBEAT.md 2>\u002Fdev\u002Fnull | wc -l | tr -d ' ')\n[ \"$ext_urls\" -gt 0 ] && warn \"Found $ext_urls external URLs in memory files (Case #10 risk: external governing documents)\" || ok \"No suspicious external URLs in memory\"\n\noverride_count=$(grep -rin 'override\\|bypass.*safety\\|disable.*check\\|ignore.*rule' \\\n  MEMORY.md memory\u002F*.md HEARTBEAT.md 2>\u002Fdev\u002Fnull | wc -l | tr -d ' ')\n[ \"$override_count\" -gt 0 ] && critical \"Found $override_count override\u002Fbypass instructions in memory\" || ok \"No override patterns in memory\"\n\n# --- ASI05: Supply Chain ---\nsection \"ASI05: Supply Chain (Skills\u002FPlugins)\"\nif [ -d skills ] || [ -d .openclaw\u002Fskills ]; then\n    skill_count=$(find skills .openclaw\u002Fskills -name 'SKILL.md' 2>\u002Fdev\u002Fnull | wc -l | tr -d ' ')\n    echo \"  Found $skill_count installed skills\"\n    # Check for skills with shell access\n    grep -rn 'exec\\|shell\\|subprocess\\|child_process' skills\u002F*\u002FSKILL.md .openclaw\u002Fskills\u002F*\u002FSKILL.md 2>\u002Fdev\u002Fnull && \\\n      warn \"Skills with shell execution capabilities found\" || ok \"No shell-executing skills\"\nfi\n\n# --- ASI07: Data Leakage ---\nsection \"ASI07: Sensitive Data Exposure\"\n# Secrets in agent files\nsecret_count=$(grep -rin 'api.key\\s*[:=]\\|password\\s*[:=]\\|token\\s*[:=]\\|bearer\\s' \\\n  SOUL.md MEMORY.md TOOLS.md USER.md memory\u002F*.md 2>\u002Fdev\u002Fnull | \\\n  grep -v 'example\\|placeholder\\|REDACTED\\|xxx\\|changeme\\|SKILL.md' | wc -l | tr -d ' ')\n[ \"$secret_count\" -gt 0 ] && critical \"Found $secret_count potential secrets in agent files\" || ok \"No exposed secrets\"\n\n# PII patterns\npii_count=0\nssn=$(grep -rPc '\\b\\d{3}-\\d{2}-\\d{4}\\b' MEMORY.md memory\u002F*.md USER.md 2>\u002Fdev\u002Fnull | awk -F: '{s+=$2}END{print s+0}')\npii_count=$((pii_count + ssn))\ncc=$(grep -rPc '\\b\\d{4}[-\\s]?\\d{4}[-\\s]?\\d{4}[-\\s]?\\d{4}\\b' MEMORY.md memory\u002F*.md 2>\u002Fdev\u002Fnull | awk -F: '{s+=$2}END{print s+0}')\npii_count=$((pii_count + cc))\n[ \"$pii_count\" -gt 0 ] && warn \"Found $pii_count PII patterns (SSN\u002Fcredit card) in agent files\" || ok \"No PII patterns\"\n\n# --- ASI06: Boundary Rules ---\nsection \"ASI06: Agent Boundary Rules\"\nif grep -qi 'non-owner\\|non.owner.*refuse\\|only.*owner\\|forum.*only.*discuss\\|chỉ.*thảo luận' AGENTS.md 2>\u002Fdev\u002Fnull; then\n    ok \"Non-owner boundary rules configured\"\nelse\n    warn \"No non-owner boundary rules — vulnerable to Case #2 non-owner compliance\"\nfi\n\nif grep -qi 'nhượng bộ\\|concession.*limit\\|escalat.*stop\\|gaslighting\\|pressure.*limit' AGENTS.md 2>\u002Fdev\u002Fnull; then\n    ok \"Anti-gaslighting\u002Fescalation rules present\"\nelse\n    warn \"No anti-gaslighting rules — vulnerable to Case #7\"\nfi\n\n# --- ASI10: Multi-Agent Communication ---\nsection \"ASI10: Multi-Agent Communication\"\nagent_channels=$(grep -rin 'discord\\|forum\\|moltbook\\|clawstr\\|webhook' \\\n  TOOLS.md MEMORY.md HEARTBEAT.md 2>\u002Fdev\u002Fnull | wc -l | tr -d ' ')\necho \"  Agent communicates via $agent_channels external channel references\"\n[ \"$agent_channels\" -gt 5 ] && warn \"Many external channels — larger attack surface\" || ok \"Moderate channel exposure\"\n\n# --- Summary ---\necho \"\"\necho \"=========================================\"\necho \"Audit complete\"\necho \"  🔴 Critical issues: $ISSUES\"\necho \"  ⚠️  Warnings: $WARNINGS\"\necho \"=========================================\"\n\nif [ \"$ISSUES\" -gt 0 ]; then\n    echo \"\"\n    echo \"Recommended actions:\"\n    echo \"  1. Fix all critical issues before exposing agent to external interactions\"\n    echo \"  2. Review AGENTS.md for Anti-Chaos Defense Rules\"\n    echo \"  3. Reference: Agents of Chaos (arXiv:2602.20021)\"\n    echo \"  4. Reference: OWASP Top 10 for Agentic Applications 2026\"\n    exit 1\nfi\nexit 0\n```\n\n### References\n\n- [Agents of Chaos — arXiv:2602.20021](https:\u002F\u002Farxiv.org\u002Fabs\u002F2602.20021) — Live red-teaming of OpenClaw agents\n- [OWASP Top 10 for Agentic Applications 2026](https:\u002F\u002Fgenai.owasp.org\u002Fresource\u002Fowasp-top-10-for-agentic-applications-for-2026\u002F)\n- [NIST AI Agent Standards Initiative](https:\u002F\u002Fwww.nist.gov\u002Fcaisi\u002Fai-agent-standards-initiative)\n- [OpenClaw Security Crisis — Conscia](https:\u002F\u002Fconscia.com\u002Fblog\u002Fthe-openclaw-security-crisis\u002F)\n","# Security Audit\n\nScan, detect, and fix security issues in codebases and infrastructure. Covers dependency vulnerabilities, secret detection, OWASP top 10, SSL\u002FTLS verification, file permissions, and secure coding patterns.\n\n## When to Use\n\n- Scanning project dependencies for known vulnerabilities\n- Detecting hardcoded secrets, API keys, or credentials in source code\n- Reviewing code for OWASP top 10 vulnerabilities (injection, XSS, CSRF, etc.)\n- Verifying SSL\u002FTLS configuration for endpoints\n- Auditing file and directory permissions\n- Checking authentication and authorization patterns\n- Preparing for a security review or compliance audit\n\n## Dependency Vulnerability Scanning\n\n### Node.js\n\n```bash\n# Built-in npm audit\nnpm audit\nnpm audit --json | jq '.vulnerabilities | to_entries[] | {name: .key, severity: .value.severity, via: .value.via[0]}'\n\n# Fix automatically where possible\nnpm audit fix\n\n# Show only high and critical\nnpm audit --audit-level=high\n\n# Check a specific package\nnpm audit --package-lock-only\n\n# Alternative: use npx to scan without installing\nnpx audit-ci --high\n```\n\n### Python\n\n```bash\n# pip-audit (recommended)\npip install pip-audit\npip-audit\npip-audit -r requirements.txt\npip-audit --format=json\n\n# safety (alternative)\npip install safety\nsafety check\nsafety check -r requirements.txt --json\n\n# Check a specific package\npip-audit --requirement=- \u003C\u003C\u003C \"requests==2.25.0\"\n```\n\n### Go\n\n```bash\n# Built-in vuln checker\ngo install golang.org\u002Fx\u002Fvuln\u002Fcmd\u002Fgovulncheck@latest\ngovulncheck .\u002F...\n\n# Check specific binary\ngovulncheck -mode=binary .\u002Fmyapp\n```\n\n### Rust\n\n```bash\n# cargo-audit\ncargo install cargo-audit\ncargo audit\n\n# With fix suggestions\ncargo audit fix\n```\n\n### Universal: Trivy (scans any project)\n\n```bash\n# Install: https:\u002F\u002Faquasecurity.github.io\u002Ftrivy\n# Scan filesystem\ntrivy fs .\n\n# Scan specific language\ntrivy fs --scanners vuln --severity HIGH,CRITICAL .\n\n# Scan Docker image\ntrivy image myapp:latest\n\n# JSON output\ntrivy fs --format json -o results.json .\n```\n\n## Secret Detection\n\n### Manual grep patterns\n\n```bash\n# AWS keys\ngrep -rn 'AKIA[0-9A-Z]\\{16\\}' --include='*.{js,ts,py,go,java,rb,env,yml,yaml,json,xml,cfg,conf,ini}' .\n\n# Generic API keys and tokens\ngrep -rn -i 'api[_-]\\?key\\|api[_-]\\?secret\\|access[_-]\\?token\\|auth[_-]\\?token\\|bearer ' \\\n  --include='*.{js,ts,py,go,java,rb,env,yml,yaml,json}' .\n\n# Private keys\ngrep -rn 'BEGIN.*PRIVATE KEY' .\n\n# Passwords in config\ngrep -rn -i 'password\\s*[:=]' --include='*.{env,yml,yaml,json,xml,cfg,conf,ini,toml}' .\n\n# Connection strings with credentials\ngrep -rn -i 'mongodb:\u002F\u002F\\|mysql:\u002F\u002F\\|postgres:\u002F\u002F\\|redis:\u002F\u002F' --include='*.{js,ts,py,go,env,yml,yaml,json}' . | grep -v 'localhost\\|127.0.0.1\\|example'\n\n# JWT tokens (three base64 segments separated by dots)\ngrep -rn 'eyJ[A-Za-z0-9_-]*\\.eyJ[A-Za-z0-9_-]*\\.' --include='*.{js,ts,py,go,log,json}' .\n```\n\n### Automated scanning with git\n\n```bash\n# Scan git history for secrets (not just current files)\n# Using git log + grep\ngit log -p --all | grep -n -i 'api.key\\|password\\|secret\\|token' | head -50\n\n# Check staged files before commit\ngit diff --cached --name-only | xargs grep -l -i 'api.key\\|password\\|secret\\|token' 2>\u002Fdev\u002Fnull\n```\n\n### Pre-commit hook for secrets\n\n```bash\n#!\u002Fbin\u002Fbash\n# .git\u002Fhooks\u002Fpre-commit - Block commits containing potential secrets\n\nPATTERNS=(\n    'AKIA[0-9A-Z]{16}'\n    'BEGIN.*PRIVATE KEY'\n    'password\\s*[:=]\\s*[\"\\x27][^\"\\x27]+'\n    'api[_-]?key\\s*[:=]\\s*[\"\\x27][^\"\\x27]+'\n    'sk-[A-Za-z0-9]{20,}'\n    'ghp_[A-Za-z0-9]{36}'\n    'xox[bpoas]-[A-Za-z0-9-]+'\n)\n\nSTAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM)\n[ -z \"$STAGED_FILES\" ] && exit 0\n\nEXIT_CODE=0\nfor pattern in \"${PATTERNS[@]}\"; do\n    matches=$(echo \"$STAGED_FILES\" | xargs grep -Pn \"$pattern\" 2>\u002Fdev\u002Fnull)\n    if [ -n \"$matches\" ]; then\n        echo \"BLOCKED: Potential secret detected matching pattern: $pattern\"\n        echo \"$matches\"\n        EXIT_CODE=1\n    fi\ndone\n\nif [ $EXIT_CODE -ne 0 ]; then\n    echo \"\"\n    echo \"To proceed anyway: git commit --no-verify\"\n    echo \"To remove secrets: replace with environment variables\"\nfi\nexit $EXIT_CODE\n```\n\n### .gitignore audit\n\n```bash\n# Check if sensitive files are tracked\necho \"--- Files that should probably be gitignored ---\"\nfor pattern in '.env' '.env.*' '*.pem' '*.key' '*.p12' '*.pfx' 'credentials.json' \\\n               'service-account*.json' '*.keystore' 'id_rsa' 'id_ed25519'; do\n    found=$(git ls-files \"$pattern\" 2>\u002Fdev\u002Fnull)\n    [ -n \"$found\" ] && echo \"  TRACKED: $found\"\ndone\n\n# Check if .gitignore exists and has common patterns\nif [ ! -f .gitignore ]; then\n    echo \"WARNING: No .gitignore file found\"\nelse\n    for entry in '.env' 'node_modules' '*.key' '*.pem'; do\n        grep -q \"$entry\" .gitignore || echo \"  MISSING from .gitignore: $entry\"\n    done\nfi\n```\n\n## OWASP Top 10 Code Patterns\n\n### 1. Injection (SQL, Command, LDAP)\n\n```bash\n# SQL injection: string concatenation in queries\ngrep -rn \"query\\|execute\\|cursor\" --include='*.{py,js,ts,go,java,rb}' . | \\\n  grep -i \"f\\\"\\|format(\\|%s\\|\\${\\|+ \\\"\\|concat\\|sprintf\" | \\\n  grep -iv \"parameterized\\|placeholder\\|prepared\"\n\n# Command injection: user input in shell commands\ngrep -rn \"exec(\\|spawn(\\|system(\\|popen(\\|subprocess\\|os\\.system\\|child_process\" \\\n  --include='*.{py,js,ts,go,java,rb}' .\n\n# Check for parameterized queries (good)\ngrep -rn \"\\\\$[0-9]\\|\\\\?\\|%s\\|:param\\|@param\\|prepared\" --include='*.{py,js,ts,go,java,rb}' .\n```\n\n### 2. Broken Authentication\n\n```bash\n# Weak password hashing (MD5, SHA1 used for passwords)\ngrep -rn \"md5\\|sha1\\|sha256\" --include='*.{py,js,ts,go,java,rb}' . | grep -i \"password\\|passwd\"\n\n# Hardcoded credentials\ngrep -rn -i \"admin.*password\\|password.*admin\\|default.*password\" \\\n  --include='*.{py,js,ts,go,java,rb,yml,yaml,json}' .\n\n# Session tokens in URLs\ngrep -rn \"session\\|token\\|jwt\" --include='*.{py,js,ts,go,java,rb}' . | grep -i \"url\\|query\\|param\\|GET\"\n\n# Check for rate limiting on auth endpoints\ngrep -rn -i \"rate.limit\\|throttle\\|brute\" --include='*.{py,js,ts,go,java,rb}' .\n```\n\n### 3. Cross-Site Scripting (XSS)\n\n```bash\n# Unescaped output in templates\ngrep -rn \"innerHTML\\|dangerouslySetInnerHTML\\|v-html\\|\\|html(\" \\\n  --include='*.{js,ts,jsx,tsx,vue,html}' .\n\n# Template injection\ngrep -rn \"{{{.*}}}\\|\u003C%=\\|\u003C%-\\|\\$\\!{\" --include='*.{html,ejs,hbs,pug,erb}' .\n\n# Document.write\ngrep -rn \"document\\.write\\|document\\.writeln\" --include='*.{js,ts,html}' .\n\n# eval with user input\ngrep -rn \"eval(\\|new Function(\\|setTimeout.*string\\|setInterval.*string\" \\\n  --include='*.{js,ts}' .\n```\n\n### 4. Insecure Direct Object References\n\n```bash\n# Direct ID usage in routes without authz check\ngrep -rn \"params\\.id\\|params\\[.id.\\]\\|req\\.params\\.\\|request\\.args\\.\\|request\\.GET\\.\" \\\n  --include='*.{py,js,ts,go,java,rb}' . | \\\n  grep -i \"user\\|account\\|profile\\|order\\|document\"\n```\n\n### 5. Security Misconfiguration\n\n```bash\n# CORS wildcard\ngrep -rn \"Access-Control-Allow-Origin.*\\*\\|cors({.*origin.*true\\|cors()\" \\\n  --include='*.{py,js,ts,go,java,rb}' .\n\n# Debug mode in production configs\ngrep -rn \"DEBUG\\s*=\\s*True\\|debug:\\s*true\\|NODE_ENV.*development\" \\\n  --include='*.{py,js,ts,yml,yaml,json,env}' .\n\n# Verbose error messages exposed to clients\ngrep -rn \"stack\\|traceback\\|stackTrace\" --include='*.{py,js,ts,go,java,rb}' . | \\\n  grep -i \"response\\|send\\|return\\|res\\.\"\n```\n\n## SSL\u002FTLS Verification\n\n### Check endpoint SSL\n\n```bash\n# Full SSL check\nopenssl s_client -connect example.com:443 -servername example.com \u003C \u002Fdev\u002Fnull 2>\u002Fdev\u002Fnull | \\\n  openssl x509 -noout -subject -issuer -dates -fingerprint\n\n# Check certificate expiry\necho | openssl s_client -connect example.com:443 -servername example.com 2>\u002Fdev\u002Fnull | \\\n  openssl x509 -noout -enddate\n\n# Check supported TLS versions\nfor v in tls1 tls1_1 tls1_2 tls1_3; do\n  result=$(openssl s_client -connect example.com:443 -$v \u003C \u002Fdev\u002Fnull 2>&1)\n  if echo \"$result\" | grep -q \"Cipher is\"; then\n    echo \"$v: SUPPORTED\"\n  else\n    echo \"$v: NOT SUPPORTED\"\n  fi\ndone\n\n# Check cipher suites\nopenssl s_client -connect example.com:443 -cipher 'ALL' \u003C \u002Fdev\u002Fnull 2>&1 | \\\n  grep \"Cipher    :\"\n\n# Check for weak ciphers\nopenssl s_client -connect example.com:443 -cipher 'NULL:EXPORT:DES:RC4:MD5' \u003C \u002Fdev\u002Fnull 2>&1 | \\\n  grep \"Cipher    :\"\n```\n\n### Verify certificate chain\n\n```bash\n# Download and verify full chain\nopenssl s_client -connect example.com:443 -showcerts \u003C \u002Fdev\u002Fnull 2>\u002Fdev\u002Fnull | \\\n  awk '\u002FBEGIN CERTIFICATE\u002F,\u002FEND CERTIFICATE\u002F{print}' > chain.pem\n\n# Verify chain\nopenssl verify -CAfile \u002Fetc\u002Fssl\u002Fcerts\u002Fca-certificates.crt chain.pem\n\n# Check certificate details\nopenssl x509 -in chain.pem -noout -text | grep -A2 \"Subject:\\|Issuer:\\|Not Before\\|Not After\\|DNS:\"\n```\n\n### Check SSL from code\n\n```bash\n# Verify SSL isn't disabled in code\ngrep -rn \"verify\\s*=\\s*False\\|rejectUnauthorized.*false\\|InsecureSkipVerify.*true\\|CURLOPT_SSL_VERIFYPEER.*false\\|NODE_TLS_REJECT_UNAUTHORIZED.*0\" \\\n  --include='*.{py,js,ts,go,java,rb,yml,yaml}' .\n```\n\n## File Permission Audit\n\n```bash\n# Find world-writable files\nfind . -type f -perm -o=w -not -path '*\u002Fnode_modules\u002F*' -not -path '*\u002F.git\u002F*' 2>\u002Fdev\u002Fnull\n\n# Find executable files that shouldn't be\nfind . -type f -perm -u=x -not -name '*.sh' -not -name '*.py' -not -path '*\u002Fnode_modules\u002F*' \\\n  -not -path '*\u002F.git\u002F*' -not -path '*\u002Fbin\u002F*' 2>\u002Fdev\u002Fnull\n\n# Check sensitive file permissions\nfor f in .env .env.* *.pem *.key *.p12 id_rsa id_ed25519; do\n    [ -f \"$f\" ] && ls -la \"$f\"\ndone\n\n# Find files with SUID\u002FSGID bits (Linux)\nfind \u002F -type f \\( -perm -4000 -o -perm -2000 \\) 2>\u002Fdev\u002Fnull | head -20\n\n# Check SSH key permissions\nif [ -d ~\u002F.ssh ]; then\n    echo \"--- SSH directory permissions ---\"\n    ls -la ~\u002F.ssh\u002F\n    echo \"\"\n    # Should be: dir=700, private keys=600, public keys=644, config=600\n    [ \"$(stat -c %a ~\u002F.ssh 2>\u002Fdev\u002Fnull || stat -f %Lp ~\u002F.ssh)\" != \"700\" ] && echo \"WARNING: ~\u002F.ssh should be 700\"\nfi\n```\n\n## Full Project Security Audit Script\n\n```bash\n#!\u002Fbin\u002Fbash\n# security-audit.sh - Run a comprehensive security check on a project\nset -euo pipefail\n\nPROJECT_DIR=\"${1:-.}\"\ncd \"$PROJECT_DIR\"\n\necho \"=========================================\"\necho \"Security Audit: $(basename \"$(pwd)\")\"\necho \"Date: $(date -u '+%Y-%m-%dT%H:%M:%SZ')\"\necho \"=========================================\"\necho \"\"\n\nISSUES=0\nwarn() { echo \"  [!] $1\"; ((ISSUES++)); }\nok() { echo \"  [OK] $1\"; }\nsection() { echo \"\"; echo \"--- $1 ---\"; }\n\n# 1. Secrets detection\nsection \"Secret Detection\"\nfor pattern in 'AKIA[0-9A-Z]\\{16\\}' 'BEGIN.*PRIVATE KEY' 'sk-[A-Za-z0-9]\\{20,\\}' \\\n               'ghp_[A-Za-z0-9]\\{36\\}' 'xox[bpoas]-'; do\n    count=$(grep -rn \"$pattern\" --include='*.{js,ts,py,go,java,rb,env,yml,yaml,json,xml}' . 2>\u002Fdev\u002Fnull | \\\n            grep -v 'node_modules\\|\\.git\\|vendor\\|__pycache__' | wc -l)\n    if [ \"$count\" -gt 0 ]; then\n        warn \"Found $count matches for pattern: $pattern\"\n    fi\ndone\ngrep -rn -i 'password\\s*[:=]\\s*[\"'\"'\"'][^\"'\"'\"']*[\"'\"'\"']' \\\n  --include='*.{js,ts,py,go,yml,yaml,json,env}' . 2>\u002Fdev\u002Fnull | \\\n  grep -v 'node_modules\\|\\.git\\|example\\|test\\|mock\\|placeholder\\|changeme\\|xxxx' | \\\n  while read -r line; do warn \"Hardcoded password: $line\"; done\n\n# 2. Dependency audit\nsection \"Dependency Vulnerabilities\"\nif [ -f package-lock.json ] || [ -f package.json ]; then\n    npm audit --audit-level=high 2>\u002Fdev\u002Fnull && ok \"npm: no high\u002Fcritical vulns\" || warn \"npm audit found issues\"\nfi\nif [ -f requirements.txt ]; then\n    pip-audit -r requirements.txt 2>\u002Fdev\u002Fnull && ok \"pip: no known vulns\" || warn \"pip-audit found issues\"\nfi\nif [ -f go.sum ]; then\n    govulncheck .\u002F... 2>\u002Fdev\u002Fnull && ok \"Go: no known vulns\" || warn \"govulncheck found issues\"\nfi\n\n# 3. Gitignore check\nsection \".gitignore Coverage\"\nif [ ! -f .gitignore ]; then\n    warn \"No .gitignore file\"\nelse\n    for entry in '.env' 'node_modules' '*.key' '*.pem' '.DS_Store'; do\n        grep -q \"$entry\" .gitignore 2>\u002Fdev\u002Fnull && ok \".gitignore has $entry\" || warn \".gitignore missing: $entry\"\n    done\nfi\n\n# 4. SSL verification disabled\nsection \"SSL Verification\"\ndisabled=$(grep -rn \"verify\\s*=\\s*False\\|rejectUnauthorized.*false\\|InsecureSkipVerify.*true\" \\\n  --include='*.{py,js,ts,go,java,rb}' . 2>\u002Fdev\u002Fnull | \\\n  grep -v 'node_modules\\|\\.git\\|test\\|spec\\|mock' | wc -l)\n[ \"$disabled\" -gt 0 ] && warn \"SSL verification disabled in $disabled location(s)\" || ok \"No SSL bypasses found\"\n\n# 5. CORS wildcard\nsection \"CORS Configuration\"\ncors=$(grep -rn \"Access-Control-Allow-Origin.*\\*\\|cors({.*origin.*true\" \\\n  --include='*.{py,js,ts,go,java,rb}' . 2>\u002Fdev\u002Fnull | \\\n  grep -v 'node_modules\\|\\.git' | wc -l)\n[ \"$cors\" -gt 0 ] && warn \"CORS wildcard found in $cors location(s)\" || ok \"No CORS wildcard\"\n\n# 6. Debug mode\nsection \"Debug\u002FDevelopment Settings\"\ndebug=$(grep -rn \"DEBUG\\s*=\\s*True\\|debug:\\s*true\" \\\n  --include='*.{py,yml,yaml,json}' . 2>\u002Fdev\u002Fnull | \\\n  grep -v 'node_modules\\|\\.git\\|test\\|jest\\|vitest' | wc -l)\n[ \"$debug\" -gt 0 ] && warn \"Debug mode enabled in $debug location(s)\" || ok \"No debug flags found\"\n\necho \"\"\necho \"=========================================\"\necho \"Audit complete. Issues found: $ISSUES\"\necho \"=========================================\"\n[ \"$ISSUES\" -eq 0 ] && exit 0 || exit 1\n```\n\n## Secure Coding Quick Reference\n\n### Environment variables instead of hardcoded secrets\n\n```bash\n# Bad: hardcoded in source\nAPI_KEY=\"sk-abc123...\"\n\n# Good: from environment\nAPI_KEY=\"${API_KEY:?Error: API_KEY not set}\"\n\n# Good: from .env file (loaded at startup, never committed)\n# .env\nAPI_KEY=sk-abc123...\n# .gitignore\n.env\n```\n\n### Input validation checklist\n\n```\n- [ ] All user input validated (type, length, format)\n- [ ] SQL queries use parameterized statements (never string concat)\n- [ ] Shell commands never include user input directly\n- [ ] File paths validated (no path traversal: ..\u002F)\n- [ ] URLs validated (no SSRF: restrict to expected domains)\n- [ ] HTML output escaped (no XSS: use framework auto-escaping)\n- [ ] JSON parsing has error handling (no crash on malformed input)\n- [ ] File uploads checked (type, size, no executable content)\n```\n\n### HTTP security headers\n\n```bash\n# Check security headers on a URL\ncurl -sI https:\u002F\u002Fexample.com | grep -i 'strict-transport\\|content-security\\|x-frame\\|x-content-type\\|referrer-policy\\|permissions-policy'\n\n# Expected headers:\n# Strict-Transport-Security: max-age=31536000; includeSubDomains\n# Content-Security-Policy: default-src 'self'\n# X-Frame-Options: DENY\n# X-Content-Type-Options: nosniff\n# Referrer-Policy: strict-origin-when-cross-origin\n# Permissions-Policy: camera=(), microphone=(), geolocation=()\n```\n\n## Tips\n\n- Run `npm audit` \u002F `pip-audit` \u002F `govulncheck` in CI on every pull request, not just occasionally.\n- Secret detection in git history matters: even if a secret is removed from HEAD, it exists in git history. Use `git filter-branch` or `git-filter-repo` to purge, then rotate the credential.\n- The most dangerous vulnerabilities are often the simplest: SQL injection via string concatenation, command injection via unsanitized input, XSS via `innerHTML`.\n- CORS `Access-Control-Allow-Origin: *` is safe for truly public, read-only APIs. It's dangerous for anything that uses cookies or auth tokens.\n- Always verify SSL in production. `verify=False` or `rejectUnauthorized: false` should only appear in test code, never in production paths.\n- Defense in depth: validate input, escape output, use parameterized queries, enforce least privilege, and assume every layer might be bypassed.\n\n---\n\n## 🤖 Agentic Security Audit (Bổ sung 25\u002F02\u002F2026)\n\n> *Từ paper \"Agents of Chaos\" (arXiv:2602.20021) + OWASP Top 10 for Agentic Applications 2026.*\n> *Traditional security audit chỉ cover code\u002Finfra. Agentic systems có attack surface hoàn toàn mới.*\n\n### When to Use (Agentic)\n\n- Auditing OpenClaw\u002Fagent workspace configuration\n- Reviewing agent permissions and access boundaries\n- Scanning for prompt injection vectors in agent-facing content\n- Assessing multi-agent communication security\n- Evaluating identity verification mechanisms\n- Checking persistent memory for poisoning\n\n### OWASP Agentic Top 10 Checklist (2026)\n\n```\n- [ ] ASI01: Agent Goal Hijack (prompt injection — direct & indirect)\n- [ ] ASI02: Tool Misuse and Exploitation (shell, filesystem, API abuse)\n- [ ] ASI03: Identity and Privilege Abuse (confused deputy, over-privilege)\n- [ ] ASI04: Memory Poisoning (SOUL.md, MEMORY.md, persistent context)\n- [ ] ASI05: Supply Chain Attacks (malicious skills\u002Fplugins — e.g., ClawHub)\n- [ ] ASI06: Rogue Agents (operating outside intended boundaries)\n- [ ] ASI07: Data Leakage via Agentic Channels (cross-channel PII exposure)\n- [ ] ASI08: Orchestration Manipulation (sub-agent hijacking)\n- [ ] ASI09: Insufficient Logging and Observability\n- [ ] ASI10: Insecure Agent Communication (agent-to-agent trust)\n```\n\n### 1. Workspace Configuration Audit\n\n```bash\n# Check if agent config files are world-readable\necho \"--- Agent Config Permissions ---\"\nfor f in SOUL.md MEMORY.md AGENTS.md TOOLS.md IDENTITY.md USER.md HEARTBEAT.md; do\n    [ -f \"$f\" ] && echo \"$(stat -f '%Sp %N' \"$f\" 2>\u002Fdev\u002Fnull || stat -c '%A %n' \"$f\")\" || echo \"  NOT FOUND: $f\"\ndone\n\n# Check for secrets leaked into agent memory\u002Fconfig\necho \"--- Secrets in Agent Files ---\"\ngrep -rn -i 'api.key\\|password\\|token\\|secret\\|bearer' \\\n  SOUL.md MEMORY.md TOOLS.md IDENTITY.md USER.md memory\u002F*.md 2>\u002Fdev\u002Fnull | \\\n  grep -v 'example\\|placeholder\\|REDACTED'\n\n# Check for over-permissive shell access\necho \"--- Shell Access Check ---\"\ngrep -rn -i 'sudo\\|chmod 777\\|unrestricted' AGENTS.md TOOLS.md 2>\u002Fdev\u002Fnull\n```\n\n### 2. Prompt Injection Scan (Agent-Facing Content)\n\n```bash\n# Scan content that agents read\u002Fprocess for injection patterns\nSCAN_DIRS=\"${1:-.}\"\n\necho \"--- Prompt Injection Patterns ---\"\nINJECTION_PATTERNS=(\n    'ignore\\s+(previous|all|above)\\s+instructions'\n    'you\\s+are\\s+now\\s+'\n    'new\\s+system\\s+prompt'\n    '\\[SYSTEM\\]'\n    '\u003CSYSTEM_ADMIN_OVERRIDE>'\n    'AUTHORIZED_OVERRIDE'\n    'forget\\s+your\\s+(rules|instructions|guidelines)'\n    'act\\s+as\\s+if\\s+you\\s+are'\n    'disregard\\s+(all|your|previous)'\n    'jailbreak'\n    'DAN\\s+mode'\n)\n\nfor pattern in \"${INJECTION_PATTERNS[@]}\"; do\n    matches=$(grep -rn -iP \"$pattern\" \"$SCAN_DIRS\" \\\n      --include='*.{md,txt,json,html,yml,yaml}' 2>\u002Fdev\u002Fnull | \\\n      grep -v 'node_modules\\|\\.git\\|SKILL.md' | head -5)\n    [ -n \"$matches\" ] && echo \"  [!] Injection pattern '$pattern':\" && echo \"$matches\"\ndone\n\n# Steganographic: zero-width Unicode characters\necho \"--- Zero-Width Unicode Characters ---\"\ngrep -rPn '[\\x{200B}\\x{200C}\\x{200D}\\x{FEFF}\\x{00AD}\\x{2060}]' \"$SCAN_DIRS\" \\\n  --include='*.{md,txt,json,html}' 2>\u002Fdev\u002Fnull | head -10\n\n# Suspicious base64 strings (>50 chars, could be encoded payloads)\necho \"--- Suspicious Base64 Strings ---\"\ngrep -rPn '[A-Za-z0-9+\u002F=]{50,}' \"$SCAN_DIRS\" \\\n  --include='*.{md,txt,json}' 2>\u002Fdev\u002Fnull | \\\n  grep -v 'node_modules\\|\\.git\\|\\.png\\|\\.jpg\\|package-lock' | head -10\n```\n\n### 3. Identity & Authorization Audit\n\n```bash\n# Check if agent verifies owner identity beyond display name\necho \"--- Identity Verification ---\"\n\n# OpenClaw: check if authorized senders are configured\ngrep -n 'authorizedSenders\\|authorized_senders\\|allowlist' \\\n  ~\u002F.config\u002Fopenclaw\u002Fconfig.yaml ~\u002F.openclaw\u002Fconfig.* 2>\u002Fdev\u002Fnull\n\n# Check if agent trusts display names (vulnerable to spoofing)\ngrep -rn -i 'display.name\\|username\\|sender.name' \\\n  AGENTS.md SOUL.md TOOLS.md 2>\u002Fdev\u002Fnull | \\\n  grep -iv 'user.id\\|sender.id\\|verified'\n\n# Check for cross-channel trust assumptions\necho \"--- Cross-Channel Trust ---\"\ngrep -rn -i 'if.*channel\\|trust.*channel\\|verify.*channel' \\\n  AGENTS.md SOUL.md 2>\u002Fdev\u002Fnull\n```\n\n### 4. Memory Poisoning Check\n\n```bash\n# Check memory files for suspicious patterns\necho \"--- Memory Integrity ---\"\n\n# External URLs stored as \"governing documents\" (Case #10: Agent Corruption)\necho \"URLs in memory that agent may follow as instructions:\"\ngrep -rn 'https\\?:\u002F\u002F\\|gist\\.github\\|pastebin\\|hastebin' \\\n  MEMORY.md memory\u002F*.md HEARTBEAT.md 2>\u002Fdev\u002Fnull\n\n# Check if memory files were recently modified by non-owner actions\necho \"Recent memory file changes:\"\nfind memory\u002F MEMORY.md SOUL.md AGENTS.md -newer IDENTITY.md -type f 2>\u002Fdev\u002Fnull | \\\n  while read f; do echo \"  $(stat -f '%Sm %N' \"$f\" 2>\u002Fdev\u002Fnull || stat -c '%y %n' \"$f\")\"; done\n\n# Check for instructions in memory that override safety rules\ngrep -rn -i 'override\\|bypass\\|ignore.*rule\\|disable.*safety\\|skip.*check' \\\n  MEMORY.md memory\u002F*.md HEARTBEAT.md 2>\u002Fdev\u002Fnull\n\n# Check git blame for who modified critical files\necho \"--- SOUL.md modification history ---\"\ngit log --oneline -10 -- SOUL.md 2>\u002Fdev\u002Fnull || echo \"  (not in git)\"\necho \"--- AGENTS.md modification history ---\"\ngit log --oneline -10 -- AGENTS.md 2>\u002Fdev\u002Fnull || echo \"  (not in git)\"\n```\n\n### 5. Multi-Agent Communication Audit\n\n```bash\n# Check for agent-to-agent trust without verification\necho \"--- Multi-Agent Trust ---\"\n\n# Shared channels where agents interact (Discord, forum, email)\ngrep -rn -i 'discord\\|forum\\|moltbook\\|clawstr\\|email.*agent' \\\n  TOOLS.md MEMORY.md memory\u002F*.md 2>\u002Fdev\u002Fnull\n\n# Check if agent auto-executes actions from other agents\ngrep -rn -i 'webhook\\|auto.reply\\|auto.respond\\|on.*mention' \\\n  AGENTS.md HEARTBEAT.md TOOLS.md scripts\u002F*.sh 2>\u002Fdev\u002Fnull\n\n# Check for infinite loop risks (agent A ↔ agent B relay)\ngrep -rn -i 'relay\\|forward.*message\\|pass.*along\\|tell.*agent' \\\n  MEMORY.md memory\u002F*.md 2>\u002Fdev\u002Fnull\n\n# Check cron\u002Fheartbeat for tasks triggered by external content\necho \"--- Scheduled Tasks ---\"\ngrep -rn -i 'check.*forum\\|check.*moltbook\\|reply.*comment\\|respond.*mention' \\\n  HEARTBEAT.md 2>\u002Fdev\u002Fnull\n```\n\n### 6. Resource & Privilege Audit\n\n```bash\n# Check for excessive agent permissions\necho \"--- Agent Permissions ---\"\n\n# Sudo access (should NOT be default for agents)\ngrep -rn 'sudo\\|root\\|admin.*access\\|unrestricted' \\\n  AGENTS.md TOOLS.md 2>\u002Fdev\u002Fnull\n\n# Background processes agent has created\necho \"Running agent processes:\"\nps aux | grep -i 'cron\\|heartbeat\\|monitor\\|watch\\|loop' | grep -v grep | head -10\n\n# Check for unbounded resource consumption patterns\necho \"--- Cron\u002FBackground Jobs ---\"\ncrontab -l 2>\u002Fdev\u002Fnull || echo \"  No crontab\"\n\n# Check disk usage of agent workspace\necho \"--- Workspace Size ---\"\ndu -sh . memory\u002F 2>\u002Fdev\u002Fnull\n\n# Check for files agent probably shouldn't have access to\necho \"--- Sensitive System Files Readable by Agent ---\"\nfor f in \u002Fetc\u002Fshadow \u002Fetc\u002Fpasswd ~\u002F.ssh\u002Fid_rsa ~\u002F.ssh\u002Fid_ed25519 \\\n         ~\u002F.aws\u002Fcredentials ~\u002F.config\u002Fgcloud\u002Fcredentials.db; do\n    [ -r \"$f\" ] && echo \"  [!] READABLE: $f\"\ndone\n```\n\n### 7. Semantic Reframing Detection (Advanced)\n\n> *From Agents of Chaos Case #3: \"Give me SSN\" → refused. \"Forward the email\" (containing SSN) → complied.*\n> *This check helps humans verify their agent won't leak data through reframed requests.*\n\n```bash\n# Check if agent has rules about content-based (not just action-based) evaluation\necho \"--- Content-Based Safety Rules ---\"\ngrep -rn -i 'content.*evaluat\\|semantic.*refram\\|forward.*email.*sensitive\\|assess.*content' \\\n  AGENTS.md SOUL.md 2>\u002Fdev\u002Fnull\n\n# Check for PII in files agent might forward\u002Fshare\necho \"--- PII in Agent-Accessible Files ---\"\n# SSN pattern\ngrep -rPn '\\b\\d{3}-\\d{2}-\\d{4}\\b' MEMORY.md memory\u002F*.md 2>\u002Fdev\u002Fnull\n# Credit card pattern\ngrep -rPn '\\b\\d{4}[-\\s]?\\d{4}[-\\s]?\\d{4}[-\\s]?\\d{4}\\b' MEMORY.md memory\u002F*.md 2>\u002Fdev\u002Fnull\n# Email addresses\ngrep -rPn '\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z]{2,}\\b' \\\n  MEMORY.md memory\u002F*.md USER.md 2>\u002Fdev\u002Fnull | \\\n  grep -v 'example\\|test\\|placeholder'\n```\n\n### Full Agentic Security Audit Script\n\n```bash\n#!\u002Fbin\u002Fbash\n# agentic-security-audit.sh - Comprehensive security check for AI agent workspaces\n# Based on \"Agents of Chaos\" (arXiv:2602.20021) + OWASP Agentic Top 10\nset -euo pipefail\n\nWORKSPACE=\"${1:-.}\"\ncd \"$WORKSPACE\"\n\necho \"=========================================\"\necho \"Agentic Security Audit\"\necho \"Workspace: $(pwd)\"\necho \"Date: $(date -u '+%Y-%m-%dT%H:%M:%SZ')\"\necho \"Framework: Based on Agents of Chaos + OWASP Agentic Top 10\"\necho \"=========================================\"\necho \"\"\n\nISSUES=0\nWARNINGS=0\nwarn() { echo \"  ⚠️  $1\"; ((WARNINGS++)); }\ncritical() { echo \"  🔴 $1\"; ((ISSUES++)); }\nok() { echo \"  ✅ $1\"; }\nsection() { echo \"\"; echo \"=== $1 ===\"; }\n\n# --- ASI01: Prompt Injection ---\nsection \"ASI01: Prompt Injection Vectors\"\ninjection_count=0\nfor pattern in 'ignore.*previous.*instructions' 'you are now' 'new system prompt' \\\n               '\\[SYSTEM\\]' 'SYSTEM_ADMIN_OVERRIDE' 'forget your' 'act as if'; do\n    count=$(grep -rin \"$pattern\" --include='*.md' --include='*.txt' --include='*.json' . 2>\u002Fdev\u002Fnull | \\\n            grep -v 'SKILL.md\\|security-audit\\|node_modules\\|\\.git' | wc -l | tr -d ' ')\n    injection_count=$((injection_count + count))\ndone\n[ \"$injection_count\" -gt 0 ] && critical \"Found $injection_count prompt injection patterns in workspace\" || ok \"No injection patterns found\"\n\n# Zero-width Unicode\nzw_count=$(grep -rPc '[\\x{200B}\\x{200C}\\x{200D}\\x{FEFF}]' --include='*.md' . 2>\u002Fdev\u002Fnull | \\\n           awk -F: '{s+=$2}END{print s+0}')\n[ \"$zw_count\" -gt 0 ] && critical \"Found $zw_count zero-width Unicode chars (possible steganographic injection)\" || ok \"No hidden Unicode\"\n\n# --- ASI02: Tool Misuse ---\nsection \"ASI02: Tool Permissions\"\ngrep -rn 'sudo\\|chmod 777\\|unrestricted.*shell\\|full.*access' AGENTS.md TOOLS.md 2>\u002Fdev\u002Fnull && \\\n  critical \"Over-permissive access configured\" || ok \"No sudo\u002Funrestricted access\"\n\n# --- ASI03: Identity & Privilege ---\nsection \"ASI03: Identity Verification\"\nif grep -q 'authorizedSenders\\|Authorized Senders\\|Telegram.*ID' AGENTS.md 2>\u002Fdev\u002Fnull; then\n    ok \"Authorized sender verification configured\"\nelse\n    critical \"No authorized sender verification found — vulnerable to non-owner compliance\"\nfi\n\n# Anti-spoofing rules\nif grep -qi 'display.name.*identity\\|verify.*identity\\|spoofing\\|user.*ID.*verify' AGENTS.md 2>\u002Fdev\u002Fnull; then\n    ok \"Identity spoofing awareness in config\"\nelse\n    warn \"No anti-spoofing rules — vulnerable to Case #8 Identity Hijack\"\nfi\n\n# --- ASI04: Memory Poisoning ---\nsection \"ASI04: Memory Integrity\"\next_urls=$(grep -rn 'https\\?:\u002F\u002F.*gist\\|https\\?:\u002F\u002F.*pastebin\\|https\\?:\u002F\u002F.*hastebin' \\\n  MEMORY.md memory\u002F*.md HEARTBEAT.md 2>\u002Fdev\u002Fnull | wc -l | tr -d ' ')\n[ \"$ext_urls\" -gt 0 ] && warn \"Found $ext_urls external URLs in memory files (Case #10 risk: external governing documents)\" || ok \"No suspicious external URLs in memory\"\n\noverride_count=$(grep -rin 'override\\|bypass.*safety\\|disable.*check\\|ignore.*rule' \\\n  MEMORY.md memory\u002F*.md HEARTBEAT.md 2>\u002Fdev\u002Fnull | wc -l | tr -d ' ')\n[ \"$override_count\" -gt 0 ] && critical \"Found $override_count override\u002Fbypass instructions in memory\" || ok \"No override patterns in memory\"\n\n# --- ASI05: Supply Chain ---\nsection \"ASI05: Supply Chain (Skills\u002FPlugins)\"\nif [ -d skills ] || [ -d .openclaw\u002Fskills ]; then\n    skill_count=$(find skills .openclaw\u002Fskills -name 'SKILL.md' 2>\u002Fdev\u002Fnull | wc -l | tr -d ' ')\n    echo \"  Found $skill_count installed skills\"\n    # Check for skills with shell access\n    grep -rn 'exec\\|shell\\|subprocess\\|child_process' skills\u002F*\u002FSKILL.md .openclaw\u002Fskills\u002F*\u002FSKILL.md 2>\u002Fdev\u002Fnull && \\\n      warn \"Skills with shell execution capabilities found\" || ok \"No shell-executing skills\"\nfi\n\n# --- ASI07: Data Leakage ---\nsection \"ASI07: Sensitive Data Exposure\"\n# Secrets in agent files\nsecret_count=$(grep -rin 'api.key\\s*[:=]\\|password\\s*[:=]\\|token\\s*[:=]\\|bearer\\s' \\\n  SOUL.md MEMORY.md TOOLS.md USER.md memory\u002F*.md 2>\u002Fdev\u002Fnull | \\\n  grep -v 'example\\|placeholder\\|REDACTED\\|xxx\\|changeme\\|SKILL.md' | wc -l | tr -d ' ')\n[ \"$secret_count\" -gt 0 ] && critical \"Found $secret_count potential secrets in agent files\" || ok \"No exposed secrets\"\n\n# PII patterns\npii_count=0\nssn=$(grep -rPc '\\b\\d{3}-\\d{2}-\\d{4}\\b' MEMORY.md memory\u002F*.md USER.md 2>\u002Fdev\u002Fnull | awk -F: '{s+=$2}END{print s+0}')\npii_count=$((pii_count + ssn))\ncc=$(grep -rPc '\\b\\d{4}[-\\s]?\\d{4}[-\\s]?\\d{4}[-\\s]?\\d{4}\\b' MEMORY.md memory\u002F*.md 2>\u002Fdev\u002Fnull | awk -F: '{s+=$2}END{print s+0}')\npii_count=$((pii_count + cc))\n[ \"$pii_count\" -gt 0 ] && warn \"Found $pii_count PII patterns (SSN\u002Fcredit card) in agent files\" || ok \"No PII patterns\"\n\n# --- ASI06: Boundary Rules ---\nsection \"ASI06: Agent Boundary Rules\"\nif grep -qi 'non-owner\\|non.owner.*refuse\\|only.*owner\\|forum.*only.*discuss\\|chỉ.*thảo luận' AGENTS.md 2>\u002Fdev\u002Fnull; then\n    ok \"Non-owner boundary rules configured\"\nelse\n    warn \"No non-owner boundary rules — vulnerable to Case #2 non-owner compliance\"\nfi\n\nif grep -qi 'nhượng bộ\\|concession.*limit\\|escalat.*stop\\|gaslighting\\|pressure.*limit' AGENTS.md 2>\u002Fdev\u002Fnull; then\n    ok \"Anti-gaslighting\u002Fescalation rules present\"\nelse\n    warn \"No anti-gaslighting rules — vulnerable to Case #7\"\nfi\n\n# --- ASI10: Multi-Agent Communication ---\nsection \"ASI10: Multi-Agent Communication\"\nagent_channels=$(grep -rin 'discord\\|forum\\|moltbook\\|clawstr\\|webhook' \\\n  TOOLS.md MEMORY.md HEARTBEAT.md 2>\u002Fdev\u002Fnull | wc -l | tr -d ' ')\necho \"  Agent communicates via $agent_channels external channel references\"\n[ \"$agent_channels\" -gt 5 ] && warn \"Many external channels — larger attack surface\" || ok \"Moderate channel exposure\"\n\n# --- Summary ---\necho \"\"\necho \"=========================================\"\necho \"Audit complete\"\necho \"  🔴 Critical issues: $ISSUES\"\necho \"  ⚠️  Warnings: $WARNINGS\"\necho \"=========================================\"\n\nif [ \"$ISSUES\" -gt 0 ]; then\n    echo \"\"\n    echo \"Recommended actions:\"\n    echo \"  1. Fix all critical issues before exposing agent to external interactions\"\n    echo \"  2. Review AGENTS.md for Anti-Chaos Defense Rules\"\n    echo \"  3. Reference: Agents of Chaos (arXiv:2602.20021)\"\n    echo \"  4. Reference: OWASP Top 10 for Agentic Applications 2026\"\n    exit 1\nfi\nexit 0\n```\n\n### References\n\n- [Agents of Chaos — arXiv:2602.20021](https:\u002F\u002Farxiv.org\u002Fabs\u002F2602.20021) — Live red-teaming of OpenClaw agents\n- [OWASP Top 10 for Agentic Applications 2026](https:\u002F\u002Fgenai.owasp.org\u002Fresource\u002Fowasp-top-10-for-agentic-applications-for-2026\u002F)\n- [NIST AI Agent Standards Initiative](https:\u002F\u002Fwww.nist.gov\u002Fcaisi\u002Fai-agent-standards-initiative)\n- [OpenClaw Security Crisis — Conscia](https:\u002F\u002Fconscia.com\u002Fblog\u002Fthe-openclaw-security-crisis\u002F)\n",{"name":5,"metadata":24,"description":7},{"clawdbot":25},{"os":26,"emoji":30,"requires":31},[27,28,29],"linux","darwin","win32","🔒",{"anyBins":32},[33,34,35,36,37],"npm","pip","git","openssl","curl","master","4aa004da461d820f4ea5499e58eb8d196cf99016","community\u002Fclawhub\u002Fa\u002Fagentic-security-audit",0,"https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge","https:\u002F\u002Fskill-explorer-rho.vercel.app","https:\u002F\u002Fgithub.com\u002FLord1Egypt","Unbreakable. Unstoppable. Unmatched⚡.\r\n Speaker of machine tongues 🤖  | World-builder of decentralized dreams 🌐 | Defender of the digital realm🛡️.","2026-06-10 08:21:01",{"source":8,"skillName":5,"commands":48,"prompt":58,"zipAvailable":59},[49,52,55],{"tool":50,"command":51},"npx","npx skills add Lord1Egypt\u002Fawesome-skill-forge --skill security-audit",{"tool":53,"command":54},"bunx","bunx skills add Lord1Egypt\u002Fawesome-skill-forge --skill security-audit",{"tool":56,"command":57},"pnpm","pnpm dlx skills add Lord1Egypt\u002Fawesome-skill-forge --skill security-audit","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fclawhub\u002Fa\u002Fagentic-security-audit\u002FSKILL.md",true,[],[62,70,77,84,91,98],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":69},"01M785WKJB99G3STR1NF9NRTJW","youtube-content","YouTube transcripts to summaries, threads, blogs.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fyoutube-content\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":69},"01M785WEFHB0G2S9YA6EPR3H0E","xurl","X\u002FTwitter via xurl CLI: post, search, DM, media, v2 API.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fxurl\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":69},"01M785W98EDN4EFJXJPMQEHCRC","touchdesigner-mcp","Control a running TouchDesigner instance via twozero MCP — create operators, set parameters, wire connections, execute Python, build real-time visuals. 36 native tools.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftouchdesigner-mcp\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":69},"01M785W5S9FP3QBH2V191E025P","test-driven-development","TDD: enforce RED-GREEN-REFACTOR, tests before code.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftest-driven-development\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":69},"01M785W2AS08NSSH9YATCV6FJB","teams-meeting-pipeline","Operate the Teams meeting summary pipeline via Hermes CLI — summarize meetings, inspect pipeline status, replay jobs, manage Microsoft Graph subscriptions.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fteams-meeting-pipeline\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":69},"01M785VXKW4T34BTP1SCHW1R7F","systematic-debugging","4-phase root cause debugging: understand bugs before fixing.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fsystematic-debugging\u002FSKILL.md",[],[]]