Class SkillSecurityScanner
java.lang.Object
io.agentscope.harness.agent.skill.curator.SkillSecurityScanner
Static-analysis scanner for SKILL.md and skill support files. Ported from hermes-agent's
tools/skills_guard.py regex library plus the trust-level × verdict install policy.
Detection categories (one or more regexes per category):
SkillSecurityScanner.Category.EXFILTRATION— data exfiltration via curl/wget POSTSkillSecurityScanner.Category.INJECTION— prompt-injection markers in markdownSkillSecurityScanner.Category.DESTRUCTIVE—rm -rf /,mkfs,dd of=/devSkillSecurityScanner.Category.PERSISTENCE— crontab / systemd / shell-rc tamperingSkillSecurityScanner.Category.NETWORK— listen sockets / reverse shellsSkillSecurityScanner.Category.OBFUSCATION— base64 → bash, eval $(curl …), etc.
The scan returns a SkillSecurityScanner.Verdict (SAFE / CAUTION / DANGEROUS) plus the list of findings.
Callers (e.g. SkillManageTool, HarnessAgent.promoteSkill) consult
shouldAllow(TrustLevel, Verdict) to map verdict + provenance to an install decision.
This is intentionally a Java-side approximation, not a security boundary. Skills always
run inside whatever sandbox the host configured (see ShellExecuteTool); the scanner
is here to catch the obvious mistakes during authoring, NOT to replace the sandbox.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic final recordstatic final recordstatic enumstatic enumWhere the skill came from.static enum -
Method Summary
Modifier and TypeMethodDescriptionScan a complete skill: SKILL.md + every support file.scanSingleFile(String relPath, String content) Scan a single file (used afterwrite_file/patch).static booleanshouldAllow(SkillSecurityScanner.TrustLevel trust, SkillSecurityScanner.Verdict verdict) Map (trust × verdict) to an install decision.
-
Method Details
-
scan
public static SkillSecurityScanner.ScanResult scan(String skillName, String skillMd, Map<String, String> resources) Scan a complete skill: SKILL.md + every support file.resourcesis a map of relative path → content (matchingAgentSkill.getResources()). Returns the most severe verdict across all files. -
scanSingleFile
Scan a single file (used afterwrite_file/patch). -
shouldAllow
public static boolean shouldAllow(SkillSecurityScanner.TrustLevel trust, SkillSecurityScanner.Verdict verdict) Map (trust × verdict) to an install decision. Mirrors hermestools/skills_guard.py::INSTALL_POLICY.- Returns:
trueif writing the skill should proceed;falseif it must be blocked / rolled back.
-