Kimi K3.1 Pro · 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
4
Comments matching a bug
1
Comments not matching
3
Cost of this PR
$1.557

Published comments (4)

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

Untagged anonymous requests bypass the configured device limit — A missing `X-Grafana-Device-Id` makes `TagDevice` return `nil` before `CreateOrUpdateDevice`, so over-limit clients still receive an anonymous identity. Reject these requests or enforce the limit with a server-generated device identity.

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

Cached failed device tags let over-limit devices authenticate on retries — Over-limit devices can authenticate on retries because `tagDeviceUI` caches the key before `CreateOrUpdateDevice` and leaves it after store rejection; for 29 minutes, `TagDevice` returns `nil` instead of `ErrDeviceLimitReached`. Evict the key on store errors or populate `localCache` only after a successful create/update.

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

Non-atomic device admission lets concurrent requests exceed the limit — Concurrent first requests can all pass the `CountDevices` check before any insert/upsert commits, leaving more active devices than `s.deviceLimit` allows. Make admission and the write atomic with transaction locking, or serialize this critical section.

mediumbugpkg/services/anonymous/anonimpl/anonstore/database.go:83-85

updateDevice retries prepend the query repeatedly and corrupt Exec arguments — Retries after SQLite `ErrLocked` or `ErrBusy` shift every `Exec` argument because the callback prepends another query to captured `args`. Build a fresh slice per `WithDbSession` invocation or call `Exec(query, args...)` without mutating `args`.

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.