# Security

The default policy favors a useful local work wiki over aggressive blocking.

The runtime does not deny tool calls only because an input looks sensitive. It preserves operational context by default, including phone numbers, emails, dates, and business identifiers.

Before writing durable summaries, the runtime redacts authentication values such as:

- token-like values
- password-like assignments
- private key blocks
- bearer credentials
- Basic authentication headers and URL user information
- sensitive keys in structured tool/MCP inputs, recursively, before those inputs are serialized
- command-line forms such as `--password value`, `--password=value`, `cmdkey /pass:value`, `az`/`docker`/`sshpass -p`, `sqlcmd -Pvalue`, `ConvertTo-SecureString 'value' -AsPlainText`, `curl -u user:password`, and database `user=`/`password=` arguments
- Windows remote/session forms such as `winrs -p:value`, `net use ... password /user:name`, and `sqlcmd /P:value`

Manual and hook context output also runs through redaction before returning excerpts or search hits. `llm-wiki lint` reports remaining secret-like wiki content as an error so it can be removed or rewritten before it becomes reusable project memory.

`evidence_refs` are pointers, not a place to paste secrets or transcripts. `llm-wiki lint` rejects secret-like evidence values, unsafe `file:` paths, credential-bearing `url:` values, unsupported prefixes, and unsafe commands. Missing local `file:` or `raw:` targets are warnings so agents can fix references without losing the surrounding durable note.

`llm-wiki export` redacts generated `llms.txt`, `llms-full.txt`, and `llm-wiki.json` output. Exports must not contain npm tokens, WinRM credentials, private keys, raw `.env`, or full raw transcripts. `llms.txt` is an agent onboarding/handoff manifest and follows the same durable visibility policy as retrieval eval, so archived/superseded/default episodic pages are excluded by default.

Hook payloads are stored as append-only, schema-bounded event envelopes, not full raw transcripts. Envelopes contain only the allowed event metadata and do not persist a working directory, transcript path, prompt/tool body, credential, or provider session identifier. `PreCompact` never opens the file named by `transcript_path`; it builds checkpoints only from bounded, redacted turn state captured by hook events. Raw transcript capture is intentionally unsupported by the default runtime. A project that needs it must implement a separate, explicit, project-local consent and redaction path.

On Windows, Codex and Claude Code hook entries use a fixed `node.exe -e` bootstrap and a Base64-encoded JSON data payload containing only the Node executable path, installed CLI script path, and hook arguments. Base64 is an encoding, not encryption or credential storage; provider settings expose the command and paths. The fixed bootstrap parses the payload as data and starts the exact child executable with `shell: false`. Do not add tokens, passwords, or other credentials to hook commands. The outer `node.exe` follows the provider shell's normal Windows executable search order; its result may differ from the installer `PATH`, and some hosts can prefer a current-directory executable. Keep the agent environment and project executable search path trusted. The bootstrap does not create a security boundary against a hostile executable on that path or in the current directory.

Hook cleanup uses proven command identity, provider, event, and configuration field rather than a command-name substring. With the current matcher, automatic install/update can replace one unambiguous kit command while preserving sibling user hooks. Only known legacy default matchers are normalized, and only in pure kit-owned entries with no user siblings. Custom matchers and multiple kit duplicates remain stale for review. Explicit `--replace-hooks` can reconcile duplicates only when every entry is proven kit-owned and all non-command metadata, including nested fields, matches. Uninstall can remove a proven kit command after a matcher edit, but preserves unrelated fields, sibling hooks, and entry metadata. If one `command`/`commandWindows` object field is user-owned or unknown, the whole ambiguous object is preserved. Status reports stale events separately through additive `codexStaleEvents` and `claudeStaleEvents` fields.

## Filesystem mutations and backups

Full uninstall creates a tree backup outside the workspace and verifies the copied contents against a manifest before it removes provider integrations or wiki files. The backup includes user-authored Markdown and raw evidence, so it can contain sensitive project information even when individual source files were not classified as secrets. Protect the operator data directory with the same access controls as the project. Backup manifests and command summaries avoid printing wiki content or the full list of copied paths.

Kit writers coordinate through external workspace leases. Hooks skip writes when a conflicting mutation is in progress, and readers avoid rebuilding caches while an exclusive mutation is active. Path validation, no-follow checks, file identity checks, and final hash comparisons cover ordinary races among cooperating kit commands. Node.js does not provide a portable directory-handle-relative API for every operation, so this is not a security boundary against a hostile process running as the same OS user.

Git backup commits use a separate `refs/llm-wiki-backups/...` ref and do not update the user's current branch or index. These refs are ordinary repository objects; explicitly pushing them can send their contents to a remote, so they are not confidential storage. External release manifests bind source and package digests to installed file hashes, but they are release evidence rather than a signed attestation or secret store.

Opt-in full Q&A audit log: setting `LLM_WIKI_KIT_FULL_QA=1` records every turn's redacted prompt/assistant/tool bodies under `raw/qa/<day>/<session>-NNN.md`. Bodies pass through the same `redactText` pipeline as durable summaries (pattern-based, not exhaustive), and `raw/qa/` is gitignored so redaction misses never reach a commit. This is per-turn completeness, not raw transcript capture: `transcript_path` is never read or stored. The durable `outputs/questions` gate is unchanged. See decision `2026-08-07-full-qa-capture-channel.md`.

Transient turn, compact, language, and recovery records require a stable provider session or conversation identifier. If one is absent, the runtime fails closed instead of sharing a `default` state across unrelated sessions. Operators who accept project-scoped sharing when a provider emits no session id may opt in with `LLM_WIKI_KIT_PROJECT_SCOPED_TRANSIENT=1`; this derives a per-project key (scoped to one workspace, never a shared `default`) so transient features degrade gracefully instead of failing closed. It is off by default. Runtime retention may remove only expired external runtime files that match the expected schema and safe filename; it never deletes project `llm-wiki/raw/` evidence or curated wiki content.

When a provider supplies `turn_id`/`turnId` or `prompt_id`/`promptId`, the runtime hashes only the identifier value, treats those aliases as the same canonical turn identity, and rejects later question, tool, or Stop events whose identity is missing or different. This prevents correlated late events from a previous prompt from changing or closing the current prompt. Some providers do not emit any per-turn correlation identifier; in that case the runtime can reject known duplicate event IDs/timestamps and duplicate Stop fingerprints, but it cannot prove that an otherwise uncorrelated late tool or Stop belongs to an older prompt. That provider limitation remains a documented residual risk.

The filesystem hardening assumes ordinary project races and cooperating kit writers. A malicious process running as the same OS user can still attempt ancestor-path swaps in the small interval between pathname validation and an operation because Node.js does not expose a portable directory-handle-relative `openat`/`unlinkat` API. The runtime revalidates identity and containment, uses no-follow/exclusive opens where available, and quarantines retention targets, but it does not claim to be a security boundary against an actively hostile same-user process. Run the kit only in workspaces and user accounts whose filesystem is trusted at that level.
