We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 73db72d commit b673581Copy full SHA for b673581
src/signature-algorithms.ts
@@ -143,7 +143,17 @@ export class HmacSha1 implements SignatureAlgorithm {
143
verifier.update(material);
144
const res = verifier.digest("base64");
145
146
- return res === signatureValue;
+ // Use constant-time comparison to prevent timing attacks (CWE-208)
147
+ // See: https://github.com/node-saml/xml-crypto/issues/522
148
+ try {
149
+ return crypto.timingSafeEqual(
150
+ Buffer.from(res, "base64"),
151
+ Buffer.from(signatureValue, "base64"),
152
+ );
153
+ } catch (e) {
154
+ // timingSafeEqual throws if buffer lengths don't match
155
+ return false;
156
+ }
157
},
158
);
159
0 commit comments