GHSA-j65m-hv65-r264 PinchTab: Unapplied Rate Limiting Middleware Allows Unbounded Brute-Force of API Token
SummaryPinchTab `v0.7.7` through `v0.8.4` contain incomplete request-throttling protections for auth-checkable endpoints. In `v0.7.7` through `v0.8.3`, a fully implemented `RateLimitMiddleware` existed in `internal/handlers/middleware.go` but was not inserted into the production HTTP handler chain, so requests were not subject to the intended per-IP throttle.In the same pre-`v0.8.4` range, the original limiter also keyed clients using `X-Forwarded-For`, which would have allowed client-controlled header spoofing if the middleware had been enabled. `v0.8.4` addressed those two issues by wiring the limiter into the live handler chain and switching the key to the immediate peer IP, but it still exempted `/health` and `/metrics` from rate limiting even though `/health` remained an auth-checkable endpoint when a token was configured.This issue weakens defense in depth for deployments where an attacker can reach the API, especially if a weak human-chosen token is used. It is not a direct authentication bypass or token disclosure issue by itself. PinchTab is documented as local-first by default and uses `127.0.0.1` plus a generated random token in the recommended setup.PinchTab's default deployment model is a local-first, user-controlled environment between the user and their agents; wider exposure is an intentional operator choice. This lowers practical risk in the default configuration, even though it does not by itself change the intrinsic base characteristics of the bug.This was fully addressed in `v0.8.5` by applying `RateLimitMiddleware` in the production handler chain, deriving the client address from the immediate peer IP instead of trusting forwarded headers by default, and removing the `/health` and `/metrics` exemption so auth-checkable endpoints are throttled as well.Details**Issue 1 — Middleware never applied in `v0.7.7` through `v0.8.3`:**
The production server wrapped the HTTP mux without `RateLimitMiddleware`:The function exists and is fully implemented:Because `RateLimitMiddleware` was never referenced from the production handler chain in `v0.7.7` through `v0.8.3`, the intended request throttling was inactive in those releases.**Issue 2 — `X-Forwarded-For` trust in the original limiter (`v0.7.7` through `v0.8.3`):**
Even if the middleware had been applied, the original IP identification was bypassable:In `v0.7.7` through `v0.8.3`, if the limiter had been enabled, a client could have influenced the rate-limit key through `X-Forwarded-For`. This made the original limiter unsuitable without an explicit trusted-proxy model.**Issue 3 — `/health` and `/metrics` remained exempt through `v0.8.4`:**
`v0.8.4` wired the limiter into production and switched to the immediate peer IP, but it still bypassed throttling for `/health` and `/metrics`:That left `GET /health` unthrottled even though it remained an auth-checkable endpoint when a server token was configured, so online guessing against that route still saw no rate-limit response through `v0.8.4`.PoCThis PoC assumes the server is reachable by the attacker and that the configured API token is weak and guessable, for example `password`.**PoC Code**After run**Observation:**In `v0.7.7` through `v0.8.3`, rapid requests do not return HTTP 429 because `RateLimitMiddleware` is not active in production.In `v0.8.4`, the same `/health` PoC still does not return HTTP 429 because `/health` is explicitly exempted from rate limiting.The PoC succeeds only when the configured token is weak and appears in the tested candidates.The original `X-Forwarded-For` behavior in `v0.7.7` through `v0.8.3` shows that the first limiter design would not have been safe to rely on behind untrusted clients.This PoC does not demonstrate token disclosure or authentication bypass independent of token guessability.ImpactReduced resistance to online guessing of weak or reused API tokens in deployments where an attacker can reach the API.Loss of the intended per-IP throttling for burst requests against protected endpoints in `v0.7.7` through `v0.8.3`, and against `/health` in `v0.8.4`.Higher abuse potential for intentionally exposed deployments than intended by the middleware design.This issue does not by itself disclose the token, bypass authentication, or make all deployments equally affected. Installations using the default local-first posture and generated high-entropy tokens have substantially lower practical risk.Suggested RemediationApply `RateLimitMiddleware` in the production handler chain for authenticated routes.Derive the rate-limit key from the immediate peer IP by default instead of trusting client-supplied forwarded headers.Do not exempt auth-checkable endpoints such as `/health` and `/metrics` from rate limiting.Consider an additional auth-failure throttle so repeated invalid token attempts are constrained even when endpoint-level behavior changes in the future.**Screenshot capture**
<img width="553" height="105" alt="ภาพถ่ายหน้าจอ 2569-03-18 เวลา 13 03 01" src="https://github.com/user-attachments/assets/ab5cd7af-5a67-40ae-aae3-1f4737afd32e" />
CVSS v3.1 score: 4.8