fix(core): validate portal layout CSRF with session checkToken#169
Merged
Conversation
Use Horde_Session::checkToken() for portal block layout saves so the token matches the value generated by getToken() in the edit form. Drop the Token injector path that rejected valid submissions.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes CSRF validation for classic portal block layout save actions by switching the validation path to the session’s CSRF token checker, matching the token generated by the portal edit form.
Changes:
- Replace injector-based
Horde\Token\Token::isValid()validation with$GLOBALS['session']->checkToken()for thesave/save-resumeactions. - Remove no-longer-needed
Token/TokenException/HordeSessionimports from the layout manager.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Pass Horde_Session into the block layout manager instead of reading $GLOBALS['session']. Collection resolves the session from the injector when callers do not supply one. Keeps checkToken() on the same code path as getToken() in the portal edit form while avoiding new global access in Manager.
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.
Summary
Horde_Session::checkToken()for portal block layout save actionsgetToken()in the edit formHorde_Sessioninto the layout manager instead of reading globals or calling the Token service directlyMotivation
Classic portal block layout saves could fail silently because the layout manager validated CSRF tokens through a different code path than the portal edit form uses to generate them.
Changes
lib/Horde/Core/Block/Layout/Manager.php: accept an optionalHorde_Sessionand callcheckToken()on save / save-resume; drop the directHorde\Token\Tokeninjector path that rejected valid submissionslib/Horde/Core/Block/Collection.php: pass a session into the layout manager, resolving it from the injector when callers do not supply oneTest plan
/horde/services/portal/edit.php, add or move a block, click Save/horde/services/portal/