Skip to content

fix(enrollment): emit 'error' anomaly metric on validation-failure exits (#984)#1099

Merged
ToddHebebrand merged 3 commits into
LanternOps:mainfrom
bdunncompany:fix/enrollment-error-metric
Jun 6, 2026
Merged

fix(enrollment): emit 'error' anomaly metric on validation-failure exits (#984)#1099
ToddHebebrand merged 3 commits into
LanternOps:mainfrom
bdunncompany:fix/enrollment-error-metric

Conversation

@bdunncompany

Copy link
Copy Markdown
Collaborator

Closes #984.

Problem

recordAgentEnrollment was only called on two exits — rate-limit 'denied' and the final 'success'. Every secret-validation 403 and the device-limit rejection recorded nothing, and the recorder's declared 'error' variant was never emitted anywhere. So the EnrollmentSpike alert (fires on enrollment volume by (tenant), description: 'verify this matches an expected rollout, not a leaked enrollment key') is blind to a burst of invalid-secret 403s — exactly the signature of someone probing with a leaked/guessed key.

Fix

Emit recordAgentEnrollment('error') at:

  • the 5 secret-validation 403 exits (missing + invalid secret; key-based, configured-secret, and production-enforce paths)
  • the device-limit rejection — with the resolved deviceLimitPartnerId so it carries the tenant

Metric calls only; no change to enrollment behavior or responses. Verified: apps/api tsc clean, the 22-case enrollment suite passes including a new assertion that 'error' is recorded on the production-enforce rejection.

Note

Stacked on #1096 (Go-1.25.11 govuln fix) so Security Scanning is green; the 4 Go-workflow lines drop out when #1096 merges.

…heck findings)

govulncheck (Security Scanning workflow) is failing on main and every open PR with
2 Go standard-library vulnerabilities, both fixed in go1.25.11:
  - GO-2026-5039  net/textproto  (unescaped inputs in errors)
  - GO-2026-5037  crypto/x509    (inefficient candidate hostname parsing)

These are stdlib-only (no third-party module bumps needed); a freshly-published
advisory started failing the scan on unchanged code because CI pinned 1.25.10.
Bump the GO_VERSION / go-version pins in ci.yml, codeql.yml and release.yml so
the scan (and the released agent binary's stdlib) use the patched toolchain.
go.mod's go directive (1.25.10 floor) is intentionally left as-is.
security.yml runs the Go Vulnerability Check job and had its own GO_VERSION:
'1.25.10' (separate from ci.yml). Bumping it to 1.25.11 is what actually makes
govulncheck use the patched stdlib.
…ly metric (LanternOps#984)

recordAgentEnrollment was only called on the rate-limit 'denied' and the final
'success' exits, so every enrollment-secret rejection and the device-limit
rejection recorded nothing — the recorder's declared 'error' variant was never
emitted. That left the EnrollmentSpike alert (which fires on enrollment volume
'by tenant' and says 'verify this is an expected rollout, not a leaked key')
blind to a burst of invalid-secret 403s from someone probing with a
leaked/guessed enrollment key.

Emit recordAgentEnrollment('error') at the five secret-validation 403 exits
(missing + invalid, key-based + configured + production-enforce) and the
device-limit rejection (with the partner id, which is resolved there). Metric
calls only — no change to enrollment behavior. Adds a test asserting 'error' is
recorded on the production-enforce rejection.
@ToddHebebrand ToddHebebrand merged commit 2fc357c into LanternOps:main Jun 6, 2026
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent-enrollment counter blind to failed-validation attempts — EnrollmentSpike can't see leaked-key probing

2 participants