Authentication Architecture

Authentication Architecture

Overview

QODY implements multi-role authentication with separate flows for:

Security: Rate-Limiting & Brute-Force Protection

Critical Vulnerability Fixed — 2026-07-03 (MC #104585)

Vulnerability

Impact: CRITICAL — Unlimited brute-force / password-spray against owner/admin/SUPERADMIN accounts.

The login rate limiter trusted the client-supplied X-Forwarded-For header (first value) to key rate-limit buckets. An attacker could rotate a forged X-Forwarded-For value on each request to obtain a fresh rate-limit bucket every time, bypassing all protections.

Affected Endpoints:

Live Exploitation Verified: 2026-07-01 (Securion security review)

7 consecutive requests, same email, different spoofed X-Forwarded-For on every request:
All attempts → HTTP 401 (unlimited, rate limiter never triggered)
Evidence: ~/system/evidence/104554/qody-ratelimit-securion-review-20260701.md

Fix (Deployed 2026-07-03)

Strategy: Rate-limit on NON-SPOOFABLE dimensions instead of client IP.

New Design:

ClientIpResolver.kt: A helper for trusted-last-hop IP resolution was added (TRUSTED_PROXY_HOPS=1) but is used ONLY for non-critical post-auth ApiRateLimiter IP dimension + audit logs — NOT the login security key. Login security does NOT depend on IP trust.

Implementation:

Deployment

Verification (Live Production Replay)

Test: Replayed XFF-rotation exploit on production api.qody.ba with fresh email + rotating forged X-Forwarded-For values (same attack that succeeded unlimited pre-fix).

Result (Staff Login):

AttemptForged XFFResult
1203.0.113.1HTTP 401
2203.0.113.2HTTP 401
3203.0.113.3HTTP 401
4203.0.113.4HTTP 401
5203.0.113.5HTTP 401
6203.0.113.6HTTP 429 — Rate limited ✅

Outcome: Email-based limiter triggered at threshold despite XFF rotation. Fix confirmed live.

Unit Tests: 261 total, 0 failures, including a regression test replaying the exact exploit.

Evidence: ~/system/evidence/104585/qody-xff-fix-deploy-verify-20260703.md

Follow-Up (Non-Blocking, L-Priority)


JWT & Refresh Tokens

(Planned section — JWT structure, rotation policy, HttpOnly cookies, etc.)

Password Hashing

(Planned section — Argon2id parameters, rotation, etc.)

Session Management

(Planned section — Staff/SuperAdmin session lifecycle, logout, etc.)


Revision #1
Created 2026-07-03 11:50:51 UTC by John
Updated 2026-07-03 11:50:52 UTC by John