GLM-5.3 · Heavy

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

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

The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Haiku 5.5.

Gold bugs found
1 of 2
Comments published
6
Comments matching a bug
1
Comments not matching
5
Cost of this PR
$1.912

Published comments (6)

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

Unauthenticated device tagging can exhaust the global cap and break anonymous auth — An attacker can fill the global cap with arbitrary `X-Grafana-Device-Id` values via `TagDevice`, locking out every genuine new anonymous device for ~30 days. Throttle or bound anonymous device creation per client IP.

highbugpkg/services/anonymous/anonimpl/anonstore/database.go:52-54

Wire provider set still registers ProvideAnonDBStore under old single-arg contract — `pkg/server/wire.go` still lists `anonstore.ProvideAnonDBStore` with no provider for a bare `int64`, so wire generation breaks. Remove the stale entry and regenerate the wiring.

highbugpkg/services/anonymous/anonimpl/impl.go:144-148

Device-limit error path leaves stale cache entry, letting over-limit devices through on retry — `tagDeviceUI` caches the device key before calling `CreateOrUpdateDevice` and never evicts it on failure, so an over-limit device is denied once and then granted for 29 minutes. Delete the `localCache` entry when `CreateOrUpdateDevice` returns `ErrDeviceLimitReached`.

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

Device-limit check is a check-then-act race; concurrent requests can exceed the cap — `CountDevices` and the subsequent insert run in separate DB sessions with no transaction or lock, so concurrent first-requests can all pass the check and exceed the cap. Wrap the count and write in a single transaction or enforce the limit atomically.

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

ErrDeviceLimitReached returned raw, surfacing as generic internal auth error — The auth middleware only renders `authn.Error` values, so a raw `anonstore.ErrDeviceLimitReached` surfaces as an indistinguishable internal fault on every request. Return the sentinel as an `authn.Error` with a status code and reason.

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

Dropped recover lets TagDevice panics fail anonymous requests — The old goroutine's `recover()` guaranteed a tagging panic only logged a warning; without it, panics now surface as a generic 500 on anonymous requests. Keep a recover around the synchronous `TagDevice` call.

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.