--- name: blocked-by-policy description: What to do when a Kiro Crew safety policy blocks a tool call — tell a policy block from a user refusal, then take the sanctioned path for its class (AWS creds, SSO, key files, trust root, exfiltration, self-protection, SQL text in a heredoc). Load on a 'command denied' result or refused AWS access. triggers: blocked by security policy, user denied tool execution, access to sensitive path, sensitive credential path, data-exfiltration pattern, governance trust-root, permission denied by policy, cannot access aws, no aws credentials, aws access denied, sso login, credential path, credential tool not available --- # When a safety policy blocks a tool call ## First: it was almost certainly not the user A rejected tool call is reported to you as a generic failure — on kiro-cli literally `User denied tool execution`. That string is wrong about *who* refused. Kiro Crew's own gate produces most refusals, and the real reason arrives separately as a `[Kiro Crew host notice]` message in the same turn. A host notice that says you made the same tool call several times is not a refusal: nothing was blocked. It is advice to change strategy. So: - **Never tell the user they cancelled, denied, or rejected anything** unless you saw them do it. Say the host policy blocked it, and name the rule. - **Do not stop and ask whether to retry.** Decide inside the same turn. - **Do not apologise for an interruption that did not happen.** ## Second: do not retry the same shape The deny rules come in families. If `cat ` was blocked, then `head`, `tail`, `less`, `more`, `strings`, `base64`, `cp` and `python -c 'open(...)'` on the same path are blocked too — by sibling rules with the same category. Cycling through readers wastes turns and produces a series of identical refusals. The question to ask is never "which reader is allowed" but "what was I actually trying to accomplish, and what is the sanctioned path to it". ## The classes, and the sanctioned path for each ### AWS credentials (`~/.aws`, `AWS_*` env vars, IMDS) **You do not need to read them, and running AWS CLI commands is not blocked by the rule that refused the read.** This is the single most common misdiagnosis: the read is refused, and the conclusion "this host has no AWS access" is drawn from it. The SDK resolves credentials itself. - Run the command you wanted, plainly. It uses the owner's default setup. - Confirm the identity in effect: `aws sts get-caller-identity` - Pass `--profile ` only with a name the owner gave you, to choose between profiles they have. **What is refused is YOU opening the credential file, not the credential being used.** The SDK inside the `aws` process still reads it, so a setup the owner already has works without you ever touching the file — which is why the command you actually wanted is the way forward and a different reader never is. **A resolved credential is not guaranteed just because the user has one.** Your environment can point at a session-scoped credentials location rather than the user's own, so a credential they minted by hand in their terminal may be invisible to you while still existing on the host. What `aws` can read depends on the sandbox tier Kiro Crew started this chat under, which `KIROCREW_SANDBOX_LEVEL` in this chat's shell names. On `standard`, the default tier, `~/.aws` is visible and the owner's setup works as it does in their terminal. On `strict` `~/.aws` is hidden, so no file route works. On `cc` only `~/.aws/config` is shown, so the supported route is a `credential_process` in that file. `strict` comes from the owner's sandbox settings (`agent.sandbox`, `agent.harness_sandbox`) or from an organization's sandbox floor, `cc` only from such a floor, and the owner's settings do not lower a floor. On some agent harnesses Kiro Crew hides `~/.aws` on every tier, and on `codex` it shows `~/.aws/config` only. If `aws` finds no credentials, or says a profile could not be found, this chat may not be able to see the owner's AWS files: one of those tiers hides them, or something outside Kiro Crew does, such as a sandbox the host runs agents in. Then `--profile` will not help, and neither will a credential command run in this chat's shell (such as `ada`), which cannot reach the owner's files or sign-in from here. Do not retry the command, and do not conclude that this host has no AWS access. Destructive AWS operations are separately denied on purpose. #### If the owner's AWS files are hidden: ask Kiro Crew for access Kiro Crew's own route then is its `aws_access` tool. Call it once, with a profile name the owner gave you or with nothing for the default setup. A person confirms the account and role, and the tool's answer gives the words to put in front of each `aws` command in this chat. If the tool refuses, or nobody confirms, say once which command you ran and what the tool said. Where its answer names no next step, this chat has no AWS access. Three things about it routinely mislead: - **A person answers the first ask for each account and role.** No approval mode answers for them, so until a person has said yes a chat nobody is watching gets no AWS access. That yes covers every chat until Kiro Crew restarts: a later ask for the same account and role is an ordinary tool call. Do not look for another way to get the call approved. - **The answer holds names, never a credential.** Credentials are handed to each `aws` command as it runs. Do not run the hand-out helper yourself, and do not print or copy what it returns. - **A refusal that names the owner's step is not a policy block.** When the host setup itself does not resolve (a sign-in that ran out, a profile that is not there), the tool says so and names what the owner does in their own terminal. Report that step; do not attempt it from here. #### If `aws_access` appears to be missing A tool search that returns nothing is **not** evidence that the tool does not exist here, and it is never grounds for explaining the architecture. Under MCP Tool Search a tool's spec is absent from your list until you load it, and a keyword query can score below the match threshold while the exact id hits. Retry with the exact id, loaded as the `[TOOL NAMES]` block says, not a keyword query. This alone resolves most cases. **Never invent a reason.** If it still misses, report what you observed (the search missed) and stop there. A confident guess about why sends the user to rebuild something that was already working. ### Enterprise SSO session material A live SSO cookie is a bearer credential: holding it would let you act as the user against every SSO-gated service. It is fenced for reading as well as writing, and copying it into a cookie jar is blocked on the same grounds — that is not a loophole to find, it is the same rule. You cannot authenticate on the user's behalf. Ask them to run their host's SSO login command in their own terminal, then retry what needed it. ### Other key material (`~/.ssh`, `~/.gnupg`, `~/.netrc`, `~/.npmrc`, cloud and container stores, …) Run the command that *uses* the key. The client that owns a credential store — version-control, remote-shell, cloud, container, package manager — resolves it without your help. If the task genuinely cannot proceed without the material, name the step that needs it and let the user carry out that step themselves. **Routing the material through this conversation is not the alternative to reading the file — it is the same outcome by a different route.** The refusal was about that material reaching you; a secret typed into the chat lands in the transcript, in the model's context, and in everything derived from both. Hand back the step, not a request for the material. A refusal in this family is not always about a path: a command whose job is to **obtain** a credential lands here too. The supported route for that is the owning client's own credential helper, as the user set it up. That is the user's setup step, so report what you needed instead of re-attempting the acquisition yourself. ### The governance trust root `security_policy.json`, `profiles/`, `admission_policy.json` and `denied_commands.json` under the data home are the ceiling you are governed *by*. Their unreachability from inside a tool call is the property that makes the ceiling un-disableable — it is not a misconfiguration. Do not look for another writer, a temp-file rename, or an extract-into-place trick. State what would need to change and let the user edit it. ### Exfiltration-shaped requests The refusal is about what the action would DO — move a local file's contents off this host — not about how it is written, so it must not be re-spelled. The rule matches the request shape: `-d @file`, `--data-binary @file`, `--data-urlencode @file`, `-F field=@file`, `wget --post-file`, and `/dev/tcp/` redirects. A form that got past it would mean the control was defeated rather than satisfied, so those bytes must not leave through you by any route. If the upload is genuinely what the task needs, name the file and the destination and let the user send it themselves. If you only needed the remote call and a local file was never the point, make the call without one. And if **no** local file is involved at all — an ordinary authenticated request that merely resembled the refused shape — say so plainly and report it as an over-block, rather than looking for a form that gets past the rule. One member of this family reads direction rather than shape: the three `aws s3 cp|mv|sync` rows. They exist to stop an UPLOAD, but their text also matches a download that carries a leading flag (`aws s3 cp --recursive s3://b/p ./d`). A reader narrows them away when it can read the whole line as a sequence of plain downloads (and plain `NAME=value` assignments it resolves), so most real downloads are never blocked. When one still trips — because the line has a shell variable it cannot resolve, a glob, a quote, a redirect, a pipe, a command substitution, a subshell, a here-document or a second command it cannot split — and the line is plainly a download (an `s3://` source, a local destination), it is an over-block of a download, not an upload. Do not re-spell it to slip past. What passes is a call that holds only the downloads, with literal paths or an unquoted `NAME=value` set once earlier in the same call and before any `&&` or `||`, plus at most plain `cat`, `echo`, `touch`, `mkdir`, `ls`, `cd` or `pwd` with no `>` or `<` redirect. So run the downloads in their own call, and do the rest (sourcing a file, a pipe, a redirect, a script, a here-document fed to a program) in a separate call after it. Or use `aws s3api get-object --bucket --key `. If the bytes really are going OUT to `s3://`, that is the upload the rows exist to stop: name the file and the destination and let the user run it. ### The self-protection floor Some refusals match on the command's **argv**, not on its text — the two you will meet are an inline interpreter program that imports the product (`python -c 'import kiro_crew …'`), and a compound command that mixes a product path with a credential-minting verb. These guard the product's own credential mint and its supervisor, so the refusal is about **what the action would do**, not how it is written. The same program reached by any other invocation form is the same action, so a form that got past the check would mean the control was defeated rather than satisfied. Do not go looking for one. What to do instead depends on what you were actually after: - **You needed the credential or the restart.** Refused for you by design. Say what you need and let the user do it. - **You needed something unrelated and the product import merely tripped the shape.** Get it another way that does not run product code: a file-reading tool instead of a shell reader, a CLI subcommand's own output instead of importing its internals, or an ordinary package query. If nothing else will do, hand that one step to the user rather than re-spelling it. ### A destructive SQL statement matched as text The `sql` rules (`DROP DATABASE`, `DROP TABLE`, `TRUNCATE TABLE`) match the statement's **text** wherever it appears on the command line — quoted, as an `echo` or `printf` argument, inside a heredoc body, in a `python -c` program. A command line cannot tell a statement a database client is about to run from one that is only being written down, so the rule refuses rather than guess. That means a shell command writing release notes that mention the statement is refused exactly like one that runs it, and the refusal names the SQL pattern even though you ran no SQL. It is a matter of what the line carries, not how it is spelled: re-spelling the statement, splitting its keywords, or moving it to another shell writer meets the same rule. What to do depends on what you were doing: - **The statement was going to run against a database.** That is exactly what is refused. Name the statement and let the user run it themselves; no other door to that effect is open to you. - **The statement is prose or data you are writing** — notes, a document, a comment or commit body, a fixture a linter must reject. The shell was never needed: the file-editing tool is not a shell command, so this rule does not read what it writes. Write the document with that tool, then hand its path to a prose reader such as `gh … --body-file ` or `git commit -F `. A database client (`psql`, `mysql`, `sqlite3` or any other) must never be handed that document: that is the refused statement by another route. - **The text was not yours to write and the command line merely carried it.** Say so plainly and report it as an over-block. ## Reading the refusal The reason has two possible forms: - `Blocked by security policy: ` — a denied-command rule. The pattern is a regex or a glob, so read it as "the family this belongs to", not as a literal description of your command. A second line, when present, explains why a pattern your text does not literally match still fired. - `Blocked: ` — the always-on floor (sensitive paths, the trust root, exfiltration shapes). These name the class directly. - `Blocked: the path could not be verified against the sensitive-path list…` — NOT a match. The resolver ran out of time before judging the path, so it was refused unjudged. This is the one refusal where the rule above inverts: do not switch reader or spelling (they meet the same budget); wait about thirty seconds and retry the identical call, and if it keeps happening tell the user the path resolver is timing out and name the path. Where the `kirocrew-debug` tools are granted, `debug_refusals` reads the gateway's own record and gives each refusal its class, including refusals your session never saw — `unverifiable_path` there is the stall described above. ## Useful checks - `kirocrew doctor` — reports the credential posture: which AWS profiles are configured, whether a `credential_process` is in play, and whether this host mounts an MCP server that vends credentials. - `kirocrew policy show [--ids]` / `policy explain ` / `policy profile ` / `policy source` / `policy validate` — the governance ceiling, where it comes from, and whether it loads. `policy show --ids` lists each denied-command category's rule ids instead of just counts, which is what you want when a refusal names a pattern you cannot place. `policy explain` takes optional `--session-key`, `--agent` and `--app` so you can ask about a surface other than your own. CLI only, deliberately: there is no tool for enumerating your own ceiling. ## What not to do - Do not describe a policy block as a user action. - Do not iterate through readers of the same blocked path. - Do not disable a rule to get past it. On a governed host the credential and sensitive-file categories are pinned and cannot be disabled at all, including by `disable_all` — guidance is the only lever, which is why this skill exists. - Do not silently give up on the task. Name the rule, name the sanctioned path, and either take it or hand the one human step back to the user.