Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
add jitter to response time
Matheus Nogueirab8511b54d5b8
diff --git a/backend/src/ee/services/honey-token/honey-token-service.ts b/backend/src/ee/services/honey-token/honey-token-service.tsindex 465143afa3..30307dfe69 100644--- a/backend/src/ee/services/honey-token/honey-token-service.ts+++ b/backend/src/ee/services/honey-token/honey-token-service.ts@@ -954,15 +954,18 @@ export const honeyTokenServiceFactory = ({}const startMs = Date.now();- // Floor to normalize response time across token-found and token-not-found paths,- // preventing timing side-channel enumeration of registered access key IDs.+ // Floor + random jitter prevents timing side-channel enumeration of registered+ // access key IDs. The jitter defeats statistical averaging across many requests.const MIN_RESPONSE_TIME_MS = 150;+ const JITTER_MAX_MS = 200;const rejectWithNormalizedTiming = async (): Promise<never> => {const elapsed = Date.now() - startMs;- if (elapsed < MIN_RESPONSE_TIME_MS) {+ const jitter = Math.floor(Math.random() * JITTER_MAX_MS);+ const target = MIN_RESPONSE_TIME_MS + jitter;+ if (elapsed < target) {await new Promise<void>((resolve) => {- setTimeout(resolve, MIN_RESPONSE_TIME_MS - elapsed);+ setTimeout(resolve, target - elapsed);});}throw new UnauthorizedError({ message: "Invalid webhook request" });