fix(security): harden hook and device token auth

This commit is contained in:
Peter Steinberger
2026-02-13 01:23:26 +01:00
parent 54513f4240
commit 113ebfd6a2
9 changed files with 190 additions and 12 deletions

View File

@@ -2,6 +2,7 @@ import { randomUUID } from "node:crypto";
import fs from "node:fs/promises";
import path from "node:path";
import { resolveStateDir } from "../config/paths.js";
import { safeEqualSecret } from "../security/secret-equal.js";
export type DevicePairingPendingRequest = {
requestId: string;
@@ -431,7 +432,7 @@ export async function verifyDeviceToken(params: {
if (entry.revokedAtMs) {
return { ok: false, reason: "token-revoked" };
}
if (entry.token !== params.token) {
if (!safeEqualSecret(params.token, entry.token)) {
return { ok: false, reason: "token-mismatch" };
}
const requestedScopes = normalizeScopes(params.scopes);