Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: claude review chaanges

=1c7ac4341037
diff --git a/backend/src/ee/services/saml-config/saml-config-service.ts b/backend/src/ee/services/saml-config/saml-config-service.ts
index cd3d57dd3a..7452453074 100644
--- a/backend/src/ee/services/saml-config/saml-config-service.ts
+++ b/backend/src/ee/services/saml-config/saml-config-service.ts
@@ -571,7 +571,7 @@ export const samlConfigServiceFactory = ({
const membership = await orgDAL.createMembership(
{
actorUserId: userAlias.userId,
- inviteEmail: email,
+ inviteEmail: sanitizedEmail,
scopeOrgId: orgId,
scope: AccessScope.Organization,
status: OrgMembershipStatus.Invited,
diff --git a/backend/src/services/account-recovery/account-recovery-service.ts b/backend/src/services/account-recovery/account-recovery-service.ts
index c74a183728..b37247e654 100644
--- a/backend/src/services/account-recovery/account-recovery-service.ts
+++ b/backend/src/services/account-recovery/account-recovery-service.ts
@@ -21,6 +21,7 @@ type TAccountRecoveryServiceFactoryDep = {
};
export type TAccountRecoveryServiceFactory = ReturnType<typeof accountRecoveryServiceFactory>;
+const DUMMY_USER_ID = "00000000-0000-0000-0000-000000000000";
export const accountRecoveryServiceFactory = ({
userDAL,
@@ -88,18 +89,26 @@ export const accountRecoveryServiceFactory = ({
const cfg = getConfig();
const email = sanitizeEmail(unsanitizedEmail);
const user = await userDAL.findOne({ username: email });
- if (!user || (user && !user.isAccepted)) {
- throw new Error("Failed email verification for pass reset");
- }
- const userEnc = await userDAL.findUserEncKeyByUserId(user.id);
- if (!userEnc) throw new BadRequestError({ message: "Failed to find user encryption data" });
+ // Use a dummy userId when there's no valid user.
+ const shouldReject = !user || (user && !user.isAccepted);
- await tokenService.validateTokenForUser({
- type: TokenType.TOKEN_EMAIL_PASSWORD_RESET,
- userId: user.id,
- code
- });
+ try {
+ await tokenService.validateTokenForUser({
+ type: TokenType.TOKEN_EMAIL_PASSWORD_RESET,
+ userId: shouldReject ? DUMMY_USER_ID : user.id,
+ code
+ });
+ } catch {
+ // If we were going to reject anyway, throw the generic message.
+ // If the user was valid but the token failed, same generic message.
+ throw new Error("Invalid or expired verification request");
+ }
+
+ // Reject *after* the constant-time token validation work.
+ if (shouldReject) {
+ throw new Error("Invalid or expired verification request");
+ }
const token = crypto.jwt().sign(
{