Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { createFixedWindowRateLimiter, type FixedWindowRateLimiter, type SharedStore } from "@toolctrl/shared-store";
|
||||
import { createFixedWindowRateLimiter, type FixedWindowRateLimiter, type SharedStore } from "@hivegrid/shared-store";
|
||||
import { getSharedStore } from "../shared-store.js";
|
||||
|
||||
export const LOGIN_RATE_LIMIT_WINDOW_MS = 60_000;
|
||||
@@ -158,16 +158,17 @@ export function __resetLoginRateLimitStoreForTests(): void {
|
||||
storeFactory = () => getSharedStore();
|
||||
}
|
||||
|
||||
export function deriveLoginRateLimitClientIp(request: Pick<LoginRateLimitRequest, "headers" | "remoteAddress">): string {
|
||||
const forwardedFor = readHeader(request.headers, "x-forwarded-for");
|
||||
const forwardedClient = forwardedFor?.split(",")[0]?.trim();
|
||||
if (forwardedClient) {
|
||||
return forwardedClient;
|
||||
}
|
||||
// Trusted, proxy-set headers only. The leftmost X-Forwarded-For value is
|
||||
// client-controlled, so keying the login throttle on it let an attacker reset
|
||||
// their bucket by rotating the header (credential-stuffing bypass).
|
||||
const TRUSTED_LOGIN_IP_HEADERS = ["cf-connecting-ip", "true-client-ip", "x-real-ip"] as const;
|
||||
|
||||
const realIp = readHeader(request.headers, "x-real-ip")?.trim();
|
||||
if (realIp) {
|
||||
return realIp;
|
||||
export function deriveLoginRateLimitClientIp(request: Pick<LoginRateLimitRequest, "headers" | "remoteAddress">): string {
|
||||
for (const headerName of TRUSTED_LOGIN_IP_HEADERS) {
|
||||
const value = readHeader(request.headers, headerName)?.trim();
|
||||
if (value) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
const remoteAddress = request.remoteAddress?.trim();
|
||||
|
||||
Reference in new issue
Block a user