fix(manager): validate table identifiers before they reach raw SQL - #2450
Open
elcreator wants to merge 1 commit into
Open
fix(manager): validate table identifiers before they reach raw SQL#2450elcreator wants to merge 1 commit into
elcreator wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.