silverstripe / silverstripe-linkfield

Silverstripe module for managing links
BSD 3-Clause "New" or "Revised" License
4 stars 14 forks source link

Use to toMap() in Link::jsonSerialize() could lead to data disclosure #208

Closed emteknetnz closed 4 months ago

emteknetnz commented 5 months ago

The following code exists in Link::jsonSerialize()

        // TODO: this could lead to data disclosure - we should only return the fields that are actually needed
        $data = $this->toMap();

The code is called as part of LinkFieldController::linkData()

Data disclosure could happen when custom links or extensions to existing links add data columns that are not supposed to be shown in the CMS

Instead of using the 'include everything' approach, we should have an explicit list of fields returned. The list should be extensible.

Acceptance criteria

Affected code snippet

https://github.com/silverstripe/silverstripe-linkfield/blob/c75615f93d5fb3c899e2b9ee40e8528614e0a644/src/Models/Link.php#L206-L224

Extra context

PRs