Repository navigation
fix(tier1): scope SkillSpector agent-threat findings to agent control paths - #306
Conversation
… paths
Tier 1 security failed a skill on any SkillSpector agent-threat match,
including matches in files no agent reads or runs: operator-facing UI
strings, attack examples in docs/ or test fixtures, notebooks, images and
lockfiles. Those findings blocked directly when HIGH, and otherwise
through the aggregate risk-score gate.
For a detected skill, rules, workflows or plugin artifact, the security
check now classifies each reported file by role. Findings are kept on
agent control paths (instructions, references, executables and
scanner-marked executable components, agent configuration, MCP and plugin
manifests) and on any file those reference, followed transitively by a
bounded walk. Other findings are counted and suppressed, and they are
left out of the recomputed aggregate risk score.
SkillSpector can report identical matches from several files as one
issue whose location names one file and whose occurrences list all of
them. Each issue is classified by every one of those files and is
suppressed only when all of them are outside agent control paths.
The walk follows relative paths, bare file names of nested files,
directory names, Python and JS imports, -m module forms, plugin manifest
runtime fields, and skill or plugin root variables and placeholders
(${CLAUDE_SKILL_DIR}, $SKILL_DIR, $SKILL_ROOT, ${CLAUDE_PLUGIN_ROOT},
{baseDir}, <skill-dir>). A path with a directory also matches behind any
other prefix, such as an install path or a root-relative slash, and a
top-level file matches behind the artifact's own directory name.
References match without regard to case. A word check and a token and
segment-pair index skip searches that cannot match, so ordinary skills
with thousands of UI files finish the walk.
Classification fails closed when it cannot place a finding or finish the
walk. A missing location, or one that escapes the artifact through .. or
a symlink, and malformed occurrences keep their issue. A truncated
report, an unresolvable executable component, a symlinked directory, an
unreadable file, an unloadable manifest, an exhausted walk budget or an
unexpected classification error keeps every finding.
Supply-chain rules, YARA malware, webshell and cryptominer signatures,
and the AE2/AE3 artifact-integrity rules (content that does not match its
extension, text with embedded NUL bytes) stay blocking on every path. A
file named as a raster image takes the image role only when its content
has an image signature. Unknown layouts and the standalone security-scan
command keep the unrestricted scan.
The JSON report records a skillspector_applicability block per result,
kept findings carry artifact_type, file_role and applicability metadata,
and the terminal Tier 1 summary shows a filtered row.
Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
rng1995
left a comment
There was a problem hiding this comment.
Automated review: 11 findings (1 P1, 2 P2, 8 P3); 10 posted inline.
Findings outside the diff or about the description:
PR_DESCRIPTION: P3: The Tests section says the suites were run "On currentmain(with the 0.7.0 release), with the CHANGELOG entry under the new Unreleased / Fixed heading". This branch is based ona61e1f3f, which reverts the 0.7.0 release preparation (#302). That base has no## 0.7.0heading inCHANGELOG.md,pyproject.tomlis still at 0.6.0, and the repository has nov0.7.0tag. The## Unreleased/### Fixedsection is also not new: the revert restored it, and the entry is appended to it just above## 0.6.0. The numbers themselves look right:test_skillspector_scope.pyplustest_security.pystill gives 676 passed at the PR head. Only the wording is stale. As written, a reader may go looking for a 0.7.0 release that does not exist, or think the counts were taken on a different base.mainhas also moved on since then, for example to the SkillSpector v2.13.3 pin (#292).
Suggested fix: Drop "(with the 0.7.0 release)" and "new", and name the base the counts come from. For example: "On a61e1f3f (main after the 0.7.0 revert, #302), with the entry under Unreleased / Fixed". If you rebase onto the current main, rerun the suites and update the counts.
Conflicts: docs/tier1-validation.mdx (kept both the agent control paths and the LLM provenance sections). Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude Code loads .lsp.json, output-styles/ and monitors/monitors.json without any manifest entry, so the reference walk never reached them and their findings were suppressed as repository metadata or ordinary data. Classify them as agent executables and instructions, and also keep the Codex .app.json and the Codex and Cursor plugin manifests. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The fallback "from ... import" regex allowed newlines before "from", so a match attempt at every line start of a blank-line run scanned to the end of the run. One control file of about 1 MB of blank lines cost minutes of CPU before the character budget was charged. Whitespace before "from" may no longer include a newline. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
SkillSpector 2.11.2 writes and scores an identical match found in N files as N issues that share one finding_id. Once scoping suppressed an issue, the applicable score came from the reconciliation floor, which collapsed such a group to one finding and subtracted the rest as unknown findings from the kept issues. Six kept MEDIUM advisories (60) then passed at 50 or 40 when a suppressed match repeated in two or three docs files. When a 2.10+ report serializes exactly the findings it counted, also score the kept records directly with SkillSpector's per-rule weights and executable multiplier, without cross-file dedup or unknown findings, and gate on the higher of that and the reconciliation floor. Tests now cover 2.11.2-shaped reports, including the reconciliation of suppressed issues when the records do not line up with the count. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The "skillspector risk score" message was written from the raw score before scoping, so a passing scoped scan reported "100/100 (CRITICAL)" next to its success line. When scoping suppressed issues, write the message after the applicable score is known and label both scores. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
skillspector_applicability.reported_issues held the number of issues kept after scoping, not the number SkillSpector reported, next to a raw_risk_score that is the scanner's own value. Rename it to kept_issues before a release makes the JSON key a compatibility promise. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…them
The reference walk added each one-segment parent directory (docs, web,
tests, and skills for a bundled plugin skill) as a bare variant, so
ordinary wording such as "building a web page from the docs" or "works
with the other skills" made every file under that directory an agent
reference. A top-level directory name now counts only with a slash, a ./
prefix, or quoted as code or a string ("`policies`", "policies").
Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The per-file size limit, both artifact file-limit checks (directories during the walk and referenceable files) and the manifest traversal budget had no test, so replacing any of their fail-closed returns with pass left every test green. Each guard now has a case that fails when it is removed. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Ordinary-file row listed tests/ and UI code as suppressed, and the CHANGELOG named UI strings and test fixtures, but SkillSpector marks every .py, .js and .ts file executable. Those files are agent executables that seed the reference walk, so their findings and those of any fixture they name stay blocking. Narrow the row and the entry to non-executable files, say so explicitly, and pin the behavior with a test. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The docs said every top-level file other than READMEs, test files, notebooks, images and lockfiles is an agent reference, but top-level .rst documents and dotfiles that are not recognized agent files (such as .env) are suppressed too. Add them to the exceptions and add repository metadata to the Ordinary-file row; the role table test pins each case. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
chrisknvidia
left a comment
There was a problem hiding this comment.
Most of the earlier review points look fixed on this head. I read the scope module, the walk and the security.py wiring, and re-ran the new head against real SkillSpector reports. Two things reproduce and matter: a symlinked file is enough to hide a finding from the Tier 1 gate (SKILL.md symlinked to a docs/ file passes), and the web/*.tsx example the PR leads with does not pass on the SkillSpector release the repo installs, because .tsx is an executable suffix there.
The docs table row and the CHANGELOG entry both name .tsx as a suppressed UI file. Once the suffix list is checked against the pinned SkillSpector release, those two places need the same correction as the code comment above.
…rence walk - A reached symlink also reaches its in-root target, because SkillSpector reports matches under the real file's name. - Bare directory words and globs in code spans and fenced blocks reach the files the agent would expand them to; prose stays excluded. - Keep the static stage's skillspector_applicability block when the LLM stage runs; the LLM stage's block goes under skillspector_llm_applicability. - Docs and CHANGELOG: SkillSpector 2.12+ marks .tsx and other source suffixes executable, so only HTML, CSS, .vue and similar UI files are suppressed. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Narendran Raghavan <[email protected]>
Conflicts resolved in src/skillevaluator/validators/security.py and docs/tier1-validation.mdx. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The finding-8 change required a slash, a ./ prefix, or quotes around a
one-segment directory name in every source, so a script that ran
`find policies -type f -exec cat {} +` or `cd policies && cat *.md` no
longer reached policies/, and its prompt-injection findings were
suppressed. A bare top-level directory name, from the walk root and from
the enclosing skill root, now counts again when the referring file is
code (a source or shell suffix, an agent_executable role that is not a
prose file, or a SkillSpector executable component) in the same
namespace. Markdown and other prose keep the slash, ./ or quoted rule.
Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
_retained_skillspector_risk_score sorted each rule's contributions purely ascending, so a rule with mixed severities (such as P9 or TM1 emitting MEDIUM and LOW) gave its largest weight to a LOW finding. SkillSpector and legacy_score order by severity first, descending. Five such rules score 68.75 in SkillSpector but scored 50 here once any issue was suppressed, and the run passed. Contributions now sort by (-severity points, contribution), keeping the ascending lower bound only within a severity. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
chrisknvidia
left a comment
There was a problem hiding this comment.
Follow-up on the current head. The symlink fix works: with only an alias pointing at it, a finding on the target stays blocking. I also checked an alias chain (guide.md -> docs/mid.md -> docs/evil.md), which stays blocking, and a symlinked references/ directory, which fails closed. Globs and bare directory words in code spans now reach their files, including a nested match for docs/*.md. The static applicability block keeps its own key when the LLM stage runs, and the docs and CHANGELOG now match the executable suffixes in SkillSpector 2.12+. Nothing further from me.
Resolve conflicts with #300 (SkillSpector baselines): SecurityValidator takes content_type, skillspector_reference_root, and skillspector_baseline; Tier 1 security passes the agent-scope arguments and the baseline; the SkillSpector summary keeps both the baseline-suppressed message and the agent-control-path suppression note. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Narendran Raghavan <[email protected]>
The bridge_services fixture probes /healthz until the bridge answers. The probe's server worker can still be finishing after urllib has read the response, so under CI load a test could start with one worker already active. test_slow_drip_request_line_and_headers_obey_an_absolute_deadline then counted that worker next to its own connection and failed with 'assert 2 == 1' (seen on PRs #306 and #344). Wait for the bridge's workers to drain before yielding the fixture. Signed-off-by: Narendran Raghavan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
Tier 1
securitynow checks where each SkillSpector finding is before it blocks. SkillSpector rules describe attacks on an agent, such as prompt injection, tool abuse and exfiltration. A match only matters when it is in a file the agent reads or runs. For a detected skill, rules, workflows or plugin artifact, findings in other files are counted and suppressed, and they no longer fail the run.validators/skillspector_scope.py:skillspector_file_rolegives each reported location a role.scripts/test_x.shandprompts/x.svgare kept.normalize_report_pathresolves the scanner location against the scanned root. The location isunknown, and its finding is kept, when the file is missing, escapes the root through..or a symlink, is a drive path, contains control characters, or is the root itself.location. SkillSpector can report identical matches from several files as one issue, withlocationnaming one file andoccurrenceslisting all of them. The issue is suppressed only when every one of those files is outside agent control paths. Otherwise it is kept with the role of the file that keeps it.executablecounts as an agent executable. If an executable path does not resolve inside the artifact, nothing in that report is suppressed.referenced_report_pathsis a bounded reachability walk:helper.mdforlib/helper.md), Python and JS imports,-mmodule forms, and the runtime fields of plugin manifests. A reference may end a sentence (Read docs/threats.md.).${CLAUDE_SKILL_DIR},$SKILL_DIR,$SKILL_ROOTand${CLAUDE_PLUGIN_ROOT}, in shell, PowerShell and cmd forms. So are skill-directory placeholders whose name containsskillorbase({baseDir},{{skill_dir}},<skill-dir>). The placeholder name is length-bounded, so the substitution stays linear on adversarial text./) also matches right after a/, so it is found behind an install path, a root-relative/, or a placeholder the walk does not expand (~/.claude/skills/demo/docs/threats.md,/data/policy.md,<root>/web/prompt.txt). A top-level file also matches behind the artifact's own directory name (~/.claude/skills/demo/README.mdfor a skill indemo/). Bare file names still have to start a path, soother/helper.mddoes not reachlib/helper.md.DOCS/THREATS.mdreachesdocs/threats.md).agent_reference.scope_skillspector_issuescombines these for one report. Supply-chain rules (SC*), YARA malware, webshell and cryptominer rules (YR1–YR3), and the artifact-integrity rules for content that does not match its extension (AE2) and text with embedded NUL bytes (AE3) stay blocking on every path. YR4 and the lexical artifact-integrity rules (AE4,AE6) are scoped like the other agent-threat rules..png,.jpg,.gif,.webp,.ico,.avif) gets theimage_assetrole only when its content starts with an image signature. Otherwise its findings are kept asunverified_image, because the extension that would suppress them is the oneAE2calls misleading.unknown, or when itsoccurrencesfield is malformed (not a list, an entry that is not an object, or afilethat is not a string).analysis_completeness.findings_after_filtering, because the unserialized findings have no location.SecurityValidatorgainscontent_typeandskillspector_reference_root:_process_skillspector_cli_resultapplies the scope after the existing generated-artifact and SPDX filters.removed_issues, and the aggregate risk score is recomputed without them. Without recomputing the score, suppressed issues would still trip thescore > 50policy finding.artifact_type,file_roleandapplicabilitymetadata.skillspector_applicabilityblock: kept and suppressed counts, suppressed counts by role, and raw and applicable risk scores. Folder scans add up the per-skill blocks.tier1.run_validationpasses the detected type for skill, rules, workflows and plugin. For a plugin it also passes the plugin root as the reference root, so a bundled skill's${CLAUDE_PLUGIN_ROOT}/skills/<name>/...references and plugin-level hooks still reach the skill's files.unknownandNonekeep the unrestricted scan.run_security_scan(security-scan) is unchanged.skillspector_applicabilityper result.filteredrow.docs/tier1-validation.mdxsecurity section, including the cases that keep the unrestricted scan. CHANGELOG entry under Unreleased / Fixed.Why
A Tier 1 run failed a skill whenever SkillSpector matched in a file that no agent reads or runs. Common cases were an operator-facing UI string such as "ignore all previous instructions" in an HTML, CSS or
.vuefile underweb/, attack examples indocs/or test fixtures, and package text in a lockfile. The run failed through HIGH findings or through the aggregate risk-score gate. One example on SkillSpector 2.11.2: a skill whose only matches were indocs/threats.mdandweb/instruction_display.tsxfailed with a raw score of 81, and with this change passed with an applicable score of 0. OnceSKILL.mdnamesdocs/threats.md, or justthreats.md, the document's findings block again. The.tsxhalf of that example does not carry over to the SkillSpector release the repository installs: v2.12.0 and later mark.tsxexecutable, so its findings stay blocking asagent_executable(covered by a test).Tier 1 already runs separate code-risk, secrets, PII, dependency and Unicode checks on those files.
security-scanstays the unrestricted repository scan for broad investigation.Limitations
These keep the unrestricted scan for the whole skill, which is safe but means nothing is suppressed:
assets/guide.pdfortemplates/form.docx). An agent can read guidance in such a file, and the walk cannot follow references inside it.The walk follows references written as text. A file that a control file reaches only through a path built at run time (for example
"web/" + name) is not followed, and its findings are suppressed. A top-level file named behind a prefix that is neither a recognized root variable or placeholder nor the artifact's own directory name (for example<root>/README.md, or an install directory with a different name) is not followed either. Top-level files other than READMEs, test files, notebooks, images and lockfiles are agent references whether or not they are named, so this only affects those.Kept from public
_minimum_skillspector_risk_scoreare unchanged. Suppressed issues go through the existingremoved_issuesreconciliation, the same path generated-artifact and SPDX exemptions already use. The score policy gate that public added stays. It is now evaluated on the applicable score._is_generated_artifact_issueand exact SPDX exemption run first and are unchanged. That includes the SC8 bytecode carve-out.original_rootafter_rewrite_path_prefix, so staged copies withoutevals/outputs are classified against the real skill.unknowntargets like skills. They keep the unrestricted scan, because no agent control path can be established for them.ValidatorBase._validate_folder_or_skillis not changed. Per-skill counters are added up insideSecurityValidator, and no base-class hook is added.Left out on purpose:
scope_exclusionsto execution failures. Open PR feat(plugin): Add Plugin evaluation support across all tiers #28 accounts for these exclusions as advisory.run_validation. This depends on feat(plugin): Add Plugin evaluation support across all tiers #28's plugin-tree scan._render_successedits, and the success message already carries the count.Tests
tests/validators/test_skillspector_scope.py(278 tests):.., absolute outside, drive paths, control characters, missing file, root itself, escaping symlink, symlink loop, single-file targets.content_type=Nonestays unrestricted.SC*,YR1–YR3,AE2andAE3kept on every path.YR4,AE4andAE6scoped.assets/orweb/are suppressed as images. HTML or text named.pngor.jpgis kept asunverified_image, and is anagent_referencewhenSKILL.mdnames it.docs/but which also occurs inSKILL.mdis kept asagent_instruction. An occurrence in a referenced file is kept asagent_reference. An issue whose occurrences are all outside control paths is suppressed. Malformed, escaping and missing occurrences fail closed. A report with fewer occurrence records thanfindings_after_filteringfails closed.-m, backslash, transitive and relative-import references.${CLAUDE_SKILL_DIR},$CLAUDE_SKILL_DIR,$env:CLAUDE_SKILL_DIR,$SKILL_DIR,$SKILL_ROOTand${CLAUDE_PLUGIN_ROOT}(shell, PowerShell, cmd),{baseDir},{{skill_dir}}and<skill-dir>, for nested and top-level files.~/.claude/skills/demo/docs/threats.md,<skill-dir>/web/prompt.txt,/data/policy.md, a Windows install path, and~/.claude/skills/<artifact dir>/README.md. Case-insensitive matches (DOCS/THREATS.md,Helper.MD).docs/threats.md.bak,other/helper.md, the bare wordhelper,my-docs/threats.md,other-skill/README.md,~/.claude/skills/other/README.mdand<div>/README.md.from .. import, a${CLAUDE_SKILL_DIR}path in a different case, and a path behind an install prefix./-containing variants inside a token, three-segment variants, and bare names that must start a token..ttfwithout a font signature, fail closed.plugin.jsonwith an integer past Python's digit limit and anagent_plugin.yamlwith an invalid date (both fail closed), the plugin reference root,${CLAUDE_SKILL_DIR}in a bundled skill, and cross-skill root variables ($SKILL_ROOT,${CLAUDE_SKILL_DIR},{baseDir}).validate_security_onlywith mocked SkillSpector: scoped vs. general scan, staged scan with absolute staged paths, and folder totals. The checked-in SkillSpector 2.11.1 report, rewritten as a compacted issue with aSKILL.mdoccurrence and as a truncated report, fails the scoped scan. Also checked: the JSON report and thefilteredsummary row, andrun_validation/run_security_scanconstructor wiring for every content type./leading boundary (6),CLAUDE_SKILL_DIR(1), placeholders (3), lowercasing (8), the directory-name prefix (1),AE2/AE3(2), image verification (2), the manifestValueErrorhandling (2), the segment-pair prefilter (10), the classification guard (1), and the directory-name filter (1).mainatf878f99a(after the 0.7.2 release), with the CHANGELOG entry under Unreleased / Fixed:tests/validators/test_skillspector_scope.pyandtests/validators/test_security.py: 891 passed, 1 skipped.test_security.pyadds one test: the LLM stage keeps the static applicability block.tests/reporting,tests/cli/test_validate_defaults.py,tests/cli/test_tier_workflows.py,tests/cli/test_validate_plugin.py,tests/test_commands.py,tests/test_skip_checks.pyandtests/test_progress_output.py: 1,629 passed.${CLAUDE_SKILL_DIR}and install-path references): every walk finishes and suppresses the UI finding, in 0.3 to 1.5 seconds on a loaded machine.docs/andweb/matches pass with an applicable score of 0;SKILL.mdnamingdocs/threats.mdorthreats.mdkeeps the document's findings asagent_reference; Python sources stay blocking because SkillSpector marks them executable.ruff check,ruff format --checkon the changed hunks,scripts/check_oss_boundary.pyand Gitleaks (no leaks found) pass.🤖 Generated with Claude Code