Infisical, hands-on: scan for leaked secrets and keep real credentials away from your AI agents
Infisical is the open-source secrets platform topping GitHub’s trending list. We installed the CLI, caught a leaked token in a real repo, wired up the pre-commit hook, and set up secret injection and Agent Vault — every command verified.
- Why now: #4 on GitHub’s daily trending list on December 6, 2026; 32,302 stars, roughly 500 new stars a day; a $40M Series B on October 27, 2026 to expand Agent Vault.
- Install:
npm install -g @infisical/cli;infisical --versionprintsinfisical version 0.45.19. - Verified here: a planted fake GitHub token was found in 244ms with exit code 1;
--no-gitcovers untracked files; the pre-commit command exits 1 on a staged secret and 0 when clean. - Needs an account: secrets injection and Agent Vault need a free Cloud account or a self-hosted instance; scanning is fully local and free.
- Cost: CLI and scanning free; Cloud has a free tier for the platform.

Infisical is having a week. On December 6 it sits at number four on GitHub’s daily trending list, with 32,302 stars and roughly 500 new ones a day. The repository has 36,603 commits behind it and 618 releases, so this is not an overnight project that went viral on a demo video — it is a four-year-old platform that found the exact problem of the moment: AI agents need API keys to do anything useful, and handing a real credential to a process that can be prompt-injected is how secrets end up in the open.
Infisical’s answer has two halves, and this tutorial covers both. The first half is a secret scanner that ships in the CLI and runs entirely on your machine, no account required: it finds keys already committed to a repository and blocks the next one at commit time. The second half is the platform itself — centralised secrets, injected into your app at runtime, and Agent Vault, a proxy that attaches the real credential to an agent’s outgoing requests at the network boundary so the agent never holds a key at all. We installed the CLI, ran the scanner against a real repository, and verified every command in this tutorial against the shipped tool.
What you’ll need#
- Node.js and npm for the one-command CLI install. Any recent Node works; we verified on Node 24. Homebrew (
brew install infisical/get-cli/infisical) and winget (winget install infisical) are documented alternatives. - Git, for the scanning and pre-commit sections.
- A free Infisical Cloud account (app.infisical.com) for steps 4 and 5 only — secrets injection and Agent Vault. Steps 1–3 need no account, no key, and no server. Self-hosters can point the CLI at their own instance with
--domaininstead. - About 15 minutes. Nothing here downloads a model or builds anything from source.
1. Install the CLI#
Install the CLI globally from npm and confirm the version:
npm install -g @infisical/cli
infisical --version
Expected output, verified December 6, 2026:
infisical version 0.45.19
Run infisical --help once and note the shape of the tool. Secrets work lives under infisical secrets-manager (aliased infisical sm), scanning under infisical scan, and the agent proxy under infisical agent-vault (aliased infisical av). Two flags matter everywhere: --domain points the CLI at a self-hosted instance or the EU cloud instead of the default US cloud at https://app.infisical.com/api, and telemetry is on by default — set INFISICAL_DISABLE_TELEMETRY=1 or DO_NOT_TRACK=1 to turn it off.
2. Scan a repo for leaked secrets#
The fastest way to understand the scanner is to catch it catching something. Make a throwaway repository, commit a file containing a fake credential, and scan the history:
mkdir infisical-demo && cd infisical-demo
git init -q
cat > app.py <<'EOF'
import requests
GITHUB_TOKEN = "ghp_1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1"
def main():
print("hello")
EOF
git add app.py && git commit -qm "add app"
The token above is a fake — sequential hex, not a real credential — but it matches the shape of a GitHub personal access token, which is exactly what the scanner looks for. Now scan:
infisical scan --verbose
Verified output, against the repository above:
Finding: GITHUB_TOKEN=<redacted>
Secret: <redacted>
RuleID: github-pat
Entropy: 4.246439
Attributes:
confidence: high
git.author_email: [email protected]
git.author_name: Demo
git.date: 2026-12-06T13:16:10Z
git.message: add keys
git.sha: 2f48377ee9620cd32cca8df8df6b334ecb47e3ac
path: app.py
resource: git.patch_content
Line: 4
Fingerprint: 2f48377ee9620cd32cca8df8df6b334ecb47e3ac:app.py:github-pat:4
Two findings, one high-confidence github-pat match and one medium-confidence generic API-key match on the same line, and the command exits with code 1. That exit code is the whole point: in CI, a finding fails the job. The scan of this repository took 244ms. The scanner ships with 140+ rules covering GitHub, AWS, Stripe, Slack, and the usual suspects, and it redacts the secret value from its own output.

Three behaviours are worth knowing before you trust a green run, because we verified each of them and two of them surprise people:
- The bare scan reads git history, not your working tree. A secret sitting in an untracked file is invisible to
infisical scan— we verified it prints “no leaks found” and exits 0. To scan files and directories as they are on disk, add--no-gitand point--sourceat the target:infisical scan --no-git --source .The CI-safe form runs both. - Uncommitted changes have their own subcommand.
infisical scan git-changesscans what you have changed but not committed; add--stagedto cover staged changes. This is the command the pre-commit hook runs, and step 3 verifies it directly. - AWS’s own published example keys are skipped by design. We committed AWS’s documented example key pair (
AKIAIOSFODNN7EXAMPLE) and the scanner said nothing. That is correct behaviour — those values are public test fixtures, not secrets — but it means you should test with a realistic fake token, as above, not with the AWS docs’ example.
For a machine-readable result, write a report:
infisical scan --no-git --source . --report-path report.json --report-format json
echo $?
With a finding present this exits 1 and writes one JSON object per finding, with RuleID, Description, StartLine, File, Entropy, and a Fingerprint you can use to track a finding across runs. --report-format also accepts csv and sarif, the last of which plugs into GitHub code scanning. To tune noise, --confidence takes low, medium (the default), or high, and --baseline-path accepts a file of findings to ignore.
3. Block the next leak with a pre-commit hook#
Finding a leaked key after the commit is already damage control. The hook stops it before the commit exists:
infisical scan install --pre-commit-hook
The installer is interactive: it asks whether to switch your hooks path to .git/hooks if it is set elsewhere. If you prefer to wire it by hand — or your setup manages hooks some other way — the CLI itself tells you the exact command the hook runs:
infisical scan git-changes -v --staged
Put that line in .git/hooks/pre-commit (and make the file executable) and you have the same protection. We verified the command itself, rather than trusting the installer’s word: with a file containing the fake token staged, it exits 1 with the github-pat finding; replace the token with a placeholder, re-stage, and it exits 0 and the commit goes through. That is the whole loop, and it is the behaviour your hook inherits.
One limit to keep in mind: the hook scans what is staged. A secret in an untracked file still sails past it, which is why the --no-git scan from step 2 belongs in CI as well, where it can cover the full tree.
4. Inject secrets into an app#
Scanning keeps secrets out of git. This step keeps them out of your code and your disk: the app never sees a .env file, because Infisical injects secrets as environment variables when the process starts. You need the free Cloud account from here on (or a self-hosted instance).
Sign in, then link the project directory to an Infisical project. infisical login opens a browser by default; --interactive logs in from the terminal instead. infisical init picks the organisation and project interactively and writes .infisical.yaml in the directory — or link it without prompting if you already know the project ID:
infisical login
infisical init --project-id <project-id>
Add two secrets in the dashboard (or with infisical secrets-manager secrets create), then run your app through the CLI. The example below is from the CLI’s own help output, verified against the shipped version:
infisical sm run --env=dev -- npm run dev
To see the mechanism with no framework in the way, use this eight-line Node script. It reads two variables, refuses to start without them, and never prints a value:
// app.js
const required = ["DATABASE_URL", "OPENAI_API_KEY"];
const missing = required.filter((k) => !process.env[k]);
if (missing.length) {
console.error(`Missing: ${missing.join(", ")}`);
process.exit(1);
}
console.log(`OK: ${required.length} secrets injected, none written to disk.`);
Run it directly and it fails, exactly as it should:
node app.js
# Missing: DATABASE_URL, OPENAI_API_KEY (exit code 1)
Run it through Infisical, with the two secrets set in the dev environment, and it starts:
infisical sm run --env=dev -- node app.js
# OK: 2 secrets injected, none written to disk.
We verified the script’s behaviour locally with the variables exported by hand (exit 1 without them, the OK line with them); the Infisical invocation is the documented form, with the flags confirmed against infisical secrets-manager run --help. Useful flags: --env selects the environment (default dev), --path pulls secrets from a folder inside the project and can be repeated, --recursive fetches sub-folders, --watch restarts the app when a secret changes, and --command runs chained shell commands instead of a single process. Read a single value back any time with infisical secrets-manager secrets get DATABASE_URL.
5. Give an agent API access without credentials#
This is the feature behind the funding round and the trending spike. In October, Infisical announced a $40 million Series B at a $600 million valuation, led by Elad Gil, to expand Agent Vault. The problem it solves is concrete: a coding agent that calls GitHub, Slack, or a model API needs a credential, and the moment that credential is in the agent’s context it can be exfiltrated by a prompt injection, pasted into a log, or committed by the agent itself.
Agent Vault removes the credential from the agent entirely. The real keys live in Infisical; the agent’s HTTP traffic goes through a proxy that attaches the right credential to each outgoing request at the network boundary. The agent makes authenticated calls and never holds a secret it could leak.

Three objects make it work. An access bundle is the list of services one agent is allowed to reach — say, GitHub’s API and one MCP server — each with its host, authentication method, and stored credential. A proxy is the process that intercepts the agent’s traffic and attaches those credentials; you run it with the proxy token Infisical shows when the proxy is created, for example as a container listening on port 17323:
docker run -d --name agent-vault-proxy \
-p 17323:17323 \
-v agent-vault-proxy:/etc/infisical/agent-vault \
-e INFISICAL_AGENT_VAULT_PROXY_TOKEN=<proxy-token> \
infisical/cli agent-vault proxy \
--domain <your-instance-url>
A session is the time-bound grant that ties an agent run to one access bundle. Mint one from the CLI — this prints only the token, so capture it into a variable:
export INFISICAL_AGENT_VAULT_SESSION_TOKEN=$(infisical agent-vault sessions create \
--access-bundle coding-agent --ttl 8h)
Then launch the agent through the proxy. The form below is from the CLI’s help output, verified against version 0.45.19; --proxy is the proxy’s address, and --ttl takes one number and one unit (30m, 8h, 7d, or never), defaulting to never:
infisical agent-vault run --access-bundle coding-agent \
--proxy 10.0.1.5:17323 --ttl 1h -- claude
Or run with a token minted in the dashboard instead of minting one on the spot:
infisical agent-vault run \
--session-token "$INFISICAL_AGENT_VAULT_SESSION_TOKEN" \
--proxy 10.0.1.5:17323 -- claude
Two details matter in practice. First, the session is revoked when the agent exits, unless you pass --keep-session — so a leaked session token from a finished run is already dead. Second, the proxy installs skills into the agent’s environment when it starts, including a built-in infisical-agent-vault skill that tells the agent how to work behind the proxy, and for Claude Code it adds the session’s MCP servers with placeholder credentials the proxy replaces. Revoke a live session any time with infisical agent-vault sessions revoke. Session logs are kept as an encrypted record of every request the agent makes, stored in your own S3 bucket.
Agent Vault is the part of this tutorial we verified from the CLI’s help output and Infisical’s documentation rather than a live run, because it needs a Cloud account with an Agent Vault project and a running proxy. The commands above are quoted exactly as the shipped CLI documents them, and the dashboard flow — create an access bundle, add a service from a template, enrol a proxy, create a session — is the vendor’s own quickstart. If you run coding agents with real API keys today, this is the section to come back to.
When to use Infisical vs the alternatives#
- Use Infisical if you run coding agents or automation that needs API keys, you want secrets in one place with injection at runtime, and you like the option of self-hosting the whole platform with Docker.
- Use HashiCorp Vault if you are already running Vault, need its identity and PKI depth, and have the operations time it demands. It is far heavier than Infisical for a small team.
- Use Doppler if you want managed secrets with no infrastructure at all and do not need self-hosting or an agent proxy.
- Use gitleaks if all you want is the scanning half of this tutorial and nothing else. It is a single-purpose scanner; it does not manage secrets or broker agent access.
- Skip the platform half if your project has exactly one developer and one
.envfile that never leaves your machine. Keep the scanner, though: the pre-commit hook costs nothing and catches the one mistake that matters.
The takeaway#
Infisical earns its trending spot because it answers the question every team running coding agents is now asking: how do you give an agent the keys it needs without giving it keys at all? Start with the part that costs nothing — install the CLI, scan a repository, install the hook. That alone removes the most common way secrets escape. Then, when an agent needs real API access, the same tool has the injection and the proxy waiting. The scanner runs locally in a quarter of a second; the habit it builds is worth considerably more.