Skip to content

fix: escape single quotes in $quoteValue() to prevent SQL injection#2033

Merged
bpamiri merged 2 commits intodevelopfrom
peter/fix-sql-injection-quotevalue
Apr 9, 2026
Merged

fix: escape single quotes in $quoteValue() to prevent SQL injection#2033
bpamiri merged 2 commits intodevelopfrom
peter/fix-sql-injection-quotevalue

Conversation

@bpamiri
Copy link
Copy Markdown
Collaborator

@bpamiri bpamiri commented Apr 9, 2026

Summary

  • Critical SQL injection fix in $quoteValue() (vendor/wheels/databaseAdapters/Base.cfc)
  • The function wrapped string values in single quotes without escaping embedded quotes, allowing payloads like test' OR '1'='1 to break out of the quoted context
  • Fix: Replace(arguments.str, "'", "''", "all") before wrapping in quotes — standard SQL single-quote escaping
  • Added QuoteValueSpec.cfc with 9 test cases covering injection payloads, edge cases, and numeric passthrough

Test plan

  • CI passes across all engines (Lucee 5/6/7, Adobe 2018/2021/2023/2025, BoxLang) with SQLite
  • Verify $quoteValue("test' OR '1'='1") returns 'test'' OR ''1''=''1' (escaped)
  • Verify numeric types still pass through unquoted
  • Verify empty strings are still quoted (not passed through as numeric)

🤖 Generated with Claude Code

$quoteValue() wrapped strings in single quotes without escaping embedded
quotes, allowing values like "test' OR '1'='1" to break out of the
quoted context. Now escapes ' → '' before quoting.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
SQLite is the primary test database. Avoids coupling tests to H2
which may not be available in all environments.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bpamiri bpamiri merged commit 21c16d4 into develop Apr 9, 2026
3 checks passed
@bpamiri bpamiri deleted the peter/fix-sql-injection-quotevalue branch April 9, 2026 08:32
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