Skip to content

Fix SQL injection via unvalidated table, view and column identifiers - #379

Merged
techmahedy merged 3 commits into
doppar:4.xfrom
techmahedy:techmahedy-4.x
Oct 19, 2026
Merged

techmahedy merged 3 commits into
doppar:4.xfrom
techmahedy:techmahedy-4.x

Conversation

@techmahedy

@techmahedy techmahedy commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Pull Request Checklist

Q A
Branch? 4.x
Bug fix? yes
New feature? no
Deprecations? no
Issues -
License MIT

This PR solves two problems

  1. Fix SQL injection via unvalidated table, view and column identifiers
  2. Fix PostgreSQL temporal lookups reading times in the session timezone

Security

Significantly improved

Summary

Identifiers passed to Database::view() and Grammar::getTableColumnsSql() were interpolated directly into SQL. Prepared statements protect values, not identifiers, so user-controlled input reaching these methods allowed SQL injection.

Changes

  • Grammar::getTableColumnsSql(): validate the table name with assertValidIdentifier() and quote it in the SQLite (PRAGMA table_info) and MySQL (DESCRIBE) queries. The PostgreSQL query validates before interpolating its string literal.
  • Database::view(): validate the view name (name or schema.name) and quote it per driver.
  • Database::view(): validate the column names from $where (plain identifiers only) and quote them in the condition. Values remain bound parameters.
  • Invalid identifiers throw InvalidArgumentException.

Checklist

  • Tests have been added or updated
  • Documentation has been updated if necessary
  • Code follows the project coding standards
  • All tests pass locally

@techmahedy techmahedy added the bug Something isn't working label Oct 19, 2026
@techmahedy techmahedy added enhancement New feature or request Security Fix Security Fix labels Oct 19, 2026
@techmahedy
techmahedy merged commit fbd3577 into doppar:4.x Oct 19, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request Security Fix Security Fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant