fix(security): use server-configured PET notification recipient

This commit is contained in:
2026-11-09 14:04:31 +00:00
parent f4f8075af3
commit ff84e9ea0f
6 changed files with 99 additions and 67 deletions
@@ -15,7 +15,6 @@ const allowedSubjects = [
];
const allowedFields = new Set([
"petEmail",
"contactEmail",
"contactSubject",
"contactbody",
@@ -120,22 +119,22 @@ export default async function ApiProxy(req, res) {
);
}
const petEmail = sanitizeString(requestBody.petEmail);
const petEmail = sanitizeString(process.env.PETEMAIL);
const contactEmail = sanitizeString(requestBody.contactEmail);
const contactSubject = sanitizeString(requestBody.contactSubject);
const contactBody = requestBody.contactbody;
if (
typeof requestBody.petEmail !== "string" ||
typeof process.env.PETEMAIL !== "string" ||
!isNonEmptyString(petEmail) ||
petEmail.length > 200 ||
!emailRegex.test(petEmail)
) {
return validationError(
res,
"INVALID_PET_EMAIL",
"petEmail must be a valid email address of 200 characters or fewer"
);
return respondError(res, {
status: 500,
code: "PET_RECIPIENT_NOT_CONFIGURED",
message: "PET notification recipient is not configured"
});
}
if (