Skip to content

FOUR-33091: Fix SQL Injection in ProcessMaker 4 advanced_filter - #9044

Open
caleeli wants to merge 2 commits into
developfrom
FOUR-33091
Open

FOUR-33091: Fix SQL Injection in ProcessMaker 4 advanced_filter#9044
caleeli wants to merge 2 commits into
developfrom
FOUR-33091

Conversation

@caleeli

@caleeli caleeli commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Issue & Reproduction Steps

advanced_filter allows any raw using the function raw(...).

Solution

  • Restrict restrict advanced_filter to validated temporal expressions, approved fields, and safe comparison operators.
  • The allowed fields:
    • created_at
    • updated_at
    • initiated_at
    • completed_at
    • due_at
    • started_at
  • The allowed operators:
    • =
    • !=
    • <
    • =

    • <=
    • between

Related Tickets & Packages

ci:deploy

@decisions-sonarqube

Copy link
Copy Markdown

@caleeli
caleeli requested a review from nolanpro September 7, 2026 21:23
@nolanpro

nolanpro commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://ci-f2ef5fdaf7.engk8s.processmaker.net

@ryancooley

Copy link
Copy Markdown
Contributor

cursor review

@cursor

cursor Bot commented Sep 8, 2026

Copy link
Copy Markdown

PR Summary

High Risk
This is a security fix on user-controlled advanced_filter SQL generation; incorrect validation could break legitimate date filters or leave injection gaps.

Overview
Closes an SQL injection path where advanced_filter accepted arbitrary content inside raw(...) and passed it into queries.

Raw value handling is rewritten so only raw(NOW()) and optional ± INTERVAL n UNIT forms are accepted (interval capped at 365), with 422 responses for invalid expressions, bad operators, or malformed between values. between is now a supported raw operator, including two raw bounds.

Context rules in BaseFilter limit raw usage on non-JSON fields to an allowlist of temporal columns (created_at, due_at, etc.); JSON data.* fields can still compare against validated NOW() expressions. JSON comparisons embed raw SQL via the query grammar when the value is an Expression.

Coverage adds unit and API tests for intervals, between, rejection of subquery payloads, and PHPUnit attribute grouping on ProcessRequestsTest.

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

@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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 9e23cf3. Configure here.

@caleeli
caleeli requested review from julceslauhub and removed request for nolanpro September 8, 2026 17:38
@nolanpro
nolanpro self-requested a review September 8, 2026 18:14
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.

3 participants