mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-10 19:28:51 +00:00
Refine eab payload checking logic
This commit is contained in:
@@ -353,11 +353,19 @@ export const pkiAcmeServiceFactory = ({
|
||||
kmsId: certificateManagerKmsId
|
||||
});
|
||||
const eabSecret = await kmsDecryptor({ cipherTextBlob: profile.acmeConfig!.encryptedEabSecret! });
|
||||
let eabPayload: Uint8Array<ArrayBufferLike> | undefined;
|
||||
let eabProtectedHeader: JWSHeaderParameters | undefined;
|
||||
try {
|
||||
const { payload: eabPayload, protectedHeader: eabProtectedHeader } = await flattenedVerify(
|
||||
externalAccountBinding,
|
||||
eabSecret
|
||||
);
|
||||
const result = await flattenedVerify(externalAccountBinding, eabSecret);
|
||||
eabPayload = result.payload;
|
||||
eabProtectedHeader = result.protectedHeader;
|
||||
} catch (error) {
|
||||
if (error instanceof errors.JWSInvalid) {
|
||||
throw new AcmeMalformedError({ detail: "Invalid external account binding JWS payload" });
|
||||
}
|
||||
logger.error(error, "Unexpected error while verifying EAB JWS payload");
|
||||
throw new AcmeServerInternalError({ detail: "Failed to verify EAB JWS payload" });
|
||||
}
|
||||
const { alg: eabAlg, kid: eabKid } = eabProtectedHeader!;
|
||||
if (!["HS256", "HS384", "HS512"].includes(eabAlg!)) {
|
||||
throw new AcmeMalformedError({ detail: "Invalid algorithm for external account binding JWS payload" });
|
||||
@@ -383,16 +391,6 @@ export const pkiAcmeServiceFactory = ({
|
||||
message: "External account binding public key thumbprint or algorithm mismatch"
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof errors.JWSInvalid) {
|
||||
throw new AcmeMalformedError({ detail: "Invalid external account binding JWS payload" });
|
||||
}
|
||||
if (error instanceof AcmeError) {
|
||||
throw error;
|
||||
}
|
||||
logger.error(error, "Unexpected error while verifying EAB JWS payload");
|
||||
throw new AcmeServerInternalError({ detail: "Failed to verify EAB JWS payload" });
|
||||
}
|
||||
|
||||
const existingAccount: TPkiAcmeAccounts | null = await acmeAccountDAL.findByProfileIdAndPublicKeyThumbprintAndAlg(
|
||||
profileId,
|
||||
|
||||
Reference in New Issue
Block a user