Agent Skill Security Audit
Description
An agent skill is executable trust-boundary content when it contains instructions, scripts, hooks, references, or tool permissions. Audit the complete skill package before installation or execution rather than trusting its description or publisher metadata.
The audit is primarily static and compares declared behavior with the actual SKILL.md instructions and every bundled executable/resource file. Check for unexpected permission grants, credential reads, network egress, obfuscated content, hidden behavior, unsafe hooks, and mismatch between advertised and observable behavior.
Dynamic analysis is optional and must run only in an isolated sandbox with synthetic or no credentials, bounded resources, controlled network access, and explicit teardown. An audit result is evidence for a trust decision; it is not a guarantee that a skill is benign.
Inputs / Outputs
| Input |
Type |
Required |
Description |
| skill_root |
path |
yes |
Root directory containing the skill manifest and bundled resources |
| declared_permissions |
list |
no |
Permissions/tools explicitly declared by the skill or host metadata |
| runtime_policy |
object |
no |
Sandbox, filesystem, network, credential, and execution constraints |
| audit_mode |
enum |
yes |
static or sandboxed |
Output is a structured audit record containing findings, evidence locations, severity, confidence, declared-vs-observed deltas, sandbox requirements, and a disposition such as allow, review, or deny.
Audit Procedure
- Parse frontmatter and record declared name, purpose, permissions, compatibility, and provenance.
- Inventory SKILL.md, scripts, hooks, binaries, configuration, references, and generated files under the skill root.
- Compare advertised behavior with actual instructions and executable content.
- Identify credential and sensitive-file access, including environment variables, SSH material, cloud credentials, token stores, and unrelated user data.
- Identify network destinations and egress mechanisms. Treat undeclared network access as a finding requiring review.
- Inspect for shell/process execution, package installation, dynamic code loading, obfuscation, encoded payloads, persistence, or attempts to hide behavior from the user.
- Compare declared tool permissions with the minimum permissions required by observed behavior.
- Record exact evidence locations and never treat absence of a detected pattern as proof of safety.
- If dynamic analysis is required, run only in an isolated sandbox with synthetic credentials, bounded resources, controlled egress, and no access to the auditor real environment.
- Produce a fail-closed disposition when high-confidence critical behavior is incompatible with the declared purpose or execution policy.
Runnable Example
from pathlib import Path
import re
SENSITIVE_PATHS = (".env", ".ssh", ".aws", ".config/gcloud")
def audit_skill(root: Path) -> list[dict]:
findings = []
for path in sorted(p for p in root.rglob("*") if p.is_file()):
rel = path.relative_to(root).as_posix()
text = path.read_text(errors="replace") if path.suffix in {".md", ".py", ".sh", ".json", ".yaml", ".yml"} else ""
if any(token in rel for token in SENSITIVE_PATHS):
findings.append({"rule": "sensitive-path", "severity": "high", "path": rel})
if re.search(r"(curl|wget|requests\\.(get|post)|urllib\\.request)", text, re.I):
findings.append({"rule": "network-egress", "severity": "medium", "path": rel})
return findings
print(audit_skill(Path("./skill-under-review")))
This example is a bounded static signal detector, not a malware detector. Production audits need language-aware analysis, archive/binary handling, symlink controls, policy evaluation, and reproducible evidence capture.
Failure Modes
| Failure |
Cause |
Mitigation |
| Trusting metadata |
Description differs from bundled behavior |
Audit executable/resource contents and record declared-vs-observed deltas |
| Credential exposure |
Skill reads real secrets or credential stores |
Deny or isolate access; use synthetic credentials for dynamic testing |
| Hidden egress |
Network access is not declared or constrained |
Default to no network and allow only policy-approved destinations |
| Permission overreach |
Skill requests tools broader than its purpose |
Apply least privilege and require explicit review for elevated permissions |
| Obfuscation |
Encoded/dynamic content hides behavior |
Flag for manual/static analysis and preserve exact evidence location |
| Sandbox escape |
Dynamic test reaches the host |
Use a maintained isolated runtime with resource, filesystem, and network controls |
| False negative |
Static checks miss behavior |
Treat audit output as evidence, not a safety guarantee; use layered controls |
| False positive |
Benign implementation matches a heuristic |
Record confidence and require contextual review rather than automatic condemnation |
Design Rules
- Treat every third-party skill package as untrusted input until its behavior is reviewed.
- Audit the complete package, not only SKILL.md frontmatter.
- Preserve provenance and exact evidence locations for every finding.
- Compare declared permissions and behavior against the least-privilege execution policy.
- Default dynamic analysis to synthetic/no credentials, bounded resources, and restricted network access.
- Never claim that a static scan proves a skill is safe.
- Keep audit evidence separate from authorization; a passing audit does not itself grant permission to execute a skill.
- Prefer deterministic checks for path, permission, secret, network, and package-integrity findings where practical.
References
Evidence
Evidence status: the cited sources support the audit problem and defensive methodology. This skill does not claim complete malware detection, compliance certification, or universal safety.
Related Skills
- Sandboxed Execution
- Secret Scanning
- Permission Checking
- Input Sanitization
- Audit Logging
Changelog
| Date |
Version |
Change |
| 2026-10 |
v1 |
Added demand-driven contract for pre-installation and pre-execution agent-skill security auditing |
1---2name: agent-skill-security-audit3description: Audit an agent skill and its bundled resources before installation or execution, checking declared behavior, permissions, credential access, network egress, obfuscation, and sandbox requirements.4metadata:5 source: https://skillmd.com/skills/samotech/agent-skill-security-audit6 upstream: skills/14-security/agent-skill-security-audit.md7 category: 14-security8 version: "v1"9---1011# Agent Skill Security Audit1213## Description1415An agent skill is executable trust-boundary content when it contains instructions, scripts, hooks, references, or tool permissions. Audit the complete skill package before installation or execution rather than trusting its description or publisher metadata.1617The audit is primarily static and compares declared behavior with the actual SKILL.md instructions and every bundled executable/resource file. Check for unexpected permission grants, credential reads, network egress, obfuscated content, hidden behavior, unsafe hooks, and mismatch between advertised and observable behavior.1819Dynamic analysis is optional and must run only in an isolated sandbox with synthetic or no credentials, bounded resources, controlled network access, and explicit teardown. An audit result is evidence for a trust decision; it is not a guarantee that a skill is benign.2021## Inputs / Outputs2223| Input | Type | Required | Description |24|---|---|---:|---|25| skill_root | path | yes | Root directory containing the skill manifest and bundled resources |26| declared_permissions | list | no | Permissions/tools explicitly declared by the skill or host metadata |27| runtime_policy | object | no | Sandbox, filesystem, network, credential, and execution constraints |28| audit_mode | enum | yes | static or sandboxed |2930Output is a structured audit record containing findings, evidence locations, severity, confidence, declared-vs-observed deltas, sandbox requirements, and a disposition such as allow, review, or deny.3132## Audit Procedure33341. Parse frontmatter and record declared name, purpose, permissions, compatibility, and provenance.352. Inventory SKILL.md, scripts, hooks, binaries, configuration, references, and generated files under the skill root.363. Compare advertised behavior with actual instructions and executable content.374. Identify credential and sensitive-file access, including environment variables, SSH material, cloud credentials, token stores, and unrelated user data.385. Identify network destinations and egress mechanisms. Treat undeclared network access as a finding requiring review.396. Inspect for shell/process execution, package installation, dynamic code loading, obfuscation, encoded payloads, persistence, or attempts to hide behavior from the user.407. Compare declared tool permissions with the minimum permissions required by observed behavior.418. Record exact evidence locations and never treat absence of a detected pattern as proof of safety.429. If dynamic analysis is required, run only in an isolated sandbox with synthetic credentials, bounded resources, controlled egress, and no access to the auditor real environment.4310. Produce a fail-closed disposition when high-confidence critical behavior is incompatible with the declared purpose or execution policy.4445## Runnable Example4647```python48from pathlib import Path49import re5051SENSITIVE_PATHS = (".env", ".ssh", ".aws", ".config/gcloud")5253def audit_skill(root: Path) -> list[dict]:54 findings = []55 for path in sorted(p for p in root.rglob("*") if p.is_file()):56 rel = path.relative_to(root).as_posix()57 text = path.read_text(errors="replace") if path.suffix in {".md", ".py", ".sh", ".json", ".yaml", ".yml"} else ""58 if any(token in rel for token in SENSITIVE_PATHS):59 findings.append({"rule": "sensitive-path", "severity": "high", "path": rel})60 if re.search(r"(curl|wget|requests\\.(get|post)|urllib\\.request)", text, re.I):61 findings.append({"rule": "network-egress", "severity": "medium", "path": rel})62 return findings6364print(audit_skill(Path("./skill-under-review")))65```6667This example is a bounded static signal detector, not a malware detector. Production audits need language-aware analysis, archive/binary handling, symlink controls, policy evaluation, and reproducible evidence capture.6869## Failure Modes7071| Failure | Cause | Mitigation |72|---|---|---|73| Trusting metadata | Description differs from bundled behavior | Audit executable/resource contents and record declared-vs-observed deltas |74| Credential exposure | Skill reads real secrets or credential stores | Deny or isolate access; use synthetic credentials for dynamic testing |75| Hidden egress | Network access is not declared or constrained | Default to no network and allow only policy-approved destinations |76| Permission overreach | Skill requests tools broader than its purpose | Apply least privilege and require explicit review for elevated permissions |77| Obfuscation | Encoded/dynamic content hides behavior | Flag for manual/static analysis and preserve exact evidence location |78| Sandbox escape | Dynamic test reaches the host | Use a maintained isolated runtime with resource, filesystem, and network controls |79| False negative | Static checks miss behavior | Treat audit output as evidence, not a safety guarantee; use layered controls |80| False positive | Benign implementation matches a heuristic | Record confidence and require contextual review rather than automatic condemnation |8182## Design Rules83841. Treat every third-party skill package as untrusted input until its behavior is reviewed.852. Audit the complete package, not only SKILL.md frontmatter.863. Preserve provenance and exact evidence locations for every finding.874. Compare declared permissions and behavior against the least-privilege execution policy.885. Default dynamic analysis to synthetic/no credentials, bounded resources, and restricted network access.896. Never claim that a static scan proves a skill is safe.907. Keep audit evidence separate from authorization; a passing audit does not itself grant permission to execute a skill.918. Prefer deterministic checks for path, permission, secret, network, and package-integrity findings where practical.9293## References9495- OWASP Secure Agent Playbook issue #21: https://github.com/OWASP/secure-agent-playbook/issues/2196- 2026 research on detecting malicious agent skills: https://arxiv.org/abs/2602.0654797- Skills Tree Sandboxed Execution: sandboxed-execution.md98- Skills Tree Secret Scanning: secret-scanning.md99100## Evidence101102Evidence status: the cited sources support the audit problem and defensive methodology. This skill does not claim complete malware detection, compliance certification, or universal safety.103104## Related Skills105106- [Sandboxed Execution](sandboxed-execution.md)107- [Secret Scanning](secret-scanning.md)108- [Permission Checking](permission-checking.md)109- [Input Sanitization](input-sanitization.md)110- [Audit Logging](audit-logging.md)111112## Changelog113114| Date | Version | Change |115|---|---|---|116| 2026-10 | v1 | Added demand-driven contract for pre-installation and pre-execution agent-skill security auditing |