Fix stored XSS in public family/person registration (CVE-2023-24690)#7680
Fix stored XSS in public family/person registration (CVE-2023-24690)#7680
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes CVE-2023-24690, a stored XSS vulnerability in the public family and person registration endpoints. The fix adds comprehensive input sanitization using strip_tags() and htmlspecialchars() to prevent malicious HTML/JavaScript from being stored in the database.
Key Changes
- Added sanitization for nested 'people' array in family registration (previously only top-level fields were sanitized)
- Replaced unsafe
fromJSON()method with explicit field-by-field setting in person registration - Applied consistent sanitization pattern across both endpoints:
htmlspecialchars(trim(strip_tags($value)), ENT_QUOTES, 'UTF-8')
| if (isset($personData['zip'])) { | ||
| $person->setZip($personData['zip']); | ||
| } | ||
|
|
There was a problem hiding this comment.
The replacement of fromJSON() with explicit field setting may have removed support for birthday registration. The registerFamilyAPI handles birthday data (lines 87-94), and the previous fromJSON() implementation would have set any fields present in the JSON payload. If birthday data can be submitted to this endpoint, consider adding similar birthday handling:
if (isset($personData['birthday']) && !empty($personData['birthday'])) {
$birthdayDate = DateTime::createFromFormat('m/d/Y', $personData['birthday']);
if ($birthdayDate !== false) {
$person->setBirthDay($birthdayDate->format('d'));
$person->setBirthMonth($birthdayDate->format('m'));
$person->setBirthYear($birthdayDate->format('Y'));
}
}Note: This assumes the birthday field should be sanitized like other string fields before parsing.
| // Handle birthday field if present | |
| if (isset($personData['birthday']) && !empty($personData['birthday'])) { | |
| // Sanitize input | |
| $birthdayString = \ChurchCRM\Utils\InputUtils::filterString($personData['birthday']); | |
| $birthdayDate = DateTime::createFromFormat('m/d/Y', $birthdayString); | |
| if ($birthdayDate !== false) { | |
| $person->setBirthDay($birthdayDate->format('d')); | |
| $person->setBirthMonth($birthdayDate->format('m')); | |
| $person->setBirthYear($birthdayDate->format('Y')); | |
| } | |
| } |
What Changed
Add input sanitization for public registration endpoints:
registerFamilyAPI:
registerPersonAPI:
Fixes #6443
Type
Testing
Screenshots
Security Check
Code Quality
Pre-Merge