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.
2 parents 89b0395 + b673581 commit 8164aebCopy full SHA for 8164aeb
src/signature-algorithms.ts
@@ -144,7 +144,17 @@ export class HmacSha1 implements SignatureAlgorithm {
144
verifier.update(material);
145
const res = verifier.digest("base64");
146
147
- return res === signatureValue;
+ // Use constant-time comparison to prevent timing attacks (CWE-208)
148
+ // See: https://github.com/node-saml/xml-crypto/issues/522
149
+ try {
150
+ return crypto.timingSafeEqual(
151
+ Buffer.from(res, "base64"),
152
+ Buffer.from(signatureValue, "base64"),
153
+ );
154
+ } catch (e) {
155
+ // timingSafeEqual throws if buffer lengths don't match
156
+ return false;
157
+ }
158
},
159
);
160
0 commit comments