mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Fix KID match
This commit is contained in:
@@ -339,10 +339,15 @@ export const pkiAcmeServiceFactory = ({
|
||||
externalAccountBinding,
|
||||
eabSecret
|
||||
);
|
||||
const eabAlg = eabProtectedHeader!.alg!;
|
||||
if (!["HS256", "HS384", "HS512"].includes(eabAlg)) {
|
||||
const { alg: eabAlg, kid: eabKid } = eabProtectedHeader!;
|
||||
if (!["HS256", "HS384", "HS512"].includes(eabAlg!)) {
|
||||
throw new AcmeMalformedError({ detail: "Invalid algorithm for external account binding JWS payload" });
|
||||
}
|
||||
// Make sure the KID in the EAB payload matches the profile ID
|
||||
if (eabKid !== profile.id) {
|
||||
throw new UnauthorizedError({ message: "External account binding KID mismatch" });
|
||||
}
|
||||
|
||||
// Make sure the URL matches the expected URL
|
||||
const url = eabProtectedHeader!.url!;
|
||||
if (url !== buildUrl(profile.id, "/new-account")) {
|
||||
@@ -359,10 +364,6 @@ export const pkiAcmeServiceFactory = ({
|
||||
message: "External account binding public key thumbprint or algorithm mismatch"
|
||||
});
|
||||
}
|
||||
// Make sure the KID in the EAB payload matches the profile ID
|
||||
if ((eabPayload as unknown as { kid: string }).kid !== profile.id) {
|
||||
throw new UnauthorizedError({ message: "External account binding KID mismatch" });
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof errors.JWSInvalid) {
|
||||
throw new AcmeMalformedError({ detail: "Invalid external account binding JWS payload" });
|
||||
|
||||
Reference in New Issue
Block a user