Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/ANALYSIS_RESOURCE_BOUNDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,11 @@ When relevant analysis is incomplete:
- `skillspector scan --fail-on-incomplete` exits with status 1. Without this option, the CLI retains
its compatibility behavior and still applies its ordinary risk-score exit policy. Execution
failures exit with status 2.
- `skillspector scan --min-coverage PERCENT` exits with status 1 when canonical coverage is below
`PERCENT`; equality passes. Recursive scans check each scanned child's own coverage, not the
aggregate `analysis_completeness.coverage_percent`, and any omitted or unscanned skill fails a
positive threshold. Skills that discovery never found because it stopped early are not counted;
add `--fail-on-incomplete` to catch that case.
- MCP responses set `safe_to_install` to `false` when analysis is incomplete, any relevant file is
entirely uninspected, execution failed, or the risk score exceeds the installation threshold.

Expand Down
24 changes: 15 additions & 9 deletions docs/B.3.1-mcp-least-privilege.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,14 @@ to need.
code contains `httpx.post(...)`. LP1 fires for the undeclared `network`
capability.

**Remediation:** For Agent Skills `SKILL.md`, add a tool that covers the missing
capability to the `allowed-tools` frontmatter field. For MCP server manifests,
add the missing capability to the `permissions` list. Otherwise, remove the code
that requires it.
**Remediation:** Review whether the capability is required and how the host
runtime enforces it; runtime permissions are unknown unless separately
verified. Remove code that does not need the capability. For Agent
Skills `SKILL.md`, `allowed-tools` records tools preapproved for invocation; it
is not a permission ceiling. Add a tool only when it is independently approved
as necessary, not to silence this finding. For MCP server manifests, add the
required capability to the `permissions` list only after reviewing the actual
policy.

---

Expand Down Expand Up @@ -176,11 +180,13 @@ rather than deception) but still a significant transparency gap.
`allowed-tools:` key, but the code calls `os.environ["API_KEY"]` and
`subprocess.run(...)`.

**Remediation:** Declare the skill's tool scope in the manifest type you are
authoring. For Claude Code / Agent Skills `SKILL.md`, list the tools the skill
may invoke in the `allowed-tools` frontmatter field (`permissions` is not part
of the SKILL.md schema and is ignored). For MCP server manifests, add a
`permissions` list naming the required capabilities.
**Remediation:** Clarify the skill's intended tool scope and review how the host
runtime enforces it; runtime permissions are unknown unless separately
verified. For Claude Code / Agent Skills `SKILL.md`, `allowed-tools`
records tools preapproved for invocation, not a permission ceiling; add tools
only when independently approved as necessary, not to silence this finding
(`permissions` is not part of the `SKILL.md` schema and is ignored). For MCP
server manifests, use a `permissions` list naming the required capabilities.

---

Expand Down
4 changes: 2 additions & 2 deletions docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ There are no conditional edges: after `resolve_input` → `build_context`, all a
| **resolve_input** | Consumes `input_path` or `skill_path`; resolves URLs/zips/files via InputHandler; sets `skill_path` and (when needed) `temp_dir_for_cleanup` | [resolve_input.py](../src/skillspector/nodes/resolve_input.py) |
| **build_context** | Reads `skill_path`, populates `components`, `file_cache`, `ast_cache`, `manifest`, `component_metadata`, `has_executable_scripts` | [build_context.py](../src/skillspector/nodes/build_context.py) |
| **Analyzers** | 22 nodes; each returns `AnalyzerNodeResponse` (list of `Finding`). State reducer appends to `findings`. | [nodes/analyzers/__init__.py](../src/skillspector/nodes/analyzers/__init__.py) (`ANALYZER_NODE_IDS`, `ANALYZER_NODES`) |
| **meta_analyzer** | Per-file LLM filter/enrich of canonical `findings`; emits ordered `effective_finding_ids` for report selection. One LLM call per file (or per chunk for oversized files); token budgets from `constants.py`; falls back when `use_llm` is False. | [meta_analyzer.py](../src/skillspector/nodes/meta_analyzer.py), [llm_analyzer_base.py](../src/skillspector/nodes/llm_analyzer_base.py) |
| **meta_analyzer** | Per-file LLM filter/enrich of canonical `findings`; emits ordered `effective_finding_ids` for report selection. One LLM call per file (or per chunk for oversized files); token budgets from `constants.py`; falls back when `use_llm` is False. | [meta_analyzer.py](../src/skillspector/nodes/meta_analyzer.py), [llm_analyzer_base.py](../src/skillspector/llm_analyzer_base.py) |
| **report** | Applies baseline suppression (`state["baseline"]`), then builds SARIF 2.1.0, computes `risk_score`, `risk_severity`, `risk_recommendation` from the non-suppressed findings; writes `report_body` from `output_format` (terminal/json/markdown/sarif) | [report.py](../src/skillspector/nodes/report.py) |

---
Expand Down Expand Up @@ -354,7 +354,7 @@ Base URL env vars are not needed for live provider tests; the tests intentionall
- **LLM calls** ([llm_utils.py](../src/skillspector/llm_utils.py)): **`get_chat_model()`** and **`chat_completion()`** dispatch based on the active provider:
- **HTTP providers**: resolve credentials in two tiers — active provider (`NVIDIA_INFERENCE_KEY` / `ANTHROPIC_API_KEY` / `OPENAI_API_KEY` → endpoint) — against any OpenAI-compatible endpoint. `max_tokens` is auto-bound to `get_max_output_tokens(model)` from `model_info`.
- **CLI providers** (`claude_cli`, `gemini_cli`, `opencode_cli`): `get_chat_model()` returns an `AgentCLIChatModel` adapter backed by `provider.complete()`, so the analyzers' `.invoke()` / `.with_structured_output(schema).invoke()` calls work with no API key (structured output is produced by prompting for JSON, then Pydantic-validating). `chat_completion()` routes through `get_chat_model()` as well. `is_llm_available()` calls `provider.is_available()` instead of credential resolution.
- **LLM analyzer base** ([llm_analyzer_base.py](../src/skillspector/nodes/llm_analyzer_base.py)): `LLMAnalyzerBase` provides per-file/per-chunk batching, token-budget-aware chunking, and a run loop for all LLM-based analyzers. `LLMMetaAnalyzer` extends it for filter/enrich (meta_analyzer node). Future semantic analyzers extend `LLMAnalyzerBase` for discovery mode.
- **LLM analyzer base** ([llm_analyzer_base.py](../src/skillspector/llm_analyzer_base.py)): `LLMAnalyzerBase` provides per-file/per-chunk batching, token-budget-aware chunking, and a run loop for all LLM-based analyzers. `LLMMetaAnalyzer` extends it for filter/enrich (meta_analyzer node). Future semantic analyzers extend `LLMAnalyzerBase` for discovery mode.

---

Expand Down
31 changes: 31 additions & 0 deletions docs/NESTED_ARTIFACT_INSPECTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,37 @@ Nested members use a stable virtual path that retains their full provenance:
outer-file!/nested.zip!/scripts/setup.sh
```

## JSON component locations

JSON component rows preserve this virtual path in `path`, matching finding locations and
inspection-ledger entries. Archive members also expose their existing inventory provenance:

```json
{
"path": "bundle.whl!/package/module.py",
"type": "python",
"executable": true,
"outer_path": "bundle.whl",
"nested_path": "package/module.py",
"container_type": "zip",
"container_ancestry": ["zip"],
"container_depth": 1
}
```

`outer_path` names the physical container relative to that component's source root. `nested_path`
retains the full member chain inside it, including any nested `!/` boundaries. Each member keeps
its own component row, executable flag, type, line count, and byte size. Ordinary files do not gain
archive fields merely because their names contain `!/`.

Consumers must distinguish a virtual member from an on-disk file: `executable: true` describes
the member's content, not the existence of its virtual path on disk. Use the source identity and
full `path` to join components with findings; do not collapse members by `outer_path`. When
validating a report, check archive provenance and containment within the corresponding source
root, and retain incomplete-inspection failures. These additive fields do not change existing
consumer validators automatically, prove that every member was inspected, or justify extracting
or executing archive content.

## Security invariants

- Members are read in memory. SkillSpector never extracts, renders, imports, installs, or executes
Expand Down
20 changes: 20 additions & 0 deletions docs/release/skillspector-2.13.6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# SkillSpector 2.13.6

This maintenance release builds on v2.13.5 and corrects incomplete static inspection of complete JSON metadata containing bare shell-wrapper names.

## Fixes

- [#1123](https://github.com/NVIDIA/SkillSpector/pull/1123): Complete JSON values such as `{"name":"nice"}` and `{"keywords":["sudo"]}` no longer produce a false `static_parse_limit` / `command_word_boundary` diagnostic. Validated JSON value boundaries establish when a bare wrapper name has no operands. Command arguments, runtime-selected wrappers, consumed options, clipped inputs, and unresolved shell fragments retain their existing checks and incomplete-inspection diagnostics.

## Minor updates

- [#807](https://github.com/NVIDIA/SkillSpector/pull/807): Correct both development-guide links to the shared LLM analyzer base source module.
- [#423](https://github.com/NVIDIA/SkillSpector/pull/423): Document `--min-coverage` thresholds, recursive child coverage, and omitted-skill handling.
- [#685](https://github.com/NVIDIA/SkillSpector/pull/685): Correct least-privilege remediation guidance to require review of necessary capabilities and host enforcement before approving tools or changing permission declarations.
- [#816](https://github.com/NVIDIA/SkillSpector/pull/816): Document JSON archive-member provenance and how consumers should interpret virtual component locations.

## Scope and upgrading

Unsupported content, exhausted budgets, unprovable runtime behavior, and provider failures remain explicit inspection limitations. Existing consumers must continue to handle `complete_with_caveats` and review coverage diagnostics. Review version-bound baselines when upgrading.

GitHub release assets contain a wheel and source distribution. This workflow does not publish to PyPI.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "skillspector"
version = "2.13.5"
version = "2.13.6"
description = "SkillSpector: Security scanner for AI agent skills (Claude Code, Cursor, and similar). Scans skills for vulnerabilities, malicious patterns, and security risks before installation. Supports Git repos, URLs, zips, and local directories; runs static pattern checks and optional LLM semantic analysis; outputs terminal, JSON, and Markdown reports with risk scoring."
readme = "README.md"
license = "Apache-2.0"
Expand Down
31 changes: 31 additions & 0 deletions src/skillspector/nodes/analyzers/static_patterns_tool_misuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -4179,6 +4179,12 @@ def retain_operand_bounds(
if backtick_values
else {}
),
# A clipped view cannot prove that a wrapper has no following operands.
**(
{"json_value_ends": dict(json_value_spans)}
if complete_context and json_value_spans
else {}
),
):
command_string = command.content
if command_string is None:
Expand Down Expand Up @@ -4362,6 +4368,7 @@ def _shell_command_strings(
xargs_contexts: tuple[tuple[str, list[bool | None]], ...] = (),
json_key_starts: frozenset[int] = frozenset(),
json_value_starts: frozenset[int] = frozenset(),
json_value_ends: Mapping[int, int] | None = None,
) -> Iterator[_ShellCommandString]:
"""Yield bounded strings reparsed by ``eval`` or a shell ``-c`` wrapper."""
single_sources = (
Expand Down Expand Up @@ -4499,6 +4506,11 @@ def _shell_command_strings(
xargs_override_cache=xargs_override_cache,
xargs_source=content,
xargs_parent_contexts=xargs_contexts,
**(
{"native_word_end": json_value_ends[clause_start] - body_start}
if json_value_ends is not None and clause_start in json_value_ends
else {}
),
)
if nested_substitutions and startup_exposure[0]:
# Quoted substitutions can launch shells outside this clause walk.
Expand Down Expand Up @@ -5264,11 +5276,13 @@ def _command_string_from_clause(
command_operand_spans: list[tuple[int, int]] | None = None,
shell_command_only: bool = False,
require_command_identity: bool = False,
native_word_end: int | None = None,
) -> tuple[bool, str | None]:
"""Resolve a bounded wrapper chain to an ``eval`` or shell command string."""
cursor = start
pending: str | None = None
wrapper_seen = False
native_wrapper_end: int | None = None
last_word_start = start
word_start = [start]
xargs_replacements: set[str] = set()
Expand Down Expand Up @@ -5449,6 +5463,19 @@ def commandless_wrapper() -> tuple[bool, None]:
# this word selects the command an owned child actually executes.
return failed(ParserCause.RUNTIME_DEPENDENT, ParserCheck.COMMAND_IDENTITY)
command = word.casefold().rsplit("/", 1)[-1]
if (
native_word_end is not None
and last_word_start == start
and cursor == native_word_end
and command in {"sudo", "nice", "xargs", "timeout"}
and not any(
marker in word
for marker in (_DYNAMIC_SHELL_WORD_SENTINEL, _RUNTIME_SHELL_PARAMETER_SENTINEL)
)
):
# Remember a complete native name, but still resolve any following
# argv operands. Only an empty first operand read can use this end.
native_wrapper_end = native_word_end
if (
not wrapper_seen
and content[last_word_start:cursor] == word
Expand Down Expand Up @@ -5706,6 +5733,7 @@ def commandless_wrapper() -> tuple[bool, None]:
xargs_redirected = False
xargs_input_mode = False
for _ in range(_SHELL_COMMAND_STRING_ARGUMENTS):
operand_scan_start = cursor
if command == "xargs":
horizontal_gap()
here_string = re.match(r"(?:[0-9]+)?<<<", content[cursor : cursor + 32])
Expand Down Expand Up @@ -5748,6 +5776,7 @@ def commandless_wrapper() -> tuple[bool, None]:
return (
(False, None)
if _ends_wrapped_clause(content, cursor)
or (native_wrapper_end == operand_scan_start and cursor == len(content))
else failed(
ParserCause.BOUNDARY_UNRESOLVED, ParserCheck.COMMAND_WORD_BOUNDARY
)
Expand Down Expand Up @@ -5885,13 +5914,15 @@ def commandless_wrapper() -> tuple[bool, None]:
if command == "timeout":
wrapper_seen = True
while True:
operand_scan_start = cursor
option, limited = next_word()
if limited:
return failed()
if option is None:
return (
(False, None)
if _ends_wrapped_clause(content, cursor)
or (native_wrapper_end == operand_scan_start and cursor == len(content))
else failed(
ParserCause.BOUNDARY_UNRESOLVED, ParserCheck.COMMAND_WORD_BOUNDARY
)
Expand Down
Loading
Loading