Skip to content

hardening: encode selected items written back into export scripts and confirm forms - #8448

Open
somethingwithproof wants to merge 6 commits into
Cacti:developfrom
somethingwithproof:security/selected-items-js-develop
Open

somethingwithproof wants to merge 6 commits into
Cacti:developfrom
somethingwithproof:security/selected-items-js-develop

Conversation

@somethingwithproof

@somethingwithproof somethingwithproof commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

This change makes export and confirmation pages encode selected items for the context where they are displayed. Download links are rebuilt from validated selections and encoded as JavaScript values, and hidden fields receive attribute encoding. This preserves the intended selection while preventing request text from becoming executable page content.

Implementation details

Export and download actions printed the raw selected_items request value into an inline script. They now build the URL from the validated selection with cacti_url() and emit it with cacti_js_encode(). form_continue_confirmation() escapes the serialized selection in its hidden input with html_escape_attr(), so the browser posts back the original value.

sanitize_unserialize_selected_items() is unchanged; every output re-serializes the validated array instead of echoing the request.

Tests: new Pest cases plus request-coverage probes for every export branch and the confirmation form; changed-line coverage 9/9. The new cases fail against the previous page files.

Revision and checks

Description scope: target develop, 15 changed files, head efa03117a. Checked 2026-10-23 03:06:04 UTC.

GitHub check snapshot: 37 passed, 2 failed, 5 skipped, 1 neutral. Checks needing attention: PHP 8.3 locked integration, CI / required. Local test figures and earlier CI runs above are recorded evidence for their stated revisions and environments; they do not assert that every check passes at this head.

Fixes #8881.

@somethingwithproof
somethingwithproof requested a review from a team as a code owner October 22, 2026 21:40
@somethingwithproof
somethingwithproof requested review from TheWitness and removed request for a team October 22, 2026 21:40
somethingwithproof added a commit to somethingwithproof/cacti that referenced this pull request Oct 22, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
somethingwithproof added a commit to somethingwithproof/cacti that referenced this pull request Oct 24, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof
somethingwithproof force-pushed the security/selected-items-js-develop branch from efa0311 to 9b2af08 Compare October 24, 2026 06:53
github-actions Bot pushed a commit to somethingwithproof/cacti that referenced this pull request Oct 26, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@github-actions
github-actions Bot force-pushed the security/selected-items-js-develop branch from 69b0f2f to 873f2c4 Compare October 26, 2026 20:50
somethingwithproof added a commit to somethingwithproof/cacti that referenced this pull request Nov 2, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof
somethingwithproof force-pushed the security/selected-items-js-develop branch from 873f2c4 to 74c6083 Compare November 2, 2026 20:10
github-actions Bot pushed a commit to somethingwithproof/cacti that referenced this pull request Nov 3, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@github-actions
github-actions Bot force-pushed the security/selected-items-js-develop branch from 74c6083 to 66905b2 Compare November 3, 2026 20:47
somethingwithproof added a commit to somethingwithproof/cacti that referenced this pull request Nov 9, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof
somethingwithproof force-pushed the security/selected-items-js-develop branch from d537281 to 8cd7026 Compare November 9, 2026 08:01
github-actions Bot pushed a commit to somethingwithproof/cacti that referenced this pull request Nov 9, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@github-actions
github-actions Bot force-pushed the security/selected-items-js-develop branch from 8cd7026 to c2d9d86 Compare November 9, 2026 20:50
somethingwithproof added a commit to somethingwithproof/cacti that referenced this pull request Nov 12, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof
somethingwithproof force-pushed the security/selected-items-js-develop branch from acfb554 to 457e016 Compare November 12, 2026 07:51
@somethingwithproof somethingwithproof added this to the v1.3.0 milestone Nov 13, 2026
@somethingwithproof somethingwithproof added bug Undesired behaviour import/export Related to Import and Export of Template and Packages release:1.3 Namespaced Cacti workflow label labels Nov 13, 2026
somethingwithproof added a commit to somethingwithproof/cacti that referenced this pull request Nov 17, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof
somethingwithproof force-pushed the security/selected-items-js-develop branch from 457e016 to 4e7fe1d Compare November 17, 2026 21:43
github-actions Bot pushed a commit to somethingwithproof/cacti that referenced this pull request Nov 19, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@github-actions
github-actions Bot force-pushed the security/selected-items-js-develop branch from 4d5f5fb to e78efe0 Compare November 19, 2026 20:51
somethingwithproof added a commit to somethingwithproof/cacti that referenced this pull request Nov 25, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof
somethingwithproof force-pushed the security/selected-items-js-develop branch from 26359a3 to ac0d736 Compare November 25, 2026 08:04
github-actions Bot pushed a commit to somethingwithproof/cacti that referenced this pull request Nov 25, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@github-actions
github-actions Bot force-pushed the security/selected-items-js-develop branch from ac0d736 to 282e52e Compare November 25, 2026 20:50
Build export and download URLs from the validated selection with cacti_url() and cacti_js_encode(), and escape the serialized selection in the confirmation form's hidden input.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Run the real form_actions() export branches and form_continue_confirmation() in probe processes so the request coverage gate measures the changed lines.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The selected items probe was registered only for the request-coverage gate,
so changed-coverage saw every changed line as uninstrumented. Register it in
run_pr_change_tests.sh, load FixtureCoverage.php in the probe processes and
merge their per-process coverage into the runner's report.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The trailing-bytes cases required sanitize_unserialize_selected_items() to
accept a value with bytes after the array. That is the decoder's contract,
not this change's. Let the export probe report when a page emits no download
and require only that the extra bytes never reach the page; a normal
selection must still produce the download.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@github-actions
github-actions Bot force-pushed the security/selected-items-js-develop branch from 282e52e to a973f77 Compare November 26, 2026 08:52
@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Undesired behaviour import/export Related to Import and Export of Template and Packages release:1.3 Namespaced Cacti workflow label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hardening: encode selected items for their output context in export scripts and confirmation forms

1 participant