Skip to content

About

TrustGuard AI firewall for Kiro (AWS): agent hooks that evaluate prompts, shell commands, file writes and MCP tool calls with NeuralTrust TrustGuard, blocking or masking unsafe actions.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TrustGuard for Kiro

AI firewall for the Kiro agent (AWS). Kiro agent hooks call trustguard-hook.sh, which maps Kiro hook events to TrustGuard POST /v1/evaluate and returns allow / deny / ask, or a masked tool input.

Same model as the Cursor plugin and the Codex plugin: one collector key, local hooks, no NeuralTrust account needed on the developer machine. The runtime is a small bash + Python 3 (stdlib only) script; it needs only bash, curl and python3, all present on a stock macOS.

What it protects

Kiro event What is evaluated TrustGuard protocol Direction Enforcement
PreToolUse (execute_bash / execute_pwsh) the shell command all input block → exit 2 (Kiro denies the call). transform → command rewritten via updatedInput with the masked value
PreToolUse (fs_write, read_file, MCP and other tools) the tool arguments as an MCP tools/call mcp input block → deny. transform → masked arguments via updatedInput. ask → Kiro approval prompt
PostToolUse the tool output (incl. MCP results) mcp result output block (e.g. indirect prompt injection) → the agent is told to treat the output as untrusted and the session is tainted
UserPromptSubmit the prompt llm input observe + taint (see Limitations). block taints the session; transform adds a "do not repeat sensitive values" note to the agent context

Session taint. After a blocked prompt or a blocked tool output, every later tool call in the same Kiro chat is denied locally, without calling the API. Start a new chat to continue. Taint markers live in ~/.trustguard/logs/kiro/taint/.

Requests carry attributes.source.application = "kiro-plugin", attributes.collector.type = "ide", the tool name in attributes.tool.name and the non-content hook fields in attributes.kiro. consumer_id and attributes.user.email are only sent when set in config (Kiro does not expose the account e-mail to hooks).

Limitations

  • Prompts cannot be blocked. Kiro ignores the exit code of UserPromptSubmit hooks today (kirodotdev/Kiro#11050), so a blocked prompt still reaches the model. The plugin compensates with session taint: no tool can run in that chat afterwards.
  • Hooks only run in a trusted workspace. Hooks are per workspace (<workspace>/.kiro/hooks/); after installing, trust the workspace and run Developer: Reload Window.
  • Only agent actions are covered. Commands you type in Kiro's terminal yourself do not go through hooks.
  • A PostToolUse block cannot erase output the tool already produced; it warns the agent and taints the session.

Install

Local / BYO

git clone https://github.com/NeuralTrust/trustguard-kiro-plugin.git
cd trustguard-kiro-plugin
make setup-key                                   # data URL + hidden key prompt, writes ~/.trustguard/kiro.json (0600), self-test
make install-local WORKSPACE=/path/to/project    # runtime -> ~/.trustguard/kiro/, hooks -> <project>/.kiro/hooks/

Then open the project in Kiro, trust the workspace and run Developer: Reload Window. The three hooks appear in the Kiro Agent Hooks panel as trustguard-prompt-submit, trustguard-pre-tool and trustguard-post-tool.

Repeat make install-local WORKSPACE=… for every project you want protected (the runtime is shared). Without make: scripts/setup-key.sh and scripts/install.sh /path/to/project.

Enterprise (MDM)

  1. Deploy trustguard/trustguard-hook.sh and trustguard/trustguard_hook.py to a fixed location (e.g. ~/.trustguard/kiro/).

  2. Drop a managed config with the org Kiro collector key:

    • macOS: /Library/Application Support/TrustGuard/kiro.json
    • Linux: /etc/trustguard/kiro.json
    • Windows: %ProgramData%\TrustGuard\kiro.json

    When the managed file has an api_key, its data_url, api_key and fail_mode cannot be overridden by the user file or environment.

  3. Ship the hook files (scripts/install-hooks.py install …) into the workspaces you manage.

Configuration

~/.trustguard/kiro.json (path overridable with TRUSTGUARD_KIRO_CONFIG):

{
  "data_url": "https://<trustguard-data-plane>",
  "api_key": "tgk_…",
  "fail_mode": "closed"
}
Key Default Env override Meaning
data_url — TRUSTGUARD_DATA_URL TrustGuard data plane (serves /v1/evaluate). base_url is still read for older configs
api_key — TRUSTGUARD_API_KEY Collector API key (tgk_…)
fail_mode open TRUSTGUARD_FAIL_MODE closed denies every tool call when TrustGuard is unreachable, errors or the config is broken. setup-key writes closed
transform_action mask TRUSTGUARD_TRANSFORM_ACTION On a DLP transform: mask runs the tool with the masked input, ask shows the masked input for approval, deny blocks
timeout_ms 5000 TRUSTGUARD_TIMEOUT_MS Per-call timeout
max_content_bytes 262144 Tool output sent to TrustGuard is clipped to this size
consumer_id — TRUSTGUARD_CONSUMER_ID Sent as consumer_id only when set
user_email — Sent as attributes.user.email only when set
events all on Disable events, e.g. {"PostToolUse": false}
skip_tools [] Tool names never sent to TrustGuard
shell_tools ["execute_bash","execute_pwsh"] Tools evaluated as shell commands
debug false TRUSTGUARD_DEBUG=1 Log every call, including the request payload

Precedence, as in the Codex plugin: env > user file > managed file > default (managed data_url / api_key / fail_mode are locked).

Uninstall

make uninstall-local WORKSPACE=/path/to/project   # removes .kiro/hooks/trustguard-*.json
make uninstall-all   WORKSPACE=/path/to/project   # also removes ~/.trustguard/kiro/ and logs

Then Developer: Reload Window in Kiro. ~/.trustguard/kiro.json is never deleted automatically; remove it by hand if you no longer need the key.

Troubleshooting

  • Plugin log: ~/.trustguard/logs/kiro/calls.jsonl. Quiet by default: only blocks, denials, taints and errors are written, without content. Set "debug": true to log every call with its request (this can contain the sensitive data TrustGuard is masking, so turn it off afterwards). The API key is never logged.
  • Kiro log (shows whether hooks fired and what they returned): ~/Library/Application Support/Kiro/logs/<timestamp>/window*/exthost/kiro.kiroAgent/Kiro Logs.log
  • Hooks don't fire: the workspace is not trusted, or the window was not reloaded after install. Check that .kiro/hooks/trustguard-*.json exist and point at an existing ~/.trustguard/kiro/trustguard-hook.sh.
  • Every tool is denied with "session is tainted": expected after a block in that chat; open a new chat.
  • Every tool is denied with "fail_mode is closed": TrustGuard is unreachable or the config is incomplete. Run make setup-key again to re-run the self-test.

Repository layout

Path Role
trustguard/ Hook runtime (trustguard-hook.sh, trustguard_hook.py) and the Kiro hook templates
scripts/ install.sh, uninstall.sh, setup-key.sh, install-hooks.py
tests/ Offline test suite against a local TrustGuard mock
make test            # offline tests (mock TrustGuard, no key needed)
make lint            # bash -n + py_compile
make install-local   # WORKSPACE=/path/to/project

Verify

echo '{"hook_event_name":"PreToolUse","tool_name":"execute_bash","tool_input":{"command":"echo hi"},"session_id":"s1","cwd":"/tmp"}' \
  | bash ~/.trustguard/kiro/trustguard-hook.sh pre-tool; echo "exit=$?"

Exit 0 = allowed, exit 2 = denied (reason on stderr).

License

Apache-2.0 — see LICENSE.

About

TrustGuard AI firewall for Kiro (AWS): agent hooks that evaluate prompts, shell commands, file writes and MCP tool calls with NeuralTrust TrustGuard, blocking or masking unsafe actions.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages