Harden per-item permission checks in the Settings controller - #1531
Merged
Conversation
The Settings controller declares no $requiredPermissions, so a setting item's own permissions are the only thing gating it, and those are enforced solely by SettingsManager::loadItems() filtering the shared item cache that findSettingItem() reads. That filtering fails open when no user is authenticated at the time the cache is warmed, and is skipped entirely when items are registered directly on the manager rather than through registerCallback(), since loadItems() then never runs. Neither is reachable from code that ships today. findSettingItem() now checks the item's own permissions as well, returning false for a forbidden item exactly as the manager already does for a missing one, so no new error shape is introduced. This covers update(), update_onSave(), update_onTest(), update_onResetDefault() and formGetWidget(), which all resolve their item through it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
System\Controllers\Settingsdeclares no$requiredPermissions, so a setting item's ownpermissionsare the only thing gating it. Those are enforced solely bySettingsManager::loadItems(), which filters the shared item cache thatfindSettingItem()reads — so the gate does hold on every path that ships today.It fails open in two situations:
filterItemPermissions()returns the list untouched when$useris null, so anything that warms the item cache before authentication caches the unfiltered set for the rest of the request.registerSettingItems()sets$this->items = []when it is falsy, so calling it directly on the manager rather than insideregisterCallback()leaves$this->itemsnon-null andloadItems()never runs — nothing is filtered at all.Neither is reachable from core or from any first-party plugin I checked, so this is hardening rather than a fix for a live issue.
It came out of triaging GHSA-8ffc-66jg-44wc, which reported the Settings write path as writable by any backend user. That report did not reproduce —
loadItems()reassigns$this->itemswith the filtered result, andfindSettingItem()reads that same cache — but the controller shouldn't depend on the manager having taken that path.Changes
findSettingItem()now checks the item's own permissions, returningfalsefor a forbidden item exactly as the manager already does for a missing one, so no new error shape is introduced. It coversupdate(),update_onSave(),update_onTest(),update_onResetDefault()andformGetWidget(), which all resolve their item through it.Tests
modules/system/tests/controllers/SettingsSecurityTest.php:registerCallback()path for a permitted userThe pre-existing
ViteCompileTest,MixCompileTestandViewMakerTestfailures inmodules/systemare unrelated — they fail identically with this change reverted.🤖 Generated with Claude Code