Skip to content

feat: add fail-closed-security-hooks plugin (runtime guardrails for regulated data) - #9

Open
timwukp wants to merge 1 commit into
aws-samples:mainfrom
timwukp:feat/fail-closed-security-hooks-plugin
Open

feat: add fail-closed-security-hooks plugin (runtime guardrails for regulated data)#9
timwukp wants to merge 1 commit into
aws-samples:mainfrom
timwukp:feat/fail-closed-security-hooks-plugin

Conversation

@timwukp

@timwukp timwukp commented Jun 13, 2026

Copy link
Copy Markdown

Implements #7.

What this adds

A second plugin to the marketplace: fail-closed-security-hooks — runtime guardrails on what the agent does, the layer a startup hits the moment it touches regulated data (fintech, health). aws-dev-toolkit is the build-side companion; this is the guardrail-side one.

Five hooks wired through a fail-closed telemetry shim:

Hook Events Enforces
pii-guard UserPromptSubmit, PreToolUse Blocks secrets (AWS keys, private keys, JWTs, DB strings, credit cards) and national IDs across US/UK/JP/KR/SG/EU/AU before they reach the model; each pattern individually disable-able
git-guard PreToolUse (Bash) Remote-URL allowlist, force-push prevention, protected-branch enforcement, destructive-op blocking
audit-logger UserPromptSubmit, PostToolUse Tamper-evident HMAC-SHA256 hash-chained JSONL audit log (verifier included); optional CloudWatch + SIEM dual-write
token-budget-guard PreToolUse, PostToolUse Per-session circuit breaker against runaway agent loops
hook-wrapper wraps the above Converts silent hook crashes/timeouts into explicit exit 2 denials — fails safe, not open

Layout (per the README's "Adding More Plugins" recipe)

plugins/fail-closed-security-hooks/
├── .claude-plugin/plugin.json
├── hooks/{pii-guard,git-guard,audit-logger,token-budget-guard,hook-wrapper}.sh + hooks.json
├── scripts/chain-verify.sh
├── README.md
└── LICENSE

Registered in .claude-plugin/marketplace.json (metadata version 0.3.0 → 0.4.0) and listed under Plugins in the README. aws-dev-toolkit is untouched.

Testing

Smoke-tested locally: pii-guard blocks an AWS key (exit 2) and passes benign prompts (exit 0); hook-wrapper turns a crashing hook into exit 2; the audit chain verifies intact (exit 0) and catches a deleted line as tampered (exit 1). Upstream carries a 76-assertion suite and passes claude plugin validate --strict: https://github.com/timwukp/claude-code-on-aws-bedrock-best-practices

Licensing

Source is Apache-2.0; this contributed copy is MIT-0 to match the repository. "Allow edits from maintainers" is enabled — happy to adjust naming/category or scope down if you'd prefer.

Adds a second plugin to the marketplace: runtime guardrails on what the
agent does, for startups touching regulated data (fintech, health).

Five hooks via a fail-closed telemetry shim:
- pii-guard           PII/secrets + national IDs (US/UK/JP/KR/SG/EU/AU)
                      blocked before reaching the model
- git-guard           remote allowlist, force-push/protected-branch,
                      destructive-op blocking
- audit-logger        tamper-evident HMAC-chained JSONL audit log,
                      optional CloudWatch/SIEM dual-write
- token-budget-guard  per-session runaway-loop circuit breaker
- hook-wrapper        turns silent hook crashes/timeouts into exit-2
                      denials (fail-closed)

New plugins/fail-closed-security-hooks/ (plugin.json, hooks/, scripts/,
README, LICENSE); registered in marketplace.json (bumped 0.3.0 -> 0.4.0)
and listed in README. aws-dev-toolkit is untouched.

Implements aws-samples#7. Upstream source + 76-assertion suite:
https://github.com/timwukp/claude-code-on-aws-bedrock-best-practices
(Apache-2.0; this contributed copy MIT-0 to match the repo).
@timwukp

timwukp commented Jun 30, 2026

Copy link
Copy Markdown
Author

Friendly ping — just noting that the same fail-closed hooks pattern landed in aws-solutions-library-samples/guidance-for-claude-code-with-amazon-bedrock#550 last week (merged by wirjo, LGTM). Happy to rebase, split, or adjust the PR format if that would help move it forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant