GLM-5.3 · Balanced

anonymous-add-configurable-device-limit-grafana-codex

Grafana · Go · M · 100–299 lines · 6 files

The normal review, with one generalist agent. Judge: Claude Haiku 5.5.

Gold bugs found
1 of 2
Comments published
4
Comments matching a bug
1
Comments not matching
3
Cost of this PR
$0.921

Published comments (4)

highbugpkg/services/anonymous/anonimpl/client.go:44-47

Over-limit device is cached on failed write and bypasses the limit for 29 minutes — In `tagDeviceUI` (impl.go), the device key is cached before `CreateOrUpdateDevice` runs, so an over-limit rejection still leaves it in `localCache` and the cache hit makes `TagDevice` return nil on later requests. Move `a.localCache.SetDefault` after a successful `CreateOrUpdateDevice`, or evict the key on error.

highsecuritypkg/services/anonymous/anonimpl/client.go:44-50

Anonymous device limit bypassable by omitting X-Grafana-Device-Id header — `TagDevice` (impl.go) returns nil when the header is missing, so clients that omit or rotate `X-Grafana-Device-Id` authenticate freely and never count against the quota. Anchor enforcement to a server-side signal, or document that the cap only meters cooperative frontends.

highbugpkg/services/anonymous/anonimpl/anonstore/database.go:109-118

Count-then-insert race in `CreateOrUpdateDevice` exceeds the device limit — In `CreateOrUpdateDevice`, `CountDevices` and the insert run as separate statements with no lock, so concurrent requests each see `count < deviceLimit` and all insert, exceeding the cap. Make the check atomic with a transaction that locks the counting range, or a conditional insert that re-checks the count.

mediumbugpkg/services/anonymous/anonimpl/client.go:44

TagDevice runs synchronously on the auth path, blocking every anonymous request — Auth now waits on a device round-trip for every anonymous request, amplifying latency on the hottest path. Run `TagDevice` asynchronously so authentication doesn't depend on it.

Gold bugs found (1)

hightagDeviceUI caches the device key before CreateOrUpdateDevice; when the store returns ErrDeviceLimitReached the entry stays, so the next request from the same device skips the limit check and authenticates for up to 29 minutes.

Gold bugs missed (1)

highThe new auth.anonymous device_limit setting has no entry in conf/defaults.ini, so the GF_AUTH_ANONYMOUS_DEVICE_LIMIT environment override is ignored and the limit stays 0.