Skip to content
pegPublic

About

Credential canaries for AI agents. Fake AWS, SSH, Kubernetes, Git and npm credentials that alert you the moment something uses them.

Topics

Resources

Contributing

Security policy

Stars

5 stars

Watchers

0 watching

Forks

Repository files navigation

snare

CI Release License

Credential canaries for AI agents.

Snare plants fake AWS, SSH, Kubernetes, Git and npm credentials where real ones live. Normal work doesn't touch them. When something does, whether a hijacked agent, a malicious package or a person, the tool's own configuration calls home and you get an alert.

No daemon, proxy or policy changes. snare arm plants, snare disarm removes.

curl -fsSL https://snare.sh/install | sh
snare arm

How it works

A hijacked agent goes looking for credentials it was never given, and tries them. Snare puts bait where it looks, using hooks the tools already support. The default awsproc canary is an AWS profile whose credential_process calls back while the SDK is still resolving credentials, before any request reaches AWS:

# ~/.aws/config
[profile prod-admin]
role_arn = arn:aws:iam::123456789012:role/OrganizationAccountAccessRole
source_profile = prod-admin-source

[profile prod-admin-source]
credential_process = sh -c 'r=$(curl -sf "<callback-url>" ...); printf "{\"Version\":1,...}"'

Profile names and comments vary per install. The agent sees a flaky AWS response. You see:

⚙️ AWS (credential_process) canary fired
Time    2026-03-14 04:07:33 UTC
IP      34.121.8.92       Location  Council Bluffs, US
Network Amazon Technologies Inc (AS16509)
UA      curl/8.0

Snare reports that the bait was used and from where, not who used it. Anyone who reads the file can see the callback URL. Hosted installs call back to a neutral host under a random path per install, so canaries share no fixed URL, and the receiver answers every callback the same way whether or not the token exists. For a host nobody else shares, see Callback domains.

Install

curl -fsSL https://snare.sh/install | sh      # Linux, macOS
brew install peg/tap/snare                    # Homebrew
irm https://snare.sh/install.ps1 | iex        # Windows PowerShell

Or download a binary from releases and verify it. Runs on Linux, macOS and Windows 10 (1803) or later. On Windows the git canary needs Git for Windows and snare prove --run needs Git Bash.

Quick start

snare arm

The first run asks where alerts should go (Discord, Slack or Telegram), plants the canaries and sends a test alert. Pass --webhook <url> to skip the question. Treat webhook URLs as secrets; change it later with snare config set webhook <url>.

  • Discord: Server Settings → Integrations → Webhooks → New Webhook → Copy Webhook URL.
  • Slack: api.slack.com/apps → Create New App → Incoming Webhooks → Add New Webhook → copy the URL.
  • Telegram: create a bot with @BotFather, message it, find your chat ID in https://api.telegram.org/bot<TOKEN>/getUpdates, then use https://api.telegram.org/bot<TOKEN>/sendMessage?chat_id=<CHAT_ID>.
  • Anything else: self-host; snare serve sends JSON to any public HTTPS URL.

arm ends with one command that trips a canary for real, so you can see an alert arrive. snare status shows never fired until something uses a canary.

Commands

snare arm [--webhook <url>]  # plant canaries; re-run any time to repair registration
snare status                 # canaries and when each last fired
snare doctor [--test]        # health check; says what to fix
snare events                 # alert history
snare disarm                 # remove all canaries

snare --help lists the rest: prove to trip canaries on purpose, plant and teardown for single canaries, --select or --all for opt-in types, rotate, serve and uninstall.

Canary types

snare arm plants five precision canaries. They need active use of a fake profile, host, cluster, repository or package scope:

Type Planted in Fires when
awsproc ~/.aws/config An AWS SDK or CLI resolves the fake profile
ssh ~/.ssh/config Something connects to the fake host
k8s ~/.kube/<name>.yaml kubectl contacts the fake cluster
git ~/.gitconfig Git accesses the fake host
npm ~/.npmrc npm looks up a package under the fake scope

Opt-in with snare arm --select, --all or snare plant --type <type>:

Type Planted in Fires when
aws ~/.aws/config A client that supports endpoint_url uses the profile
gcp ~/.config/gcloud/sa-*.json Something loads the service-account file and refreshes its token
pypi-upload ~/.pypirc A publisher uploads to the named repository
git-credentials ~/.git-credentials A secret scanner such as TruffleHog tests the stored URL

How each type was proven is in Detection contracts. Retired types keep alerting until removed with snare disarm --type <type>.

Will it fire on my own work?

Not from reads. Opening, grepping or backing up ~/.aws/config fires nothing; only using the fake profile, host or cluster does. Tests or automation that use those fake names will fire them.

  • git-credentials fires when a secret scanner verifies it, including your own. Its alerts say so.
  • Snare refuses to plant through symlinks or into a git-tracked home (stow, yadm, vcsh), so canaries don't end up in a public dotfiles repo.
  • snare prove --run and the arm test send real alerts; that is the point.

Limits

Snare detects and does not block. A canary needs a network path to the callback host when it is used; if egress is blocked, Snare sees nothing. Using copied raw keys elsewhere fires nothing, since the callback lives in the config.

Privacy

Receivers never read request bodies or store credential material from headers. Stored evidence is the token, time, IP, user agent, method, path, location, ASN and a classification. On the hosted receiver Cloudflare terminates TLS; self-host if you need the network layer.

Local state lives in a plainly named folder under your user config directory (snare config prints it). The manifest there is encrypted and never uploaded. Reading events needs the owning device's secret.

Self-hosting

Run snare serve (or Docker Compose), or deploy the Cloudflare Worker in worker/:

SNARE_ENROLLMENT_TOKEN="$(openssl rand -hex 32)" snare serve --port 8080

Callbacks need a publicly trusted TLS certificate. Put snare serve behind a reverse proxy you control. See the self-hosting guide and Callback domains.

Verifying releases

Checksums are signed with cosign from the release workflow:

tag=vX.Y.Z # the exact tag you downloaded
cosign verify-blob --bundle checksums.txt.bundle \
  --certificate-identity "https://github.com/peg/snare/.github/workflows/release.yml@refs/tags/${tag}" \
  --certificate-oidc-issuer "https://token.actions.githubusercontent.com" checksums.txt
sha256sum -c checksums.txt --ignore-missing   # shasum -a 256 -c on macOS

License

Apache 2.0. See LICENSE.

About

Credential canaries for AI agents. Fake AWS, SSH, Kubernetes, Git and npm credentials that alert you the moment something uses them.

Topics

Resources

Contributing

Security policy

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages