Skip to content

Commit 713fa24

Browse files
authored
Fix stored XSS in Group name (CVE-2024-25891-98) (#7675)
2 parents f179fa7 + 7c00f9f commit 713fa24

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/CartToGroup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
// Create the group select drop-down
5858
echo '<select id="GroupID" name="GroupID" onChange="UpdateRoles();"><option value="0">' . gettext('None') . '</option>';
5959
foreach ($ormGroups as $ormGroup) {
60-
echo '<option value="' . $ormGroup->getID() . '">' . $ormGroup->getName() . '</option>';
60+
echo '<option value="' . $ormGroup->getID() . '">' . htmlspecialchars($ormGroup->getName(), ENT_QUOTES, 'UTF-8') . '</option>';
6161
}
6262
echo '</select>'; ?>
6363
</td>

src/GroupView.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
$rsPropList = RunQuery($sSQL);
4545
$numRows = mysqli_num_rows($rsPropList);
4646

47-
$sPageTitle = gettext('Group View') . ' : ' . $thisGroup->getName();
47+
$sPageTitle = gettext('Group View') . ' : ' . htmlspecialchars($thisGroup->getName(), ENT_QUOTES, 'UTF-8');
4848

4949
require_once 'Include/Header.php';
5050

@@ -119,7 +119,7 @@
119119

120120
<div class="card card-info card-outline">
121121
<div class="card-header">
122-
<h3 class="card-title"><i class="fa-solid fa-info-circle"></i> <?= $thisGroup->getName() ?></h3>
122+
<h3 class="card-title"><i class="fa-solid fa-info-circle"></i> <?= htmlspecialchars($thisGroup->getName(), ENT_QUOTES, 'UTF-8') ?></h3>
123123
</div>
124124
<div class="card-body">
125125
<div class="mb-3">
@@ -459,7 +459,7 @@ function allPhonesCommaD() {
459459
bootbox.confirm({
460460
title: "<?= gettext("Confirm Delete Group") ?>",
461461
message: '<p class="text-danger">' +
462-
"<?= gettext("Please confirm deletion of this group record") ?>: <?= $thisGroup->getName() ?></p>" +
462+
"<?= gettext("Please confirm deletion of this group record") ?>: " + <?= json_encode($thisGroup->getName(), JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT) ?> + "</p>" +
463463
"<p>" +
464464
"<?= gettext("This will also delete all Roles and Group-Specific Property data associated with this Group record.") ?>" +
465465
"</p><p>" +

src/api/routes/people/people-groups.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@
115115
if ($groupSettings['isSundaySchool'] ?? false) {
116116
$group->makeSundaySchool();
117117
}
118-
$group->setName($groupSettings['groupName']);
119-
$group->setDescription($groupSettings['description'] ?? '');
118+
$group->setName(strip_tags($groupSettings['groupName']));
119+
$group->setDescription(strip_tags($groupSettings['description'] ?? ''));
120120
$group->setType($groupSettings['groupType'] ?? 0);
121121
$group->save();
122122
return SlimUtils::renderJSON($response, $group->toArray());
@@ -126,9 +126,9 @@
126126
$groupID = $args['groupID'];
127127
$input = $request->getParsedBody();
128128
$group = GroupQuery::create()->findOneById($groupID);
129-
$group->setName($input['groupName']);
129+
$group->setName(strip_tags($input['groupName']));
130130
$group->setType($input['groupType']);
131-
$group->setDescription($input['description'] ?? '');
131+
$group->setDescription(strip_tags($input['description'] ?? ''));
132132
$group->save();
133133
return SlimUtils::renderJSON($response, $group->toArray());
134134
});

src/sundayschool/SundaySchoolReports.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
// Create the group select drop-down
180180
echo '<select id="GroupID" name="GroupID[]" multiple size="8" onChange="UpdateRoles();"><option value="0">' . gettext('None') . '</option>';
181181
foreach ($groups as $group) {
182-
echo '<option value="' . $group->getID() . '">' . $group->getName() . '</option>';
182+
echo '<option value="' . $group->getID() . '">' . htmlspecialchars($group->getName(), ENT_QUOTES, 'UTF-8') . '</option>';
183183
}
184184
echo '</select><br>';
185185
echo gettext('Multiple groups will have a Page Break between Groups<br>');

0 commit comments

Comments
 (0)