Security¶
agent-strace provides complementary mechanisms for keeping sensitive data out of traces and derived reports: secret redaction at capture time, PII anonymization at export time, and privacy-minimized report formats. A policy file lets you audit and restrict what the agent is allowed to do.
Anonymous product telemetry is a separate, default-on data path. Neither client
sends anything until its one-time notice has been shown or telemetry was
explicitly enabled. CLI telemetry can be disabled with
agent-strace telemetry disable; extension telemetry can be disabled with the
agentTrace.telemetry.enabled setting or the Command Palette. DO_NOT_TRACK=1,
AGENT_STRACE_TELEMETRY=0, and the editor-wide telemetry switch also disable
extension telemetry. Both clients use fixed schemas that exclude prompts,
responses, command arguments, paths, repository data, session IDs, endpoints,
and exception messages. The extension sends only session success, duration,
and aggregate tool/error counts, not trace contents.
The CLI also prints a one-time research invite
on stderr after the first interactive review, share, or cognitive-debt
run; it sends nothing and is never shown in CI, in non-terminal runs, or when
telemetry is off.
See Product telemetry for the complete schemas and controls.
Secret redaction¶
Strips API keys, tokens, and credentials before they hit disk. The original data is never stored. Redaction is enabled by default for all trace writes. A hook redacts a tool's output before it cuts the output to 1000 characters, or to 500 for a failed call. Output sent as an object is redacted field by field, then written as JSON and cut. agent-strace import also redacts each prompt, response and tool result before it cuts them to their stored length, so a secret that crosses the cut is still removed.
# Default: redact before writing traces
agent-strace record -- npx -y @modelcontextprotocol/server-filesystem /tmp
agent-strace record-http --url https://mcp.example.com/mcp
# Trusted local traces only
agent-strace record --no-redact -- npx -y @modelcontextprotocol/server-filesystem /tmp
agent-strace setup --no-redact
Detected patterns:
| Secret type | Pattern |
|---|---|
| OpenAI API keys | sk-proj-*, sk-svcacct-*, sk-admin-*, sk-None-*, and older sk-* keys |
| GitHub tokens | ghp_*, gho_*, ghu_*, ghs_*, ghr_*, github_pat_* |
| AWS credentials | AKIA*, aws_secret_access_key |
| Anthropic API keys | sk-ant-* |
| Slack tokens | xox* |
| Stripe keys | Secret and restricted keys sk_live_*, sk_test_*, rk_live_*, rk_test_* with 24 or more letters or digits after the prefix. Organization keys sk_org_* with 24 or more letters or digits, after an optional short segment such as live_. Webhook signing secrets whsec_* with 32 or more letters, digits, + or /, and up to two =. Publishable keys (pk_live_*, pk_test_*) are public and are kept. |
| Google API keys | AIza followed by exactly 35 letters, digits, _ or - |
| GitLab tokens | Tokens with 20 or more characters after a prefix GitLab documents: glpat- (personal, project and group access), glptt- (pipeline trigger), gldt- (deploy), glrt- and glrtr- (runner authentication), glrct- (runner controller), glcbt- (CI/CD job, including JWT job tokens), glft- (feed), glimt- (incoming email), glagent- (Kubernetes agent), gloas- (OAuth application secret), glsoat- (SCIM), glffct- (feature flags client) and glwt- (workspace). Includes routable and versioned tokens and an instance prefix such as acme-glrt-*. Not matched: a custom personal access token prefix, legacy runner registration tokens (GR1348941*), and prefixes GitLab does not document, such as glsat- and gliamat-. |
| npm tokens | npm_ followed by exactly 36 letters or digits |
| Hugging Face tokens | hf_ followed by 30 or more letters or digits. Organization tokens (api_org_*) are not matched, because Hugging Face does not document their format. |
| JWTs | Three base64 segments separated by . |
| Bearer tokens | Bearer\s+[a-zA-Z0-9\-._~+/]+=* |
| Connection strings | postgres://, mysql://, mongodb://, redis://, amqp:// |
| Basic-auth URLs | https://user:pass@example.com |
key- values |
key- followed by 16 or more letters or digits |
token- values |
token- followed by 16 or more letters or digits |
| Key-named values | A string value under one of these keys: password, passwd, secret, token, api_key, apikey, api-key, access_token, refresh_token, auth_token, authorization, credential, credentials, private_key, privatekey, client_secret, connection_string, database_url, db_url, aws_access_key_id, aws_secret_access_key, aws_session_token. Key names match case-insensitively, and - counts as _. Every string under the key is replaced, at any depth: in a list, in a nested object, or in a list of objects. Numbers, booleans and null are kept. |
| Long lowercase hex strings | Any run of 40 or more characters from [0-9a-f], anywhere in a string. This includes full 40-character git commit SHAs and SHA-256 digests (sha256:<hex> keeps the prefix). Uppercase hex is not matched. The only exception is the policy_sha256 digest of a schema-validated agent_trace_authorization v1 record. |
| Private keys | PEM blocks whose label ends in PRIVATE KEY, such as RSA PRIVATE KEY, ENCRYPTED PRIVATE KEY or OPENSSH PRIVATE KEY, and PGP PRIVATE KEY BLOCK blocks. A block with no END line before the next BEGIN line, such as a key cut short, is redacted from its BEGIN line to the end of its base64 body. Base64 body lines that end in an END line with no BEGIN line, such as the output of tail on a key file, are redacted from the first body line through the END line. Body lines may start with a line number as printed by cat -n or Claude Code. Certificates and public keys are not matched. |
In the Python decorator, keywords collected by a **kwargs parameter are stored as an object, so a key-named keyword such as password is redacted. A dict passed as one argument is stored as repr text, so its keys are not matched.
Redacted values become typed markers such as [REDACTED:openai-key], [REDACTED:bearer-token], or [REDACTED:sensitive]. The provider keys above use stripe-key, stripe-webhook-secret, google-api-key, gitlab-token, npm-token and huggingface-token. A provider prefix inside a longer word, such as risk_live_ or xnpm_, is not matched. A - before a prefix does not stop a match, as in x-sk_live_* or a removed diff line, except before the short prefixes AIza, npm_ and hf_, which can appear by chance after a - inside other tokens. Events with redaction are marked with "redacted": true. See ADR-0007 for design rationale.
For capture without prompts, responses, or tool input and output, use agent-strace hook --metadata-only, which setup --managed configures. See Platform-team install.
Hook sessions also record the redaction mode on each session_start event, as "redaction": "on" or "off", and so do sessions built by agent-strace import from Copilot events.jsonl files and Codex rollouts. agent-strace health reports that mode and the number of redacted events. Older traces and other capture paths do not record the mode, and health reports it as not recorded. The redacted flag is set only when redaction changed something, so zero redacted events does not prove that redaction was on.
Copilot transcript enrichment¶
agent-strace import --enrich adds token usage and missing tool outcomes from a Copilot events.jsonl to the session its hooks captured. By default it adds metadata only: models, token counts, message IDs and tool outcomes without their text. Two options are content-bearing: they store the model's response text and tool outcome text, which can quote prompts, files and command output. Leave them off where prompts and responses must not be stored.
agent-strace import --enrich --with-text <events.jsonl>AGENT_STRACE_ENRICH=textin the Copilot hooks' environment, which enriches each session when it ends.AGENT_STRACE_ENRICH=1adds metadata only.
Enrichment never stores content less redacted than the session already holds. A session captured with hook --metadata-only gets metadata only, even with --with-text or AGENT_STRACE_ENRICH=text. A session that recorded redaction on is redacted again, whatever the environment says when enrichment runs. A session that recorded no redaction mode gets metadata only.
PII masking¶
Masks personally identifiable information. Separate from secret redaction. There is no CLI flag for it, and record and record-http do not mask PII by default.
Call mask_event_data() directly to sanitise event data from an existing session before sharing or exporting:
Masked by default: email addresses, phone numbers, credit card numbers, US Social Security Numbers, AWS ARNs.
Values under personal-data key names such as email, phone, user_id, ssn or credit_card are replaced whole. If the value is a list or object, every string in it is replaced, at any depth. Numbers, booleans and null are kept.
Trace anonymization¶
Strip identifying information from traces at export time. Original session data is never modified.
# Preview what would be anonymized
agent-strace export SESSION_ID --anonymize --dry-run
# Export with anonymization applied
agent-strace export SESSION_ID --anonymize --output trace-anon.json
Anonymized by default:
- Home directory paths → ~/relative/path
- Hostnames → <hostname>
- OS usernames → <user>
- Email addresses → <email>
Add custom patterns via .agent-strace/anonymize.yaml:
rules:
- pattern: "ACME Corp"
replacement: "<company>"
- pattern: "192\\.168\\.\\d+\\.\\d+"
replacement: "<internal-ip>"
Organization-report anonymization¶
agent-strace org-report --anonymize replaces complete persisted identity
labels (including user@hostname composites) and team/workspace labels with
deterministic aliases such as Identity-001 and Team-001. Aliases are sorted
and local to that report; they are not unsalted hashes and never use the
collector authentication key. Aggregate output has no standalone session ID,
path, branch, hostname, tenant, or raw-event fields. The default,
non-anonymized report may show team labels and an attributed identity such as
user@hostname when it appears in an anomaly callout; use --anonymize before
sharing a report outside the organization.
For remote collector input, one authenticated collector instance and key is the organization boundary. Team, workspace, and tenant metadata are reporting labels, not authorization controls. Use separate authenticated collectors for organizations that must be isolated. Static HTML escapes all labels and has no external assets.
Privacy-minimized reports and bundles¶
Use the purpose-built derived formats when raw trace content is not required:
- assignment submissions include allowlisted, anonymous process telemetry; see Assignment submissions and review
- compliance crosswalks omit prompts, commands, URLs, and raw identifiers; see Compliance evidence crosswalk
- organization reports support
--anonymizefor external sharing; see Organization reporting
Ordinary agent-strace share output is also privacy-minimized. It omits prompts,
responses, commands, paths, tool input and result values, and other
content-rich values while retaining ordered evidence, provenance, health,
known gaps, failures, retries, recovery, and explicitly shareable annotations.
Run agent-strace share <session-id> --dry-run to review the selected
disclosure boundary without values.
Minimized packets replace event, parent, and annotation identifiers with
packet-local references. Annotation labels and notes marked --shareable are
included verbatim and should be reviewed before sharing.
Full replay content requires --include-content:
Full-content packets can contain secrets, personal data, commands, paths, and proprietary material. Heuristic redaction can miss sensitive values. Review the packet before sharing it. The embedded disclosure manifest records the mode, redaction and anonymization state, evidence limitations, and deterministic integrity references. Source traces remain unchanged.
Policy files¶
Audit and restrict what the agent is allowed to do. Exits 1 on violations — usable in CI.
agent-strace audit # latest session, no policy required
agent-strace audit abc123 --policy .agent-scope.json
# CI gate
agent-strace audit --policy .agent-scope.json || exit 1
Policy file (.agent-scope.json):
{
"files": {
"read": { "allow": ["src/**", "tests/**"], "deny": [".env"] },
"write": { "allow": ["src/**"], "deny": [".github/**"] }
},
"commands": {
"allow": ["pytest", "uv run", "cat"],
"deny": ["curl", "wget", "rm -rf"]
},
"network": { "deny_all": true, "allow": ["localhost"] }
}
Glob patterns support ** as a recursive wildcard. File read policy applies to Read, View, Grep, and Glob tool calls. Network policy checks URLs embedded in Bash commands.
Auto-generate a policy from traces¶
# Dry-run: print the suggested policy
agent-strace policy --dry-run
# Write it to disk
agent-strace policy --output .agent-scope.json
# Observe a specific set of sessions
agent-strace policy SESSION_ID [SESSION_ID ...] --output .agent-scope.json
Role-based access control¶
Manage org-level and workspace-scoped permissions for users and groups.
# Assign an org-level role
agent-strace rbac assign --user alice@example.com --role admin --by security@example.com
# Scope to a specific workspace
agent-strace rbac assign --user bob@example.com --role workspace:viewer --workspace prod
# Assign a role to a group
agent-strace rbac assign --group engineering --role member
# Check access
agent-strace rbac check --user alice@example.com --action export_compliance
agent-strace rbac check --user bob@example.com --action read_sessions --workspace prod
# List all assignments
agent-strace rbac list
# Revoke the workspace assignment
agent-strace rbac revoke --user bob@example.com --workspace prod
| Role | Scope and permissions |
|---|---|
owner |
Full org access, including RBAC, billing, and SSO management |
admin |
Read and run agents; annotate; manage policies, identities, and workspaces; export compliance data |
member |
Read sessions, run agents, and annotate |
viewer |
Read sessions only |
machine |
Programmatic identity with read-session access |
workspace:admin |
admin permissions in the named workspace |
workspace:member |
member permissions in the named workspace |
workspace:viewer |
viewer permissions in the named workspace |
Workspace roles require --workspace ID; org roles must omit it. Assignments are
stored locally in .agent-traces/rbac.json by default.
Local config and credential files¶
agent-strace keeps a few small JSON files that several processes can update at once, for example a hook and a CLI command:
| File | Contents |
|---|---|
~/.agent-strace/auth.json |
Per-server CLI tokens from agent-strace auth login |
~/.agent-strace/telemetry.json |
Telemetry preference, anonymous ID, current analytics session, and whether the research invite was shown (path can be set with AGENT_STRACE_TELEMETRY_CONFIG) |
.agent-traces/rbac.json |
RBAC assignments |
.agent-traces/identities.json, .agent-traces/team_budgets.json |
Entries written by agent-strace apply |
.agent-traces/.config-snapshots.json |
config-watch snapshots |
Every read-modify-write of these files holds an exclusive cross-process lock
on a sibling <file>.lock file, then writes the new contents to a uniquely
named temporary file in the same directory and renames it over the original.
Readers never see a partial file, and concurrent writers do not lose each
other's changes. The lock files are left in place on purpose.
auth.json and telemetry.json are always written with mode 0600, and a
missing ~/.agent-strace directory is created with mode 0700. If auth.json
cannot be locked within 10 seconds, auth login and auth logout exit with
an error instead of writing. Telemetry waits at most 2 seconds and then skips
the update silently, so it never blocks or fails a command or hook.
Workspace isolation¶
Workspaces provide separate session stores. Use them to isolate production traces from development, or to separate sessions by team.
# Create a workspace
agent-strace workspace new prod
# Switch to it (sets AGENT_STRACE_WORKSPACE)
eval $(agent-strace workspace use prod)
# List workspaces
agent-strace workspace list
# Delete a workspace and all its sessions
agent-strace workspace rm staging --force
Each workspace is a separate directory under <trace-dir>/workspaces/. Commands run in a shell where AGENT_STRACE_WORKSPACE is set read and write that workspace. RBAC assignments can be scoped per workspace.
Shadow AI detection¶
Detect undeclared agent activity in any repo. No network calls, no API keys.
agent-strace audit-tools
agent-strace audit-tools --repo . --since "90 days ago" --approved "Cursor,GitHub Copilot"
Detected tools: Claude Code, Cursor, GitHub Copilot, Codex / ChatGPT, Windsurf, Aider. Identified via file signals (.cursorrules, CLAUDE.md, .github/copilot-instructions.md, etc.) and commit message patterns. --approved names must match these names (case-insensitive); any other detected tool is reported as unapproved.
Runtime MCP poisoning scan¶
agent-strace mcp-scan scans the session store for runtime MCP poisoning indicators. It works on the tool descriptions and tool calls the agent actually saw during the session.
agent-strace mcp-scan
agent-strace mcp-scan --session abc123
agent-strace mcp-scan --watch
agent-strace watch --rules mcp-poisoning,budget:5,timeout:30m
The scanner checks:
| Check | What it catches |
|---|---|
| Description pattern match | Tool descriptions containing instruction override text such as SYSTEM:, ignore previous instructions, or <HIDDEN> |
| Description drift | A tool name whose runtime description changed since an earlier session |
| Behavioural sequence | Credential reads followed by external HTTP, environment dumps followed by external HTTP, mass reads followed by compression, and writes outside the project root |
Add custom regexes to ~/.agent-strace/mcp-patterns.txt, one pattern per line. The scan is local and deterministic; it does not call a remote reputation service.
Recommended setup for sensitive repos¶
Commit .claude/settings.json to the repo root so every developer gets the same instrumentation:
{
"hooks": {
"PreToolUse": [{
"matcher": ".*",
"hooks": [{ "type": "command", "command": "agent-strace hook pre-tool" }]
}],
"PostToolUse": [{
"matcher": ".*",
"hooks": [{ "type": "command", "command": "agent-strace hook post-tool" }]
}]
}
}
Or use the setup command:
Combine with agentic-authz to block agents from security-critical components entirely, and use agent-strace to audit everything they do access.