Introducing a new way to review your PRs.

Read the announcement

hashgraph-online / hol-guard

Open-source antivirus and firewall for AI agents: block risky tools, secret access, prompt injection, malicious packages, MCP servers, plugins, and skills at runtime.

View on GitHub

44 documents · Updated Nov 23, 2026

docs / secret-read-risk-controls

Secret-read risk controls

Guard decides whether a shell command or file-tool request can expose local secret material. It binds the request to its workspace and execution context, applies a minimum risk floor, and records safe evidence before the wider decision path permits, pauses, contains, or blocks the action.

Request classification

Read request boundary

The read request boundary separates an actual file or data read from text that only mentions a secret. Shell readers, direct file tools, searches, listings, and structured queries share one sensitive-data boundary while keeping their action type.

The same boundary also covers file-tool writes that place a live-looking credential into a file. Guard scans each body and joins replacements aimed at the same destination, including paths that are lexically equivalent, so a name in one piece and its value in another piece are reviewed together. Patch additions receive the same check. Large or incomplete bodies remain reviewable instead of being treated as safe.

References: rust/…/mod.rs• L350-372 rust/…/literal_secrets.rs• L236-409

Secret shape classes

Guard uses both known secret shapes and context around a value. It recognizes private keys, tokens, bearer values, credential URLs, and other strong forms. It also reviews values that look random when a nearby name or code construct identifies them as a key, token, password, or secret.

The classifier avoids treating common non-secrets as credentials. Placeholders, readable words, IDs, timestamps, UUIDs, repeated filler, digests, and metadata names do not create a secret finding without a stronger signal. This keeps the control focused on material that can plausibly grant access.

References: rust/…/literal_secrets.rs• L53-100 rust/…/literal_secrets.rs• L168-234 rust/…/literal_secret_bare.rs• L163-201

Code literal classes

Code can name a secret indirectly through the operation that receives it. Guard reviews random-looking values passed to credential setters, dashed credential groups, long tables named as keys, authentication tokens in comments, and noisy dashed values under API-key names.

The surrounding code must support the secret meaning. A setter for a name or endpoint is not enough. Repeated values, keyboard runs, ordinary words, UUIDs, and generic hex data remain outside this class unless another signal identifies them as live credential material.

References: rust/…/literal_secret_code.rs• L1-20 rust/…/literal_secret_code.rs• L40-48 rust/…/literal_secret_code.rs• L133-143 rust/…/literal_secret_code_tests.rs• L8-45

Execution context

Workspace and home binding

Path risk has meaning only when Guard knows the effective directory, workspace, and shell home. Relative paths and home forms must resolve to the same declared locations that the shell or tool will use. Link targets and missing path tails stay part of the proof so a safe spelling cannot hide a different target.

References: rust/…/mod.rs• L6-50 rust/…/directory_targets.rs• L43-109 rust/…/directory_targets_home_variable.rs• L11-117

Shell flow context

Guard treats directory changes, pipelines, lists, loops, package-manager directory flags, and worktree chains as one request context. It accepts a rewritten form only when it preserves the reads and directory identity of the original. An unresolved expansion, glob, loop, or filter does not become a safe guess.

The same context must reach classification and contained execution. This prevents the enforcement sink from running a different directory or checkout than the one covered by the risk floor.

References: rust/…/segment_proof_cwd.rs• L8-112 rust/…/package_directory_flags.rs• L1-10 rust/…/contained_wrapper_plan.rs• L79-123

Launch and environment context

Environment and launch settings can change which files, programs, helpers, or endpoints a request reaches. Guard keeps settings that affect search paths, loaders, registries, credentials, proxies, configuration, or endpoints in the review context. It projects a setting only when the contained launcher makes its effect bounded.

Git receives the same treatment because its configuration can select helpers, filters, pagers, credential paths, or other programs. Missing or incomplete evidence leaves the relevant question open rather than creating permission.

References: rust/…/inert_tool_settings.rs• L20-23 rust/…/env_prefix_reviewed.rs• L123-160 rust/…/git_helper_context.rs• L196-236 rust/…/git_probe.rs• L108-176

Risk floors

Sensitive-read floor

A sensitive read creates a minimum action and reason for the decision layer. The floor can come from direct file access, a shell reader, a search that may select a secret, a structured query, or a write that puts a credential into the workspace and later tools can expose it.

The floor is monotone. Stronger command, policy, data-flow, helper, or execution signals can raise the result. A clean pattern match or old approval cannot lower it unless it matches the current request and authority.

References: rust/…/mod.rs• L350-372 rust/…/segment_proof.rs• L350-381 rust/…/literal_secrets.rs• L411-429

Git read floor

Git read review covers the named path and the configuration that Git may use before it reads. Guard distinguishes a probe that found an unsafe helper from a probe that could not answer. Approval can answer an open question, but it cannot make a known unsafe helper safe.

An earlier allowed Git step carries a later read only while configuration, worktree, output target, and checkout route remain stable. A changed checkout or worktree is checked again in its new context.

References: rust/…/git_config.rs• L36-85 rust/…/git_read_after_allow.rs• L204-290 rust/…/worktree_add_chain.rs• L145-183

Containment floor

Containment is an enforcement result, not proof that a read is harmless. Guard can route a reviewable local action to a workspace boundary that blocks network, home access, credential paths, and unsafe execution while preserving the intended local work.

The route stays narrow. Unsupported shell shapes, file-reading output filters, unsafe scripts, broad removal, missing extension evidence, and uncertain checkout or program lookup keep the request in review. The sink uses the same wrapper and root plan as classification.

References: rust/…/workspace_contained.rs• L1-7 rust/…/workspace_contained.rs• L508-673 rust/…/contained_output_filters.rs• L1-9 rust/…/sink_peel.rs• L89-100

Native decision precedence

Guard applies explicit native outcomes before general read classification. A malformed command decision blocks the request. A known dangerous action remains blocked. A benign command result can pass only when no separate structured path or query raises the risk.

This ordering keeps command text separate from other inputs in one tool call. A safe command decision does not prove that an independent file path, query, or data source is safe.

References: rust/…/generic_evaluate.rs• L27-43 rust/…/generic_evaluate.rs• L184-223 rust/…/generic_evaluate.rs• L428-486

Privacy-preserving evidence

Request evidence

Guard records the reviewed request before enforcement so policy, approval, containment, and audit paths use one action identity. The record carries the action class, reason, parse confidence, effective directory, workspace, launch facts, and identities needed to bind a later decision to the same request.

Evidence is bounded. Missing, malformed, stale, or mismatched authority data is recorded as unavailable or unsafe evidence. Guard does not replace that uncertainty with a local guess.

References: rust/…/generic.rs• L278-345 rust/…/git_probe.rs• L53-70 rust/…/worktree_add.rs• L32-45

Safe summaries

Guard stores enough information to explain and bind a result without copying secret contents into approval or audit records. It uses redacted command summaries, safe path identity, bounded metadata, and opaque identities for scripts or launch inputs. A digest can show that the reviewed script is the same script without disclosing its text.

This evidence boundary does not make command output safe. A permitted or contained read can still produce sensitive bytes, so runtime output handling and the agent-facing boundary need their own controls. See Runtime hooks, proxies, and shims.

References: rust/…/contained_output_filters.rs• L96-121 rust/…/contained_sed_script.rs• L17-41 rust/…/workspace_contained_sibling.rs• L1-10

Approval identity

Approval reuse binds to the full reviewed context rather than to a secret-path label. Workspace, directory, command shape, executable and wrapper facts, script or checkout identity, environment inputs, and enforcement route must still agree.

This prevents an approval for one checkout or launch from authorizing a changed program, search path, worktree, or execution boundary. See Approval gates and scope resolution.

References: rust/…/worktree_add_chain.rs• L145-183 rust/…/worktree_add_search_path.rs• L8-36 rust/…/workspace_contained_sibling.rs• L21-30

Control flow

The flow below shows how Guard turns a shell or file-tool request into a context-bound risk floor and an enforceable result.

flowchart LR
    A[Shell or file-tool request] --> B[Canonical request]
    B --> C[Workspace and launch context]
    C --> D[Read and secret classification]
    D --> E[Bounded path, query, helper, and body checks]
    E --> F[Minimum risk floor]
    F --> G[Safe evidence and current policy]
    G --> H{Guard result}
    H -->|allow or warn| I[Permit at runtime boundary]
    H -->|review or reapproval| J[Pause for scoped authority]
    H -->|sandbox-required| K[Run in contained boundary]
    H -->|block| L[Prevent normal execution]

The final decision belongs to Guard decision and enforcement. This page describes the secret-read inputs that decision must preserve.

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep direct reads, shell readers, searches, listings, structured queries, and credential-bearing writes on one sensitive-data boundary.
  • Keep code-literal checks tied to the code construct that gives a value its credential meaning. Do not let metadata names, IDs, UUIDs, digests, or filler raise the floor without a stronger signal.
  • Keep joined file-tool replacements and patch additions within the same scan and destination-file limits.
  • Keep canonical path resolution aligned with home expansion, logical cd, symlinks, missing tails, and workspace roots.
  • Keep the classifier rewrite and containment sink peel identical for wrappers, package directories, worktrees, redirects, status tails, and output filters.
  • Keep environment projection limited to settings that cannot change program lookup, code loading, credentials, configuration, or endpoints.
  • Keep Git probes tied to the stamped environment, routed checkout, effective configuration, and bounded output.
  • Keep containment refusal and missing evidence at review. Do not turn an unsupported shape into an allow or a different sandbox plan.
  • Keep evidence redacted and identity-bound. Do not add raw command, file, script, helper, or tool output to review records.
  • Keep approval and receipt identity aligned with workspace, checkout, launch, environment, and execution-boundary changes.
  • Keep exact native safe-read proofs limited to the target and tool shape that the authority checked.
  • Keep command authority results scoped to command text. Do not let a benign command decision erase an independent structured read risk.

Important failure modes

TriggerConsequenceGuard
A credential is split across file-tool replacements or patch rows.A live-looking value can enter the workspace without a full secret check.Join text for the same destination and keep incomplete or oversized bodies in review.
A code literal matches a broad name but is a placeholder, ID, UUID, digest, or filler.Ordinary code can receive an unnecessary secret floor.Require the surrounding credential construct and a live-looking value shape.
A path is resolved from an unknown directory or shell home.The check may describe a different file from the one the shell opens.Keep the context unresolved and require review.
A glob, recursive walk, or structured query can reach another file or credential store.A bounded read can become an unreviewed second read.Admit only input-bound forms and refuse ambiguous reach.
Git configuration or its probe result is unsafe, missing, oversized, or stale.A Git read can start a helper, pager, filter, or credential path outside the reviewed model.Keep the Git floor and distinguish found risk from unanswered probes.
The containment sink peels a different command from the classifier.The sandbox may execute work no receipt or floor covered.Share the peel grammar and refuse unsupported wrapper shapes.
A benign command decision covers a separate structured path or query.One tool call can access sensitive data outside the proved command text.Keep independent structured sensitive access at review.
Evidence stores raw paths, scripts, command text, or output.Secret material can leak through approval or audit records.Store redacted summaries, safe identities, bounded metadata, and opaque digests.

Key files

FileWhy to read it
rust/…/literal_secrets.rsShows how file-tool bodies and command text are screened for live-looking credentials.
rust/…/literal_secret_bare.rsShows how context and value shape identify credentials that have no strong prefix.
rust/…/literal_secret_code.rsShows how code setters, comments, key tables, and API-key values add the code-literal secret class.
rust/…/literal_secret_code_tests.rsShows the boundary between real-looking code credentials and placeholders, IDs, digests, and filler.
rust/…/mod.rsShows the fixed floors and main pre-tool evaluation order.
rust/…/generic_evaluate.rsShows how native outcomes, exact safe-read proofs, and general review are ordered.
rust/…/segment_proof.rsShows how command segments, sensitive arguments, and bounded readers are joined.
rust/…/safe_reads.rsShows the common boundary for file targets, filters, and structured readers.
rust/…/directory_targets.rsShows how workspace, home, directory, and link identity are bound.
rust/…/git_config.rsShows the bounded Git configuration and helper check.
rust/…/git_read_after_allow.rsShows when an earlier allowed step can carry a later Git read.
rust/…/contained_wrapper_plan.rsShows the shared plan between classification and the execution sink.
rust/…/workspace_contained.rsShows when review can become a contained execution requirement.
rust/…/worktree_add.rsShows how a new checkout and later reads share one proof.