Repository navigation
fix(core): require POST for state-changing actions (CSRF hardening) - #8609
Open
somethingwithproof wants to merge 73 commits into
Open
somethingwithproof wants to merge 73 commits into
somethingwithproof wants to merge 73 commits into
Conversation
somethingwithproof
requested review from
TheWitness
and removed request for
a team
November 6, 2026 08:58
This was referenced Nov 6, 2026
somethingwithproof
force-pushed
the
fix/csrf-require-post-on-state-change
branch
from
November 9, 2026 05:24
1a6b6ed to
f4d7bb0
Compare
github-actions
Bot
force-pushed
the
fix/csrf-require-post-on-state-change
branch
4 times, most recently
from
November 11, 2026 21:08
3052c58 to
67aa5f6
Compare
somethingwithproof
force-pushed
the
fix/csrf-require-post-on-state-change
branch
from
November 12, 2026 07:51
67aa5f6 to
52a1068
Compare
github-actions
Bot
force-pushed
the
fix/csrf-require-post-on-state-change
branch
4 times, most recently
from
November 17, 2026 08:47
24c1434 to
2b8c82e
Compare
somethingwithproof
force-pushed
the
fix/csrf-require-post-on-state-change
branch
2 times, most recently
from
November 19, 2026 09:34
4e4d485 to
cf6e1a4
Compare
github-actions
Bot
force-pushed
the
fix/csrf-require-post-on-state-change
branch
from
November 19, 2026 20:50
cf6e1a4 to
8fe3d51
Compare
This was referenced Nov 24, 2026
somethingwithproof
force-pushed
the
fix/csrf-require-post-on-state-change
branch
from
November 25, 2026 08:03
b9e6645 to
2ed4a2b
Compare
github-actions
Bot
force-pushed
the
fix/csrf-require-post-on-state-change
branch
from
November 25, 2026 20:49
2ed4a2b to
48a7341
Compare
…atch 3: form_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…3: form_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…h 3: form_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…hp (batch 3: form_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…h 3: form_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…tch 3: form_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…tch 3: form_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…atch 3: form_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…orm_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…m_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…tch 3: form_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…rm_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…atch 3: form_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
… form_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…ch 3: form_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…form_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…rm_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…m_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…3: form_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…batch 3: form_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…m_save / automation form_actions / POST-only direct actions) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…lice fixtures Follow-up to the batch-3 CSRF-require-POST hardening to green the CI checks it introduced: - include/layout.js: add tree_up/tree_down (tree.php) and move_page_up/move_page_down (links.php) to the cactiIsPostActionUrl transport map so the browser sends these actions as POST, matching the new server-side csrf_require_post() guards. Fixes the "JavaScript contracts" mutation_transport contract test. - tests/fixtures/Core/PackageSaveMatrix.php and tests/fixtures/UserAdministrationAuditProbe.php: stub a no-op csrf_require_post() alongside the other stubbed globals so the source-sliced form_save() handlers no longer fatal with an undefined function. Fixes the pest unit test, the user-admin integration test, the coverage gates, and the PHP native-dependency jobs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Batch 3 added csrf_require_post() to form_save(), the automation bulk-action execute branches and the in_array action dispatchers, but no probe ran those lines, so the changed-coverage gates failed. Add CsrfPostGuardBatch3Probe, which runs each guard from production source in its own process for GET, tokenless POST and valid POST (and an unguarded action for the dispatchers), and register it in run_pr_change_tests.sh and run_request_coverage.sh. A browser spec runs the POST transport map so its changed entries are covered too. automation_templates.php ajax_dnd, graph_dnd, tree_dnd and exitonchange, and automation_graph_rules.php qedit, still wrote on GET through loadUrl(). Add them to the dispatcher guards and to the POST transport map so drag and drop, the exit toggle and the query change keep working. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
post-action-transport.spec.js and MutationEndpointPostGuardTest only check map entries against the server. Nothing caught the opposite case: an action the dispatcher guard sends to csrf_require_post() that a page still reaches through loadUrl() or a plain link because the cactiIsPostActionUrl() map omits it, which answers 405 in the browser. The dnd and qedit misses fixed earlier in this PR were that kind. The new test reads every dispatcher guard list and every UI reference to a guarded action, and reports references that are neither a cactiPostAction element, a postUrl() or $.post() call, nor listed in the map. A second case drops qedit and graph_dnd from the map and expects exactly those two to be reported. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…robe The user administration audit probe sliced the real csrf_require_post() out of include/csrf.php and also declared an empty one, so the probe exited with a redeclaration fatal and every audit integration test failed. Keep the real guard; the probe already fakes csrf_check() and sends a POST. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Drag-and-drop reordering in automation SNMP, CDEF, VDEF, color template, graph and graph template pages, graph input removal, device template graph and data query add/remove, data input field removal, data source enable/disable, permission exception removal and the profile logout, reset and clear actions all wrote on GET and are not in the global GET denylist. Guard them with csrf_require_post() and send the loadUrl()-driven ones through the POST transport map. The profile logout request now posts its token. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
data_input.php form_save() now calls csrf_require_post(). The probe slices form_save() without that function, so the call died before the probe's validation_error shutdown assertion could pass. The probe stands in for a POST request, so it defines a no-op guard like the other sliced save probes. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
github-actions
Bot
force-pushed
the
fix/csrf-require-post-on-state-change
branch
from
November 26, 2026 08:50
48a7341 to
894ae1b
Compare
|
This branch has not been deployed
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.



This combines the three require-POST hardening batches into one branch. State-changing requests now reach their handlers only by POST with a valid token, and a GET to the same action is refused.
From #8609 (batch 1): the bulk-action execute branch of form_actions() in 17 core pages (aggregate graphs and templates, CDEFs, colors and color templates, data input, data queries, data source profiles, data sources, data templates, GPRINT presets, graph templates, graphs, device templates, pollers, sites and VDEFs) calls csrf_require_post(). It also adds the isolated probe and coverage fixtures that exercise each handler by GET, by tokenless POST and by valid POST, plus the CI fixes those probes needed.
From #8611 (batch 2): the same guard on the bulk-action execute branch of host.php, layouts.php, lib/html_reports.php, links.php, login_providers.php, managers.php, package_keys.php, package_repos.php, tree.php, user_admin.php and user_group_admin.php, with administration coverage fixtures and a crawl log filter for routine audit purge notes. Its CI and test-helper commits were identical to the ones from #8609, so they are carried once.
From #8613 (batch 3): form_save(), the automation form_actions() handlers and the POST-only direct actions (reordering, item moves and removals, drag-and-drop) in 30 pages call csrf_require_post(). The POST transport map in include/layout.js lists the newly guarded tree, links and automation actions, so the UI sends them by POST. A transport map test fails when a guarded action is still requested by GET, and a per-file probe covers each new guard.
Supersedes #8611, #8613.
Merge order: this PR and #8622 change layouts.php, this PR and #8704 change data_sources.php, and this PR and #8540 both add tests/e2e/tests/post-action-transport.spec.js. Suggested order: this PR first in each case, then #8622, #8704 and #8540. This PR and #8823 change the same lines of auth_profile.php, automation_templates.php and graph_templates.php in different ways, so no order is suggested between them; they need to be reconciled. Whichever merges later will be rebased.