Security scanner and plugin analysis
The scanner examines AI plugins and extension assets before they run or enter a marketplace. It discovers package roots, turns ecosystem-specific manifests into a common package view, runs applicable security and quality checks, evaluates findings against score and policy rules, and emits reports for people and automation. In Guard, related evidence can also inform runtime decisions for package requests, MCP servers, and newly seen plugins.
Scan lifecycle
The scan lifecycle turns a directory into a structured result. The same lifecycle supports one plugin, a repository marketplace, or a directory that contains packages from more than one ecosystem.
Target discovery
Target discovery decides whether the input is a single plugin or a collection of packages. A Codex marketplace root becomes a repository scan when its marketplace manifest can be read. Otherwise, the scanner asks the ecosystem adapters to find package candidates under the input path. Candidate paths are kept inside the scan root and duplicate candidates are removed before parsing.
The repository path has a second layer of discovery. Local marketplace entries become scan targets. Remote entries, invalid entries, unsafe source paths, and entries without a local plugin manifest are recorded as skipped targets instead of being scanned as local code.
flowchart TD
A[Input directory] --> B{Repository marketplace?}
B -->|Yes| C[Discover local marketplace targets]
B -->|No| D[Detect ecosystem package candidates]
C --> E[Parse package targets]
D --> E
E --> F[Run applicable checks]
F --> G[Build scan result]
The ecosystem adapters and their detection markers are described in Ecosystem detection and adapters. Harness adapters also distinguish an observed MCP server from a server that Guard can place behind its managed proxy. A Guard-created proxy is kept in inventory but is not wrapped again or treated as permission to use the original server.
References: src/…/scanner.py• L615-652 src/…/repo_detect.py• L44-137 src/…/detect.py• L11-46 src/…/mcp_servers.py• L65-88 src/…/mcp_servers.py• L193-220 src/…/managed_mcp_upstream.py• L23-36
Package parsing
Package parsing gives each detected asset a common description for the rest of the scan. A normalized package records its ecosystem, package kind, root, manifest, basic identity, declared components, and parse status. The check layer can therefore work from a stable package boundary while adapters handle differences between Codex, Claude, Gemini, Kimi, OpenCode, and DeepSeek Harness assets.
Parsing does not make an invalid manifest safe or complete. When an adapter cannot parse a manifest, it preserves that state so later checks and reports can show that the package was found but could not be fully understood.
References: src/…/types.py• L10-47 src/…/base.py• L99-110 src/…/opencode.py• L147-187 src/…/kimi.py• L99-158
Scan scope
The scanner reports either plugin scope or repository scope. A plugin result contains checks for one package. A repository result combines repository-level checks with the results for local plugins and also reports skipped marketplace targets. A mixed directory can include several ecosystem packages; its categories and package summaries retain enough path and ecosystem context to keep findings distinct.
Repository scoring is conservative. The result uses the lowest score among the package results and the repository-level categories when those categories exist. This keeps one weak package or repository control visible instead of allowing stronger packages to hide it.
References: src/…/scanner.py• L294-347 src/…/scanner.py• L350-612 src/…/models.py• L108-127
Check execution
Checks inspect the package manifest, declared components, source files, configuration, and repository controls. Each check returns a pass state, points, applicability, a message, and zero or more structured findings.
Check categories
The scanner groups checks by the risk or quality concern they address. Ecosystem-specific checks add package-shape validation, while shared checks cover controls that apply across package types.
| Category | Purpose |
|---|---|
| Manifest validation | Confirm that required identity, metadata, interface data, and declared paths are usable and safe. |
| Security | Look for secrets, unsafe MCP settings, approval bypasses, disclosure guidance, and license signals. |
| Operational security | Review automation permissions, immutable action references, privileged workflows, dependency updates, and dependency locking. |
| Best practices | Check basic documentation, ignored files, environment files, and declared skill structure. |
| Marketplace | Validate marketplace shape, policy data, and local source paths when a marketplace is present. |
| Skill security | Review declared skills with optional Cisco analysis and local instruction checks. |
| Code quality | Look for dynamic code execution and shell-injection patterns in supported source files. |
The detailed check families and rule behavior are described in Scanner security checks and rules.
References: src/…/scanner.py• L247-291 src/…/manifest.py• L490-501 src/…/security.py• L733-741 src/…/operational_security.py• L339-346
Applicable checks
The scanner does not treat every absent asset as a failure. A check can be not applicable when its target is absent, such as an MCP configuration, a skill directory, a workflow, or a dependency manifest. Not-applicable checks contribute no points and explain why they were skipped.
Optional Cisco skill and MCP scans add external findings only when their target exists and the selected scan mode permits execution. The scanner runs these third-party tools in a bounded process with a scrubbed environment, a temporary working directory, closed input, limited output, resource limits, and a time limit. The process boundary also validates the executable and contains its process group so a child scanner cannot extend the scan beyond its limits. Their status is reported with the native check results so an unavailable, failed, or timed-out tool is not confused with a clean scan.
The shared native scanner also applies bounded work to sensitive-value detection. It scans one text value or a stream of chunks, keeps context across chunk boundaries, and reports bytes scanned, chunks scanned, match state, and the reason for an early stop. A local-content retry suppresses clear fixture values, including values that only repeat their credential field name, but does not suppress realistic values merely because they appear near test or documentation text.
References: src/…/models.py• L45-56 src/…/skill_security.py• L36-63 src/…/mcp_security.py• L22-48 src/…/scanner_subprocess.py• L96-181 src/…/scanner_subprocess.py• L246-287 src/…/scanner.py• L42-126 rust/…/lib.rs• L437-549 rust/…/self_named_value.rs• L41-94
Check results
Each check is a small decision unit. It reports whether the condition passed, how many points it earned, the maximum applicable points, and the evidence that explains a failure. Findings remain attached to the check and are also collected into the top-level result for sorting, policy gates, and report output.
The scanner creates categories first and then flattens their findings. This preserves both views: engineers can move from a high-level category to the check that produced the evidence, while automated consumers can process one common findings list.
References: src/…/models.py• L45-64 src/…/scanner.py• L250-277 src/…/reporting.py• L121-165
Rule evaluation and scoring
Rule evaluation gives findings stable meaning across the scanner, lint commands, policy profiles, and reports. Scoring measures the share of available check points. Policy evaluation then decides whether the findings and executed rules meet the selected review profile.
Rule specifications
The rule registry is the source of stable rule metadata. A rule specification links an identifier to its category, default severity, score weight, documentation slug, remediation text, and whether a safe fix exists. Findings carry the identifier; consumers use the registry to explain the rule or determine its policy role.
The registry is separate from check execution. A check detects a condition and emits a finding. The registry describes that finding for downstream tools. This separation lets lint and policy commands reason about known rules without duplicating detection logic.
References: src/…/specs.py• L10-26 src/…/registry.py• L8-16 src/…/registry.py• L44-101
Score calculation
The raw score is the rounded ratio of earned points to maximum points across applicable checks. The scanner maps the score to a grade from A through F. In command use, suppression, enabled-rule, disabled-rule, and severity settings can produce an effective score that is shown beside the raw score in JSON output.
Repository results use the conservative scope rules described above. A score is a quality signal, not a replacement for the finding list or the policy result.
References: src/…/scanner.py• L129-132 src/…/models.py• L130-140 src/…/_scanner_commands.py• L97-124
Policy evaluation
Policy evaluation checks more than the number of findings. A policy profile sets a maximum allowed severity, rules that must have executed, rules that must pass, and a minimum score. The evaluation records the highest observed severity and each missing or failed requirement so a blocked run has a clear reason.
The command layer runs the scan, applies configured suppressions and severity changes, builds the executed-rule inventory, evaluates the profile, and then replaces the displayed score with the effective score. The default, public-marketplace, and strict-security profiles express different acceptance levels.
References: src/…/policy.py• L10-35 src/…/policy.py• L37-81 src/…/policy.py• L85-140 src/…/_scanner_commands.py• L108-124
Findings and reports
Findings are the scanner's main evidence record. A finding identifies the rule, severity, category, title, description, remediation, source, and optional file and line location. The result also keeps counts by severity and integration status so people and automation can see both risk and scan coverage.
Finding records
Native checks and external scanners use the same finding shape. External findings retain their source name, while native findings use the scanner's native source. Findings without a file location can describe package or integration state; file-backed findings point reviewers to the affected asset.
The scanner orders findings from critical to informational severity for report presentation. A severity threshold can independently make the command fail when a finding reaches or exceeds that threshold.
References: src/…/models.py• L11-43 src/…/models.py• L155-169 src/…/reporting.py• L11-13 src/…/reporting.py• L380-386
Runtime evidence
Guard can carry scanner evidence into decisions that control package and extension use. Package intent is parsed by the resident, package evaluation owns the signed policy and fail-closed decision, and persisted evidence is passed to native validation rather than being interpreted by a second local rule set. A package whose name cannot be identified is blocked instead of receiving approval for a different package.
Harness adapters extend this path from package evidence to runtime assets. The adapter registry resolves names and aliases to either a Python adapter or a native-runtime adapter. Native adapters cover several harnesses and let the resident own detection, install plans, launch settings, runtime probes, and approval flow. Detection can also add workspace AI BOM data; AI BOM and agent inventory describes that inventory view.
MCP adapters apply the same separation to server assets. Cursor and Hermes can discover configured servers and related hooks, retain source scope, and route managed local servers through Guard proxies. A Guard-created proxy remains inventory data and is not wrapped again or treated as permission to use the original server.
Adapter lifecycle state can name configuration and backup paths, so Guard authenticates that state through the native runtime before it changes files. Install checks runtime availability before its first write. A missing or invalid authentication result cannot authorize a stored path; an unavailable runtime travels as an error instead of becoming a false ownership verdict.
Hooks without a daemon-native entry point use a bounded bridge. The native runtime makes and renders the hook decision, while the bridge passes input through a deadline-limited process. Missing runtime, failed execution, or a late answer fails closed.
For Codex, the native hook state is also part of the runtime protection decision. The PreToolUse and PermissionRequest hooks form the authoritative complete-command boundary for launch, while prompt and post-tool hooks complete the managed hook set. Codex launch and install paths fail closed when the authoritative hooks are missing, disabled, or fail integrity verification. Native install planning also decides which legacy Guard shell blocks and MCP proxy entries are safe to remove; malformed planning answers refuse the change.
References: src/…/local_supply_chain.py• L169-195 src/…/local_supply_chain.py• L441-473 src/…/local_supply_chain.py• L504-564 src/…/native_context.py• L931-965 src/…/__init__.py• L12-65 src/…/native_harness.py• L29-40 src/…/native_harness.py• L158-183 src/…/cursor.py• L95-152 src/…/hermes.py• L346-370 src/…/adapter_state_integrity.py• L26-63 src/…/adapter_state_integrity.py• L66-133 src/…/bounded_cli_hook_bridge.py• L294-332 src/…/mcp_servers.py• L193-220 src/…/managed_mcp_upstream.py• L23-36 src/…/codex.py• L1143-1203 src/…/codex.py• L1225-1265 src/…/codex_install_plan.py• L28-79
Registry trust
New or changed skills, MCP servers, and plugins can receive a public registry trust score before a fresh policy decision. The lookup sends only the artifact kind and public name to Guard Cloud. The native runtime owns the cache and interprets the reply, so an unknown, ambiguous, unavailable, or malformed result can add a review but cannot remove an existing protection.
References: src/…/registry_trust.py• L1-22 src/…/registry_trust.py• L68-103 src/…/registry_trust.py• L111-151
Report formats
Report generation converts one ScanResult into formats suited to different readers. JSON is the stable machine-facing shape. Markdown gives a short human summary. SARIF maps findings to rules and locations for code-scanning systems.
The JSON payload includes scope, raw and effective scores, grade, ecosystems, detected packages, severity counts, integrations, trust data, categories, findings, timestamp, and scan path. Trust data records the total plus domain and adapter provenance when available. Repository payloads also include local plugin summaries and skipped targets. The scan-result.v1 schema defines the contract for consumers.
Markdown shows the score, grade, trust score, ecosystem, category totals, top findings, trust provenance, and integration status. SARIF keeps one rule entry per finding rule and adds file locations when a finding has one.
The broader product can also send bounded package-coordinate evidence to Guard Cloud. This is downstream evidence, not a replacement for the local report or its complete finding list.
References: src/…/reporting.py• L16-70 src/…/reporting.py• L73-206 src/…/reporting.py• L233-304 src/…/reporting.py• L307-377 schemas/scan-result.v1.json• L1-147 src/…/workspace_assessment_sync.py• L78-115 src/…/workspace_assessment_sync.py• L166-205
Command outcomes
The scan command can write text, JSON, Markdown, or SARIF. A report can be successful while still containing findings; the command exit status is controlled by score thresholds, severity thresholds, strict mode, and policy evaluation. This lets a workflow collect evidence without always turning every advisory into a blocking failure.
References: src/…/_scanner_commands.py• L127-190 src/…/reporting.py• L209-230 src/…/reporting.py• L380-386
Change checklist
When these files or sections are changed, remember to consider these:
- Keep adapter detection markers, normalized package fields, and the
ecosystemsandpackagesreport fields aligned. A new package kind that is detected but not parsed can silently lose identity or component data. - Keep check-produced rule IDs aligned with the rule registry and policy profile requirements. A typo can turn a real finding into an unknown rule or make a required rule appear unexecuted.
- Keep
Findingfields aligned with the JSON and SARIF serializers. File paths and line numbers are used by both human reports and code-scanning consumers. - Preserve the distinction between not-applicable checks, skipped marketplace targets, and failed checks. These states affect score denominators, policy gates, and coverage signals.
- When adding an external scanner, propagate its status, finding source, finding count, and unavailable or failed behavior through both integration results and policy-facing checks. Also keep its process timeout, output bound, environment scrub, and report status aligned.
- When changing the external process boundary, keep executable validation, temporary working directories, input closure, resource limits, process-group containment, and platform-specific lockdown behavior aligned with the integration status that reaches reports.
- When changing repository aggregation, verify that plugin findings are rebased to repository paths and that skipped targets remain visible in repository reports.
- When changing report fields or trust provenance, keep the JSON schema and all human and machine report views aligned.
- Keep the native scanner's chunk overlap, byte and deadline limits, early-stop reason codes, and sensitivity handling aligned with callers that interpret partial scans.
- Keep fixture and documentation suppression narrow. Values that include real-looking or deployed markers must remain findings even when nearby text looks like a sample.
- Keep package intent parsing, package artifact evaluation, execution context evidence, and the approval hash bound to the same package and launch identity. Presentation-only command options must not change the approval identity, while options passed to a downstream program must remain exact.
- Keep the adapter registry, aliases, native adapter descriptions, and harness-specific operations aligned. A name that resolves locally but is absent from native descriptions can fail only when discovery or install starts.
- Keep adapter manifests, authenticated path fields, and install or uninstall recovery behavior aligned. A lifecycle change must not write configuration before the runtime can authenticate the state it will later restore.
- Keep bounded hook commands, native runtime selection, deadline propagation, and fail-closed output aligned. A bridge must not evaluate a hook locally or forward an answer after its deadline.
- Keep MCP discovery, native server selection, stable identity, proxy environment filtering, and proxy argument parsing aligned. Inventory of a Guard-managed proxy must not become permission to wrap it again.
- Keep Codex hook state, integrity status, and launch gating aligned. The authoritative
PreToolUseandPermissionRequestboundary must remain required wherever Codex is launched or installed. - Keep Codex native install-plan answers aligned with shell-block removal and managed-proxy detection. Malformed or incomplete answers must stop cleanup rather than fall back to local guesses.
- Keep registry trust lookup failure behavior fail-open only for the optional review signal. An unknown or unavailable score must never clear a local policy decision, and the wire request must remain free of paths and credentials.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A plugin manifest is missing or cannot be parsed | Manifest checks fail or become unable to validate required fields. Dependent skill checks can become not applicable. | Keep manifest validation ahead of dependent checks and preserve explicit findings for missing or invalid manifests. |
| A marketplace entry is remote, malformed, unsafe, or points to a missing local manifest | The entry is not scanned as local code and appears in skippedTargets. | Treat skipped targets as report data and review them instead of interpreting the local plugin count as full marketplace coverage. |
| A declared skill or MCP path is outside the package root | The related external scan is skipped to avoid scanning outside the target. | Use in-root path checks before resolving or passing files to a scanner. |
An optional Cisco scanner is unavailable while its mode is on | The availability check fails with a low-severity integration finding. | Install the integration dependencies or select a mode that does not require the external scan. |
| An external scanner exceeds its time or output bound | The integration reports a timeout or failure instead of allowing an unbounded child process or report payload. | Run third-party scanners through the bounded process wrapper and review its integration status. |
| An external scanner uses a non-absolute or unavailable executable, or the host cannot provide its required process containment | The external scan cannot start and its result is not a clean scan. | Validate the executable before launch and treat process-boundary errors as integration failures. |
| The native scanner reaches its deadline or byte limit | The result is partial and carries an exhaustion reason instead of claiming a complete clean scan. | Propagate budget_exhausted and reason_code to the caller and treat partial coverage as review data. |
| Sample suppression treats a realistic deployed value as a fixture | A real credential can disappear during the local retry. | Require field-name stand-ins to remain short and self-named, and reject deployed markers, interpolation, and long secret-like runs. |
| A required rule is disabled or never executes | Policy evaluation fails even when the remaining findings look clean. | Review enabled and disabled rule settings and the profile's required execution list together. |
| A finding reaches the selected severity threshold | The command exits with failure even if the score is above its minimum. | Inspect the sorted findings and use a threshold that matches the documented review policy. |
| A native harness adapter cannot answer or returns an invalid plan | Detection or lifecycle work stops instead of applying an unverified path or configuration change. | Keep native authority errors and malformed answers fail closed. |
| Adapter state authentication is unavailable before install | Guard refuses the lifecycle change before it writes a configuration file, avoiding state that cannot be restored safely. | Require the adapter-state runtime before the first write. |
| Stored adapter state has no valid authentication result | Guard cannot trust its recorded configuration or backup path, so normal ownership and restore actions do not proceed from that state. | Treat missing or invalid authentication as untrusted state and use the adapter's explicit recovery path. |
| A bounded hook has no native runtime, fails to start, or returns after its deadline | The hook emits a failure decision instead of allowing an unverified action. | Keep the native runtime as the decision maker and enforce the end-to-end deadline. |
| The resident cannot parse a package request or its evaluation is unavailable | The package firewall fails closed instead of allowing an unreviewed install. | Treat native package authority errors as protection failures and retry after the resident is healthy. |
npm configuration adds an unnamed package to an npx request | Guard blocks the request because approval could name a different package. | Name the package explicitly or make the package setting readable before retrying. |
| A Guard-managed MCP proxy is discovered as a normal local server | The adapter can recurse into its own proxy or confuse inventory with permission. | Recognize verified Guard companion names and exclude them from managed-server selection. |
| Codex hooks are disabled, incomplete, or fail manifest integrity verification | Guard refuses to launch or complete the Codex install because the authoritative command boundary is unavailable. | Repair the managed native hooks with hol-guard install codex or hol-guard update before retrying. |
| Codex native install planning returns malformed ranges or proxy names | Guard refuses the cleanup instead of guessing which user file bytes or server entries it may remove. | Validate the complete native answer and keep cleanup dependent on that answer. |
| Registry trust lookup cannot identify a unique score | No trust review is added, but an existing local decision remains unchanged. | Treat missing trust as unknown and rely on the normal policy and finding path. |
Key files
| File | Why to read it |
|---|---|
| src/…/scanner.py | Primary lifecycle coordinator for discovery, package scans, repository aggregation, scoring, and result construction. |
| src/…/repo_detect.py | Defines how a Codex marketplace becomes local scan targets and how skipped entries are recorded. |
| src/…/detect.py and src/…/types.py | Show the boundary between ecosystem detection and the common package model. |
| src/…/manifest.py | Shows how manifest validity and declared paths establish the package's basic trust boundary. |
| src/…/security.py | Shows the core security checks for secrets, MCP configuration, approval defaults, and disclosure assets. |
| src/…/skill_security.py and src/…/mcp_security.py | Show how optional external analysis becomes normal check results and integration status. |
| src/…/scanner_subprocess.py | Defines the validated, bounded, and isolated process boundary for optional third-party scanners across supported operating systems. |
| rust/…/lib.rs | Defines the shared bounded sensitive-value scan and its early-stop result state. |
| rust/…/self_named_value.rs | Defines the narrow allowance for credential values that only repeat their field name in fixtures. |
| src/…/registry.py and src/…/policy.py | Define stable rule meaning and the policy gates that consume findings. |
| src/…/reporting.py | Defines the JSON, Markdown, and SARIF views of a scan result, including trust provenance. |
| schemas/scan-result.v1.json | Defines the machine-facing JSON contract for downstream consumers. |
| src/…/local_supply_chain.py | Connects package discovery and evidence to resident-owned policy evaluation and protected launch decisions. |
| src/…/__init__.py and src/…/native_harness.py | Define harness name resolution and the native adapter family used for discovery, lifecycle plans, and runtime evidence. |
| src/…/adapter_state_integrity.py | Defines authenticated adapter lifecycle state and the fail-before-write behavior. |
| src/…/bounded_cli_hook_bridge.py | Defines the bounded, native-runtime-backed hook path for harnesses without a daemon-native hook. |
| src/…/mcp_servers.py and src/…/managed_mcp_upstream.py | Define MCP server inventory, managed-proxy selection, identity inputs, and launch argument boundaries. |
| src/…/cursor.py and src/…/hermes.py | Show harness-specific discovery, MCP proxy setup, hook lifecycle, and runtime evidence integration. |
| src/…/codex.py and src/…/codex_install_plan.py | Define Codex native hook state, authoritative launch checks, and native decisions for legacy cleanup and managed proxies. |
| src/…/registry_trust.py | Defines optional public registry trust lookup and its conservative failure behavior for new or changed artifacts. |
| src/…/native_context.py | Shows how persisted package evidence and MCP identity inputs cross into native authority. |
| src/…/workspace_assessment_sync.py | Shows how bounded package-coordinate findings can be prepared for downstream cloud assessment. |