Security: enforce CSRF token validation on gradebook evaluation forms#8599
Security: enforce CSRF token validation on gradebook evaluation forms#8599AngelFQC wants to merge 1 commit into
Conversation
The gradebook evaluation add and edit forms (EvalForm/FormValidator) were
state-changing POST endpoints with no anti-CSRF token. FormValidator does
not inject a CSRF token on its own, so the forms accepted forged
cross-site submissions.
Add the standard Chamilo legacy idiom: validate Security::check_token('post')
before persisting (api_not_allowed on failure, clear_token on success) and
emit a fresh sec_token hidden field on the display path, mirroring the
pattern already used in exercise/tests_category.php and group/settings.php.
Refs GHSA-vjmr-7vxh-wpg2
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Cerrando este PR: tras revisarlo a fondo es un falso positivo en 2.0 y además el cambio rompía los formularios. En 2.0 el formulario de evaluación usa Es decir, El GHSA-vjmr-7vxh-wpg2 no aplica a 2.0 para estos endpoints. Si existe un vector real, sería en acciones de borrado del gradebook por GET/ |
Problem
The gradebook evaluation add (
gradebook_add_eval.php) and edit (gradebook_edit_eval.php) endpoints are state-changing POST forms built onEvalForm/FormValidator.FormValidatordoes not inject or verify an anti-CSRF token by itself, so these forms processed forged cross-site submissions using only the victim's session cookie.Fix
Apply the standard Chamilo legacy CSRF idiom (the same one already used in
exercise/tests_category.phpandgroup/settings.php):Security::check_token('post')before any persistence; reject withapi_not_allowed(true)if the token is missing/invalid, andSecurity::clear_token()on success.Security::get_token()+ a hiddensec_tokenelement ($form->addElement('hidden', 'sec_token')+setConstants).get_token()is only called on the display path, never beforecheck_token()on the processing request, so it never overwrites the session token being verified.Invariant now enforced
A gradebook evaluation can only be created or modified by a request that carries the per-session
sec_tokenissued when the form was rendered; cross-site forged POSTs are rejected.OWASP control
A01:2021 – Broken Access Control (CWE-352, Cross-Site Request Forgery).
⚠ Scope / follow-up
The advisory describes the gradebook module's add/edit/delete endpoints generally. This PR covers the two evaluation form endpoints that are concretely named and share the identical
EvalFormpattern. The same missing-CSRF pattern very likely affects sibling gradebook endpoints (gradebook_edit_result.php,gradebook_add_result.php,gradebook_add_user.php,gradebook_edit_all.php) and the deletion actions dispatched throughgradebook/index.phpaction parameters. Those were left out of this minimal change because they have heterogeneous structures and deserve individual review; they should receive the same token idiom as a follow-up.Refs GHSA-vjmr-7vxh-wpg2
🤖 Generated with Claude Code