[MDEV-27780] 'CHANGE MASTER' command (and many others) do not support bind parameters Created: 2022-02-08 Updated: 2023-02-23 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Prepared Statements |
| Affects Version/s: | 10.6.5 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Daniel Lenski | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | replication | ||
| Description |
|
According to the documentation, the CHANGE MASTER TO statement is permitted within dynamically composed SQL statements (via PREPARE/EXECUTE and/or EXECUTE IMMEDIATE). However, unlike other statements, the CHANGE MASTER TO statement does not support bind parameters. Evidence for this limitation on 10.6.5:
Furthermore, CHANGE MASTER TO cannot be used in stored procedures except when wrapped in wrapping dynamic SQL. (Also, the "Stored Routine Limitations" docs don't mention it as an exception to permitted statements.) Because of these limitations, the only way to execute CHANGE MASTER TO with variable parameters in stored procedures is to interpolate these variables’ values directly into a dynamically composed SQL string. This means that there is a large attack surface for SQL injection if potentially-untrusted values are provided to CHANGE MASTER TO in this way. Questions:
|
| Comments |
| Comment by Daniel Lenski [ 2022-02-09 ] |
|
I updated "Stored Routine Limitations" to reflect the fact that CHANGE MASTER TO isn't permitted. https://mariadb.com/kb/en/stored-routine-limitations/+r/112995/ |
| Comment by Daniel Lenski [ 2022-11-02 ] |
|
It appears this issue is also present in MySQL; I tested on v8.0. Also undocumented there: https://dev.mysql.com/doc/refman/8.0/en/sql-prepared-statements.html#prepared-statements-permitted |
| Comment by Daniel Lenski [ 2023-02-22 ] |
|
This would be a ripe opportunity for test-driven development. Start fixing this by creating a test that tries using bind parameters for pretty much every variant of pretty much every known query type:
|