secret-handling-runtime
БесплатноБез исполняемых скриптовНе проверенDecision aid for runtime secret hygiene — fd passing, scratch surface, error-path safety, identifier hygiene, and avoiding the SECRETS_ENV aggregation…
от jmagly★ 233 звезды на GitHubОб этом скилле
secret-handling-runtime
Decision aid for how a system handles secrets during operation: in memory, in pipes, in scratch files, in error messages, in logs, in process tables. Use when designing or reviewing any code that touches secret material at runtime.
This skill complements the existing addons/security/secure-token-load.md (which covers tokens at rest — file modes, heredoc patterns, source locations). This skill covers runtime — what happens to those secrets between load and use, and what happens when something fails mid-operation.
Triggers
- "secret in env" / "SECRETS_ENV"
- "shred" / "tmpfs" / "scratch surface"
- "set -e" / "error trap" / "ERR EXIT"
- "fd passing" / "named pipe for secrets"
- "log scrubbing" / "secret in error message"
- "ps aux" / "/proc/self/environ"
- "memory wipe" / "zeroize"
Section 1: File-descriptor / named-pipe passing
Suggested default — one secret per fd
# Caller
encrypt_program 3<<<"$SECRET_VALUE" 4<<<"$OTHER_SECRET" arg1 arg2
# Inside encrypt_program
secret=$(cat <&3)
other=$(cat <&4)
# fd 3 and fd 4 are open for the duration of the program
# never appear in /proc/self/environ, never in `ps aux`
Why this beats env vars:
env,printenv,/proc/<pid>/environare readable by other processes on most systems- Env vars persist across
execchains (subprocess inherits) set -x(bash trace) prints env values for each subprocess invocation- Crash dumps include env
Anti-pattern: SECRETS_ENV aggregation (review M3)
# WRONG
SECRETS_ENV="api_key=$KEY1;db_pwd=$KEY2;jwt_secret=$KEY3"
some_program # all three secrets visible to any process inspecting environ
Single variable = single leak vector. If set -x fires, all three leak. If a child process logs env, all three leak. Use one fd per secret OR one named pipe per secret.
Named pipes (mkfifo) when fd passing isn't structural
mkfifo /tmp/secrets.fifo
chmod 600 /tmp/secrets.fifo
{ echo "$SECRET" > /tmp/secrets.fifo; } &
program /tmp/secrets.fifo
rm /tmp/secrets.fifo
Caveats:
/tmp/should be tmpfs (Section 2)- Named pipes are visible to other users via
ls -la /tmp/; use a per-process directory in/run/<uid>/or/dev/shm/that's mode 700
Section 2: Scratch surface — tmpfs only
Suggested default — refuse to operate if /tmp is not tmpfs
require_tmpfs() {
local path="${1:-/tmp}"
if ! mountpoint -q "$path" || \
[ "$(findmnt -no FSTYPE "$path")" != "tmpfs" ]; then
echo "ERROR: $path is not tmpfs; refusing to operate" >&2
exit 1
fi
}
require_tmpfs /tmp
Why tmpfs only:
- tmpfs is RAM-resident; on shutdown, contents are gone
- Disk-backed
/tmp(some servers, some embedded systems) leaves traces in flash wear-leveling, journal, and swap shred -uon flash storage is worse than nothing — it gives false assurance against wear-leveling reality (review M1)
shred is not a substitute
shred overwrites file content multiple times then deletes. On flash storage (SSD, USB, eMMC), the wear-leveling layer remaps writes to fresh blocks; the original data sits in unmapped blocks until eventual reuse. shred -u deletes the visible file but the data remains recoverable via filesystem forensics.
shred IS appropriate for spinning disks where the OS guarantees in-place rewrites — uncommon in 2026.
For ephemeral scratch, tmpfs is the answer. For persistent encrypted storage, the encryption (LUKS, FileVault) is the answer; never write secrets to "ordinary" disk and try to delete them later.
Documenting the scratch surface
## Scratch surface
| Path | Backing | Acceptable for secrets? |
|------|---------|-------------------------|
| /tmp | tmpfs (verified at start) | yes |
| /var/tmp | disk | NO — refuse to write secrets |
| /dev/shm | tmpfs | yes |
| ~/.cache | disk | NO |
Section 3: Error-path safety in shell
Suggested default — set -euo pipefail + trap cleanup
#!/bin/bash
set -euo pipefail
cleanup() {
# zeroize what we can; unmount tmpfs scratch
[ -n "${SCRATCH_DIR:-}" ] && [ -d "$SCRATCH_DIR" ] && \
shred -u "$SCRATCH_DIR"/*.tmp 2>/dev/null
[ -n "${SECRET_VAR:-}" ] && unset SECRET_VAR
[ -n "${MOUNTED:-}" ] && umount "$MOUNTED" 2>/dev/null
}
trap cleanup ERR EXIT INT TERM
# ... actual script logic
Without set -e, a failing openssl enc or cat mid-pipeline can produce a partial-state file the next step processes (review M2). Without the trap, an interrupted script leaves secret-bearing scratch files intact.
Specific shell pitfalls
| Issue | Mitigation |
|---|---|
set -e doesn't fire inside if/while/&&/|| chains |
Test exit codes explicitly in those contexts: if foo; then ...; else echo "foo failed"; exit 1; fi |
set -e ignores failures in subshells unless caller checks |
(...) returns the subshell's exit; check it |
set -x (debug) prints expanded variab |
Установить secret-handling-runtime в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл secret-handling-runtime?
Decision aid for runtime secret hygiene — fd passing, scratch surface, error-path safety, identifier hygiene, and avoiding the SECRETS_ENV aggregation anti-pattern.
Как установить скилл secret-handling-runtime?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл secret-handling-runtime запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic