[MEDIUM] [SEC-10] `RateLimiterMiddleware` fails OPEN on backend errors for all non-login routes
Audit Finding: SEC-10
- Severity:
MEDIUM - Category: Rate limit bypass / Availability
- File:
src/Middleware/RateLimiterMiddleware.php:224-258
Description
The catch (\PDOException|\RuntimeException $e) block returns 503 only for login/2FA/reset-password paths and /api/mobile/v1/devices; for every other route it calls return $next($request); — i.e. the request is allowed through with no rate limiting. If Redis is down or the op_rate_limits table is locked/corrupted, the entire application loses brute-force protection on admin actions, API endpoints, and payment initiation.
Impact
An attacker who can induce Redis unavailability (e.g. by flooding it, or by exploiting a separate bug that crashes the Redis client) disables rate limiting on /api/* and /admin/*, enabling credential stuffing, payment spam, or DoS.
Reproduction
Stop the Redis service. Submit 1000 POST /api/v1/payments requests — all succeed (subject only to downstream limits).
Recommended Fix
Fail closed for mutating endpoints: return 429/503 when the limiter is unavailable for any non-GET request. For GET, failing open is acceptable.
Discovered during comprehensive codebase audit. See /home/z/my-project/worklog.md for full audit context.
Duplicate Issue — Closed
This issue is a duplicate of #304 (same audit finding SEC-10 — both issues share the same title, file path, and description).
The fix has been implemented and is ready for review in PR #523: https://github.com/own-pay/OwnPay/pull/523
Tracking will continue under the canonical issue #304, which is referenced by the PR's Closes #304 line and will be auto-closed when the PR merges.
Closing this duplicate as not_planned to keep the audit tracker clean.