Overview
An agent can authenticate Git by putting a token in the remote URL:https://oauth2:<token>@ for OAuth tokens. The token is then part of the command line of git and of the git-remote-https process it starts to open the connection.
When a network rule intercepts a connection, the Formal Endpoint records the command line of the connecting process and its ancestors in the session’s device info. Formal truncates long command lines but does not look for credentials in them, so the token is stored as-is. Formal redacts the Authorization header Git sends on each request, but not the command line.
You may want to handle this in two places:
- Logs: a log schema encrypts the command lines on the Endpoint, before the log leaves the device.
- Agents: a
responseblocks agent tool calls whose arguments contain a token or a URL with credentials, so the command never runs.
GitHub token formats
GitHub prefixes each token type:
Agents commonly find a token in the environment: the GitHub CLI reads
GH_TOKEN and GITHUB_TOKEN, and GitHub Actions creates a GITHUB_TOKEN installation token for each job. When the agent writes $GITHUB_TOKEN into the URL, the shell expands it, so the real token is in the command line but not in the agent’s tool call.
Prerequisites
- Formal Endpoint with Transparent Mode enabled
- An asymmetric encryption key registered in Formal
- Permission to create log schemas, network rules, and policies in Formal
Encrypt tokens in logs
Command lines are only logged for connections a network rule intercepts, such as the rule in Block Agent Git Pushes. Tool calls are logged for LLM traffic a network rule intercepts. This schema encrypts the command lines of the connecting process and its ancestors, and the tool call arguments in LLM logs, in every Endpoint log:encrypt = true with drop = true.
Block tokens in agent tool calls
This policy needs a network rule that intercepts LLM traffic, such as the one in LLM resources. The policy checks every string in each tool call’s arguments for a GitHub token prefix or a URL with credentials. The URL pattern also matchesx-access-token:$GITHUB_TOKEN@, which the token prefixes cannot see.
Verify
Prompt Claude Code:tool_calls input should be encrypted. For a Git command that a network rule intercepts, cmdline under device.connection_process should be encrypted in the session log.
Next steps
Log Schemas
Drop, encrypt, or truncate log fields
Network Rules
Select which traffic Transparent Mode intercepts
Policy Evaluation
Explore LLM policy inputs
Endpoint Logs
Review sessions and policy decisions