Skip to content

fix(manager): validate table identifiers before they reach raw SQL - #2450

Open
elcreator wants to merge 1 commit into
evolution-cms:3.5.xfrom
elcreator:fix/table-name-whitelist
Open

fix(manager): validate table identifiers before they reach raw SQL#2450
elcreator wants to merge 1 commit into
evolution-cms:3.5.xfrom
elcreator:fix/table-name-whitelist

Conversation

@elcreator

Copy link
Copy Markdown

a=54 read the table to OPTIMIZE or TRUNCATE straight from $_REQUEST and put it into a statement unquoted, so a manager holding settings + logs - without bk_manager, and therefore without the restore form that runs SQL by design - could append SQL of its own or truncate any table. The backup manager passed its checkbox list on to pg_dump on a command line the same way.

Both now go through Database::isValidTableName(): a bare identifier carrying the configured prefix. The pattern is the whole guard, since nothing matching it can leave the identifier it is substituted into. Existence is deliberately not checked - an unknown table is a failing statement rather than an injection, and a catalogue lookup would tie every optimize to schema read rights the hosting may not grant.

TRUNCATE keeps the raw expression because the builder would otherwise prefix an already prefixed name.

a=54 read the table to OPTIMIZE or TRUNCATE straight from $_REQUEST and
put it into a statement unquoted, so a manager holding settings + logs -
without bk_manager, and therefore without the restore form that runs SQL
by design - could append SQL of its own or truncate any table. The
backup manager passed its checkbox list on to pg_dump on a command line
the same way.

Both now go through Database::isValidTableName(): a bare identifier
carrying the configured prefix. The pattern is the whole guard, since
nothing matching it can leave the identifier it is substituted into.
Existence is deliberately not checked - an unknown table is a failing
statement rather than an injection, and a catalogue lookup would tie
every optimize to schema read rights the hosting may not grant.

TRUNCATE keeps the raw expression because the builder would otherwise
prefix an already prefixed name.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YSZQgDv5ASxQaiYd5C1nJR
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.

1 participant