Skip to content

Lesson 12 of 12 · 12m

Canaries and Audit Trails

Valid credentials used correctly look like normal traffic — canary tokens fire on first use and decrypt-level audit logs show who unwrapped what.

Prevention fails quietly: a leaked but valid credential used "correctly" produces API calls indistinguishable from your own automation. Detection has to trip on use, not on access. Two mechanisms cover it — bait that only an attacker touches, and logs at the unwrap layer.

Canary tokens

Thinkst's canarytokens.org mints free tripwires: an AWS key pair that alerts on any API call, a hostname that fires on DNS resolution, a document that phones home when opened, a kubeconfig that screams when used. The AWS key variant is the useful one — plant it where leaks land: inside a private repo (an old commit, a config/production.env nobody edits), on operator laptops at ~/.aws/credentials.bak, in a CI variables file, on a box behind your bastion. Any principal calling any AWS API with it generates CloudTrail events against Thinkst's account, and their backend pages you with the source IP and the call that fired it — you don't even need your own CloudTrail access to get the alert. There is no legitimate use — the credential authenticates only to Thinkst's locked-down account, and every call reports. A 3 a.m. hit means someone harvested and used it; you skip the "did it leak" phase entirely and start at the revoke step of the runbook.

The rule for placement: a canary only works where a real secret would be found. canary_aws_key.txt in the repo root fools nobody. A plausible backup-2024/.env three commits deep does. GitGuardian ships the same idea commercially as honeytokens.

Audit at the unwrap layer

Every system that decrypts or reads a secret emits evidence if you turn it on:

  • Vault: vault audit enable file file_path=… logs every request and response with sensitive fields HMAC'd — consistent hashes you can diff without exposing values. Vault refuses requests when no audit device works, which is the correct paranoia.
  • AWS: CloudTrail data events on secretsmanager:GetSecretValue, ssm:GetParameter, and kms:Decrypt record principal, source IP, and resource. They cost extra per event and they're the line that matters — management events tell you someone configured access; data events tell you someone used it.
  • Kubernetes: audit policy entries for get/list/watch on secrets, shipped to the audit log backend, show which service accounts read which secrets and when.

Ship all of it somewhere the attacker doesn't already control — an audit log that lives on the compromised host is a suggestion, not a record. Then baseline it: Decrypt from your deployment role hourly is routine; the same call from a residential ASN is a page. Baselines are what turn "we have logs" into "we get paged"; a data event nobody reads is indistinguishable from no event at all.

The wrong mental model

"Monitoring the perimeter catches misuse." The perimeter already failed — that's the premise. Valid credentials used through valid APIs generate no perimeter signal. The tripwire must sit on the artifact (canary) or the unwrap (audit), because those are the only two places a quiet leak is guaranteed to make noise.

Concrete practice

  • Plant AWS-key canaries in the repo, on laptops, in CI — anywhere you'd find a real credential — and wire the alert to paging, not email.
  • Enable Vault audit devices and CloudTrail data events before the incident; ship logs off-host.
  • Alert on novel (principal, resource) pairs, not just denied calls — an unfamiliar role reading a secret is your signal.

You will not prevent every leak. You can guarantee that every quiet use rings a bell — and a bell that pages the right person at 3 a.m. is the difference between a revoked key and a breach report with your name on it.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.