Skip to content

feat: k8s-cost-visibility skill, security hardening, and guardrails-by-default#24

Merged
initializ-mk merged 1 commit intomainfrom
skills/k8s-cost
Mar 6, 2026
Merged

feat: k8s-cost-visibility skill, security hardening, and guardrails-by-default#24
initializ-mk merged 1 commit intomainfrom
skills/k8s-cost

Conversation

@initializ-mk
Copy link
Contributor

Summary

  • k8s-cost-visibility skill: Estimates Kubernetes infrastructure costs (compute, storage, LoadBalancer) with cost attribution reports grouped by namespace, workload, node, label, or annotation. Supports auto/aws/gcp/azure/static/custom pricing modes. Read-only — only uses kubectl get.
  • Filesystem traversal prevention for cli_execute: Blocks shell interpreters (bash, sh, zsh, etc.) unconditionally. Validates path arguments — rejects paths inside $HOME but outside workDir. Overrides HOME env to workDir in subprocesses. Sets cmd.Dir to workDir.
  • Tool output guardrails: AfterToolExec hook scans tool output for secrets/PII before it enters the LLM context. Enforce mode blocks with a generic error (no guardrail type leaked). Warn mode redacts matches with [REDACTED].
  • Guardrails on by default: --enforce-guardrails now defaults to true. Added --no-guardrails flag. DefaultPolicyScaffold() includes all 4 built-in guardrails even without forge build.
  • Session max age: Configurable via memory.session_max_age or FORGE_SESSION_MAX_AGE. Stale sessions are discarded to prevent poisoned error context.

Security fixes

Addresses social-engineering attack where an agent was tricked via Slack into listing ~/Library/Keychains/, reading the login keychain, and base64-encoding it as a file attachment:

Attack vector Mitigation
bash -c "ls ~/Library/Keychains" Shell interpreters unconditionally denied
ls ~/Library/Keychains/ Path arg blocked (inside $HOME, outside workDir)
cat ../../.ssh/id_rsa Relative path escape blocked
Subprocess ~ expansion HOME overridden to workDir in env
Secret in tool output reaches LLM CheckToolOutput redacts/blocks before LLM context
Error leaks "guardrail no_pii" Generic "tool output blocked by content policy" message

Test plan

  • TestCLIExecute_ShellInterpreterBlocked — all 8 shells rejected
  • TestValidatePathArg_BlocksHomeTraversal — 13 cases (workDir allowed, system allowed, home traversal blocked)
  • TestLooksLikePath — 14 cases covering paths, flags, plain args
  • TestCLIExecute_PathTraversalBlocked — integration test with ls $HOME
  • TestCLIExecute_HomeOverriddenToWorkDir — verifies subprocess HOME = workDir
  • go test ./... passes in forge-core and forge-cli
  • golangci-lint run clean in both modules

…d k8s-cost-visibility skill

Security hardening for cli_execute:
- Block shell interpreters (bash, sh, zsh, etc.) unconditionally
- Add path confinement: reject path args inside $HOME but outside workDir
- Override HOME to workDir in subprocess env to prevent ~ expansion escape
- Set cmd.Dir to workDir for defense-in-depth

Tool output guardrails:
- Add CheckToolOutput to GuardrailEngine (enforce: block, warn: redact)
- Wire AfterToolExec hook to scan tool output for secrets/PII
- Use generic error message to avoid leaking guardrail internals
- Enable hooks to modify ToolOutput via mutable HookContext

Runtime defaults:
- Enable all guardrails by default (--enforce-guardrails=true)
- Add --no-guardrails flag to opt out
- Add DefaultPolicyScaffold with all 4 built-in guardrails
- Add session_max_age config for stale session expiry

New skill:
- k8s-cost-visibility: estimate K8s infrastructure costs with attribution reports
@initializ-mk initializ-mk merged commit 0d65c38 into main Mar 6, 2026
9 checks passed
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