Skip to content

FOUR-34303 SQLi /api/1.0/processes/{process}/aggregation - #9130

Open
devmiguelangel wants to merge 10 commits into
developfrom
FOUR-34303
Open

devmiguelangel wants to merge 10 commits into
developfrom
FOUR-34303

Conversation

@devmiguelangel

@devmiguelangel devmiguelangel commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Issue & Reproduction Steps

SQLi /api/1.0/processes/{process}/aggregation

processes.aggregation was stored with no validation and later interpolated into Process::getProcessStageCounts():

sprintf("JSON_EXTRACT(data, '$.%s')", $amountKey)

A user who can create processes could save a value that closed the string literal and injected SQL into the SELECT list. The query ran on GET /api/1.0/processes/{process}/stage-mapping. The same column is also mass-assignable on process create, update, and import.

Solution

  • Bind the JSON path in getProcessStageCounts() and fall back to amount when the stored value is not a variable name.
  • Validate every write through AggregationVariable (Process::rules(), saveAggregation) and the HasAggregationAttribute mutator on Process and ProcessVersion, which also covers import.
  • Share the allowlist in JsonDataPath. BaseFilter now builds its JSON path through the same helper.

How to Test

  • ./vendor/bin/phpunit 'tests/Feature/Api/ProcessControllerTest.php'
  • ./vendor/bin/phpunit 'tests/Feature/ImportExport/Exporters/ProcessExporterTest.php'
  • ./vendor/bin/phpunit 'tests/unit/ProcessMaker/FilterTest.php'
  • ./vendor/bin/phpunit 'tests/unit/ProcessMaker/Support/JsonDataPathTest.php'
  • ./vendor/bin/phpunit 'tests/unit/ProcessMaker/Rules/AggregationVariableTest.php'

Related Tickets & Packages

FOUR-34303

Code Review Checklist

  • I have pulled this code locally and tested it on my instance, along with any associated packages.
  • This code adheres to ProcessMaker Coding Guidelines.
  • This code includes a unit test or an E2E test that tests its functionality, or is covered by an existing test.
  • This solution fixes the bug reported in the original ticket.
  • This solution does not alter the expected output of a component in a way that would break existing Processes.
  • This solution does not implement any breaking changes that would invalidate documentation or cause existing Processes to fail.
  • This solution has been tested with enterprise packages that rely on its functionality and does not introduce bugs in those packages.
  • This code does not duplicate functionality that already exists in the framework or in ProcessMaker.
  • This ticket conforms to the PRD associated with this part of ProcessMaker.

ci:deploy

@cursor

cursor Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches SQL construction and mass-assignable process fields; legacy aggregation values change behavior on version/duplicate but stage queries are hardened with fallbacks and parameter binding.

Overview
Fixes SQL injection where processes.aggregation was interpolated into JSON_EXTRACT in stage-mapping queries by binding a validated JSON path and defaulting to amount when stored values are invalid.

Adds shared JsonDataPath (plus AggregationVariable and HasAggregationAttribute) so create/update/import/save-aggregation and model mutators only accept variable-style names; BaseFilter builds filter JSON paths through the same helper. Legacy tampered values no longer break saves/duplicates/versions—they are coerced to the default on copy while reads still use the safe bound path.

Reviewed by Cursor Bugbot for commit 96d1fd9. Bugbot is set up for automated code reviews on this repo. Configure here.

@devmiguelangel devmiguelangel changed the title fix(processes): bind aggregation json path to prevent SQL injection FOUR-34303 SQLi /api/1.0/processes/{process}/aggregation Nov 10, 2026
@devmiguelangel devmiguelangel self-assigned this Nov 10, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6b2ccfa. Configure here.

@cursor
cursor Bot requested review from gproly and nolanpro November 10, 2026 16:06
@nolanpro

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://tenant-1.ci-cab54a1756.engk8s.processmaker.net

@nolanpro

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://tenant-1.ci-cab54a1756.engk8s.processmaker.net

@decisions-sonarqube

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants