Skip to content

fix(model): validate calculated property SQL at config time#2067

Merged
bpamiri merged 2 commits into
developfrom
peter/fix-calculated-property-sql-injection
Apr 10, 2026
Merged

fix(model): validate calculated property SQL at config time#2067
bpamiri merged 2 commits into
developfrom
peter/fix-calculated-property-sql-injection

Conversation

@bpamiri
Copy link
Copy Markdown
Collaborator

@bpamiri bpamiri commented Apr 10, 2026

Summary

  • Adds $validateCalculatedPropertySql() that rejects dangerous SQL patterns (UNION, EXEC, xp_, SLEEP, BENCHMARK, LOAD_FILE, INTO OUTFILE/DUMPFILE) when property(sql="...") is called during model config
  • Defense-in-depth against supply-chain attacks or accidental injection of user input into calculated property SQL expressions
  • Validation runs once at model config time (app startup), not per-query — zero runtime performance impact

Test plan

  • New test spec: vendor/wheels/tests/specs/security/CalculatedPropertySqlSpec.cfc covers rejection of 9 dangerous patterns and acceptance of 5 legitimate SQL expressions
  • Run bash tools/test-local.sh model — no regressions
  • Run bash tools/test-local.sh security — new tests pass

Adds $validateCalculatedPropertySql() that rejects dangerous SQL patterns
(UNION, EXEC, xp_, SLEEP, BENCHMARK, LOAD_FILE, INTO OUTFILE/DUMPFILE)
when property(sql="...") is called during model config. Defense-in-depth
against supply-chain or accidental injection of user input into calculated
property SQL expressions.
- Change semicolon pattern from ;\s to bare ; (no legitimate semicolons
  in calculated property expressions)
- Change EXEC\s to \bEXEC(UTE)?\b to catch both EXEC and EXECUTE as
  whole words, including EXECUTE('dynamic sql') without spaces
- Add \b word boundaries to UNION to prevent false positives
- Add tests for bare semicolons and EXECUTE keyword
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant