Skip to content

Commit 3dadc95

Browse files
author
Arun Kuruvila
committed
Bug#28569645: SQL INJECTION ON SLAVE DUE TO NON-QUOTING IN
BINLOGGED ROLLBACK TO SAVEPOINT Description: SQL injection is possible on slave due to incorrect binlogging of 'ROLLBACK TO SAVEPOINT' statements. Analysis: Whenever an identifier is written to binary log, it should be properly quoted to prevent any SQL injection on the slave. For binlogging of 'ROLLBACK TO SAVEPOINT' statements, this is correctly fixed on 5.5 by the patch for Bug#14548159, but the fix is missing from 5.6+. Fix: Added proper binlogging for 'ROLLBACK TO SAVEPOINT' statements.
1 parent 97cac4a commit 3dadc95

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

sql/binlog.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,11 +1860,19 @@ static int binlog_savepoint_rollback(handlerton *hton, THD *thd, void *sv)
18601860
if (trans_cannot_safely_rollback(thd))
18611861
{
18621862
String log_query;
1863-
if (log_query.append(STRING_WITH_LEN("ROLLBACK TO ")) ||
1864-
log_query.append("`") ||
1865-
log_query.append(thd->lex->ident.str, thd->lex->ident.length) ||
1866-
log_query.append("`"))
1863+
if (log_query.append(STRING_WITH_LEN("ROLLBACK TO ")))
18671864
DBUG_RETURN(1);
1865+
else
1866+
{
1867+
/*
1868+
Before writing identifier to the binlog, make sure to
1869+
quote the identifier properly so as to prevent any SQL
1870+
injection on the slave.
1871+
*/
1872+
append_identifier(thd, &log_query, thd->lex->ident.str,
1873+
thd->lex->ident.length);
1874+
}
1875+
18681876
int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);
18691877
Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(),
18701878
TRUE, FALSE, TRUE, errcode);

0 commit comments

Comments
 (0)