Skip to content

Commit

Permalink
Merge pull request #11113 from creative-commoners/pulls/4.13/cve-2023…
Browse files Browse the repository at this point in the history
…-48714

[CVE-2023-48714] Don't show or add records the member isn't allowed to
  • Loading branch information
sabina-talipova authored Jan 22, 2024
2 parents 38fef1e + 873b721 commit 6fe377e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Forms/GridField/GridFieldAddExistingAutocompleter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use SilverStripe\View\ArrayData;
use SilverStripe\View\SSViewer;
use LogicException;
use SilverStripe\Control\HTTPResponse_Exception;

/**
* This class is is responsible for adding objects to another object's has_many
Expand Down Expand Up @@ -195,11 +196,14 @@ public function getManipulatedData(GridField $gridField, SS_List $dataList)
if (empty($objectID)) {
return $dataList;
}
$gridField->State->GridFieldAddRelation = null;
$object = DataObject::get_by_id($gridField->getModelClass(), $objectID);
if ($object) {
if (!$object->canView()) {
throw new HTTPResponse_Exception(null, 403);
}
$dataList->add($object);
}
$gridField->State->GridFieldAddRelation = null;
return $dataList;
}

Expand Down Expand Up @@ -265,6 +269,9 @@ public function doSearch($gridField, $request)
SSViewer::config()->set('source_file_comments', false);
$viewer = SSViewer::fromString($this->resultsFormat);
foreach ($results as $result) {
if (!$result->canView()) {
continue;
}
$title = Convert::html2raw($viewer->process($result));
$json[] = [
'label' => $title,
Expand Down

0 comments on commit 6fe377e

Please sign in to comment.