Policy example
Secrets in coding agent tool calls
Secrets tend to leave in a different place from PII. The model returns a tool call, such as a Bash command, and the agent runs it, so the check belongs on the response, before the command executes. The Git tokens guide blocks any LLM response whose tool-call arguments contain a GitHub token prefix or a URL with credentials.
- The first pattern works because GitHub prefixes each token type:
ghp_, github_pat_, gho_, ghu_, ghs_ and ghr_ - The second exists because of shell expansion. An agent that writes
x-access-token:$GITHUB_TOKEN@ never puts the token in its tool call, so the prefix check sees nothing, but the URL still has the shape of a URL with credentials - The rule matches common formats, and some secrets slip through. The guide is upfront about what gets past it: tokens Git reads from a credential helper or a script file, and variables expanded anywhere other than a URL
- For intercepted connections, the Endpoint records the command line of the connecting process and its ancestors, as-is. Formal redacts the
Authorization header Git sends but not the command line, which is why the guide adds a log schema that encrypts command lines and tool-call inputs on the device
Protect Git tokens in command lines ›protect-git-tokens.regorego
package formal.v2
import future.keywords.if
import future.keywords.in
credential_patterns := [
`\b(gh[opsur]_|github_pat_)[A-Za-z0-9_]{20,}`,
`https?://[^\s/@:]+:[^\s/@]+@`,
]
passes_credential(call) if {
walk(call.input, [_, value])
is_string(value)
some pattern in credential_patterns
regex.match(pattern, value)
}
response := {
"action": "block",
"type": "block_with_formal_message",
"reason": "Agents may not put credentials in commands",
} if {
input.resource.technology == "llm"
some call in input.llm.tool_calls
passes_credential(call)
}