Skip to content

Commit a55be80

Browse files
committed
fix: harden plugin tab cookie signature compare
1 parent dc58735 commit a55be80

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎src/gateway/control-ui-plugin-auth-cookie.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Control UI plugin-tab cookie auth lets an authenticated UI open gateway-auth plugin iframes.
2-
import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
2+
import { createHash, createHmac, randomBytes, timingSafeEqual } from "node:crypto";
33
import type { IncomingMessage, ServerResponse } from "node:http";
44
import { asDateTimestampMs } from "@openclaw/normalization-core/number-coercion";
55
import { isOperatorScope, type OperatorScope } from "./operator-scopes.js";
@@ -24,9 +24,9 @@ function signPayload(encodedPayload: string): string {
2424
}
2525

2626
function safeEqual(a: string, b: string): boolean {
27-
const left = Buffer.from(a);
28-
const right = Buffer.from(b);
29-
return left.length === right.length && timingSafeEqual(left, right);
27+
const left = createHash("sha256").update(a).digest();
28+
const right = createHash("sha256").update(b).digest();
29+
return timingSafeEqual(left, right);
3030
}
3131

3232
function readCookieHeaderValues(header: string | string[] | undefined, name: string): string[] {

0 commit comments

Comments
 (0)