Skip to content

Commit eea41e5

Browse files
authored
Fix stored XSS via CSV Import (CVE-2023-24686) (#7674)
## What Changed <!-- Short summary - what and why (not how) --> Add strip_tags() sanitization to all string fields imported from CSV: - Person fields: Title, FirstName, MiddleName, LastName, Suffix, Email, WorkEmail - Address fields: Address1, Address2, City, State, Zip - Custom fields: Family and Person custom field data This prevents XSS payloads from being stored in the database when importing malicious CSV files. Fixes #6442 ## Type <!-- Check one --> - [ ] ✨ Feature - [x] 🐛 Bug fix - [ ] ♻️ Refactor - [ ] 🏗️ Build/Infrastructure - [x] 🔒 Security ## Testing <!-- How to verify this works --> ## Screenshots <!-- Only for UI changes - drag & drop images here --> ## Security Check <!-- Only check if applicable --> - [ ] Introduces new input validation - [ ] Modifies authentication/authorization - [ ] Affects data privacy/GDPR ### Code Quality - [ ] Database: Propel ORM only, no raw SQL - [ ] No deprecated attributes (align, valign, nowrap, border, cellpadding, cellspacing, bgcolor) - [ ] Bootstrap CSS classes used - [ ] All CSS bundled via webpack ## Pre-Merge - [ ] Tested locally - [ ] No new warnings - [ ] Build passes - [ ] Backward compatible (or migration documented)
2 parents f96ec3c + 45ab1f5 commit eea41e5

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/CSVImport.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -378,43 +378,45 @@ public function assignRoles()
378378
// handler for each of the 20 person_per table column possibilities
379379
switch ($currentType) {
380380
// Address goes with family record if creating families
381+
// Sanitize to prevent XSS - strip HTML tags from input
381382
case 8:
382383
case 9:
383384
case 10:
384385
case 11:
385386
case 12:
386387
// if not making family records, add to person
387388
if (!isset($_POST['MakeFamilyRecords'])) {
388-
$sSQLpersonData .= "'" . addslashes($aData[$col]) . "',";
389+
$sSQLpersonData .= "'" . addslashes(strip_tags($aData[$col])) . "',";
389390
} else {
390391
switch ($currentType) {
391392
case 8:
392-
$sAddress1 = addslashes($aData[$col]);
393+
$sAddress1 = addslashes(strip_tags($aData[$col]));
393394
break;
394395
case 9:
395-
$sAddress2 = addslashes($aData[$col]);
396+
$sAddress2 = addslashes(strip_tags($aData[$col]));
396397
break;
397398
case 10:
398-
$sCity = addslashes($aData[$col]);
399+
$sCity = addslashes(strip_tags($aData[$col]));
399400
break;
400401
case 11:
401-
$sState = addslashes($aData[$col]);
402+
$sState = addslashes(strip_tags($aData[$col]));
402403
break;
403404
case 12:
404-
$sZip = addslashes($aData[$col]);
405+
$sZip = addslashes(strip_tags($aData[$col]));
405406
}
406407
}
407408
break;
408409

409410
// Simple strings.. no special processing
411+
// Sanitize to prevent XSS - strip HTML tags from input
410412
case 1:
411413
case 2:
412414
case 3:
413415
case 4:
414416
case 5:
415417
case 17:
416418
case 18:
417-
$sSQLpersonData .= "'" . addslashes($aData[$col]) . "',";
419+
$sSQLpersonData .= "'" . addslashes(strip_tags($aData[$col])) . "',";
418420
break;
419421

420422
// Country.. also set $sCountry for use later!
@@ -695,7 +697,8 @@ public function assignRoles()
695697
$currentFieldData = ConvertToBoolean($currentFieldData);
696698
}
697699
} else {
698-
$currentFieldData = addslashes($currentFieldData);
700+
// Sanitize to prevent XSS - strip HTML tags from input
701+
$currentFieldData = addslashes(strip_tags($currentFieldData));
699702
}
700703

701704
// aColumnID is the custom table column name
@@ -748,7 +751,8 @@ public function assignRoles()
748751
$currentFieldData = ConvertToBoolean($currentFieldData);
749752
}
750753
} else {
751-
$currentFieldData = addslashes($currentFieldData);
754+
// Sanitize to prevent XSS - strip HTML tags from input
755+
$currentFieldData = addslashes(strip_tags($currentFieldData));
752756
}
753757

754758
// aColumnID is the custom table column name

0 commit comments

Comments
 (0)