Guide · November 23, 2026
Your AI coding agent committed a secret: block it before push, and rotate if it got out
On Nov 21, 2026, Together AI disclosed that an AI coding agent working on its public GitHub repo xorl committed a credential for a private Hugging Face repository. Together's automated scanning caught it and the commit was reverted. But during that window someone took the credential, downloaded stored customer prompt samples from the private repo, searched them for other services' credentials and tested those. (Together AI incident post)
The lesson: a scanner that alerts after the push, plus a revert, isn't enough. Once a key is in a public commit, assume it's been copied. Block secrets before they leave your machine, and rotate anything that got out.
Why agents make this more likely
- Agents read your environment and config while they work, and they can paste a working token straight into code, tests or fixtures to make something run.
- Agents commit and push quickly, often in large diffs that nobody reads line by line.
- Agent permission files can save secrets too. See our Claude Code settings.local.json guide.
1. Block secrets at commit time, for humans and agents
A git hook runs whoever makes the commit, including an agent in your terminal. With gitleaks installed:
# .git/hooks/pre-commit (chmod +x it)
#!/bin/sh
gitleaks git --pre-commit --staged --redact --verbose || {
echo "Secret found in staged changes. Remove it, then commit again."; exit 1; }
To share it with your team, use the pre-commit framework with the gitleaks hook, or add the same check to a pre-push hook. Tell your agent in AGENTS.md / CLAUDE.md never to bypass hooks with --no-verify. Hooks only cover the machine they're installed on, so add the server-side check below too.
2. Turn on GitHub push protection
GitHub's push protection blocks a push that contains a detected secret, before it reaches the repo. Push protection for users is on by default and covers pushes to public repositories. Push protection for repositories is off by default: a repo admin turns it on in the repo's security settings (it needs GitHub Secret Protection). Turn it on for repos your agents push to.
Keep a CI scan as a backstop (for example gitleaks in GitHub Actions on every pull request), since push protection only catches the secret types it recognizes. Together AI says it now checks every pull request for credentials.
3. If a key already got out: rotate, don't revert
- Rotate the key at the provider first. Reverting the commit, force-pushing or deleting the branch doesn't help, because anyone who saw it already has it.
- Check what the key could reach and look at the provider's access logs for use you don't recognize.
- Look for other secrets in your history:
gitleaks git --redact -vscans every commit, not just the latest one. - Follow the chain. In Together's case the first key unlocked data that held more credentials. If a store your key opened could contain keys, prompts or logs, rotate those too.
Our exposed .env guide has a rotation order that keeps the app running while you swap keys.
4. Limit what a leaked key can do
- Use scoped, short-lived tokens, or keyless access (for example OIDC from CI) where the provider supports it. Together lists these among its changes.
- Give the agent's shell only the keys the current task needs, not your whole production
.env. - Don't paste live keys into prompts. If an AI provider offers zero data retention, consider turning it on. Together now makes it the default for new accounts.
Shipped something with an AI agent? Run the free live-site check to see whether your live app leaks keys in its JavaScript or serves a .env or .git folder. The paid repo report also scans your full git history for secrets.
The VibePreflight team