-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
MDEV-40151: Galera SST: InnoDB/Aria directory & buffer-pool parameters interpolated unsanitized into eval-ed shell commands #5570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hemantdangi-gc
wants to merge
7
commits into
MariaDB:10.11
Choose a base branch
from
mariadb-corporation:10.11-MDEV-40151
base: 10.11
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
55da664
MDEV-40151: Galera SST: reject shell-unsafe datadir/socket before sh -c
hemantdangi-gc 0517202
MDEV-40151: Galera SST: escape backquotes in forwarded mysqld arguments
hemantdangi-gc fd80f78
MDEV-40151: Galera SST: build mariadb-backup command from arrays
hemantdangi-gc cd09dda
MDEV-40151: Galera SST: reject a newline in rsyncd.conf path values
hemantdangi-gc 902249f
MDEV-40151: Galera SST: build rsync donor FILTER from an array
hemantdangi-gc 99226e2
MDEV-40151: Galera SST: add donor-side datadir injection test
hemantdangi-gc f426ca1
MDEV-40151: Galera SST: add mysqldump donor-side datadir injection test
hemantdangi-gc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
mysql-test/suite/galera/r/galera_sst_buffer_pool_injection.result
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| connection node_2; | ||
| connection node_1; | ||
| SELECT 1; | ||
| 1 | ||
| 1 | ||
| connection node_1; | ||
| call mtr.add_suppression('Process completed with error'); | ||
| call mtr.add_suppression('State transfer to .* failed'); | ||
| call mtr.add_suppression('Will never receive state. Need to abort'); | ||
| connection node_2; | ||
| buffer-pool injection prevented | ||
| FOUND 1 /Running: .*mariadb-backup --prepare/ in mysqld.2.err | ||
| connection node_2; | ||
| call mtr.add_suppression('Process completed with error'); | ||
| call mtr.add_suppression('WSREP_SST:'); | ||
| call mtr.add_suppression('Will never receive state. Need to abort'); | ||
| call mtr.add_suppression('State transfer to .* failed'); | ||
| call mtr.add_suppression('SST .* failed'); |
28 changes: 28 additions & 0 deletions
28
mysql-test/suite/galera/r/galera_sst_datadir_injection.result
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| connection node_2; | ||
| connection node_1; | ||
| SELECT 1; | ||
| 1 | ||
| 1 | ||
| FOUND 1 /wsrep_sst_rsync/ in mysqld.1.err | ||
| connection node_1; | ||
| call mtr.add_suppression('unsafe for shell interpolation'); | ||
| call mtr.add_suppression('Process completed with error'); | ||
| call mtr.add_suppression('State transfer to .* failed'); | ||
| call mtr.add_suppression('Will never receive state. Need to abort'); | ||
| connection node_2; | ||
| connection node_2; | ||
| FOUND 1 /unsafe for shell interpolation/ in mysqld.2.err | ||
| datadir injection prevented | ||
| connection node_2; | ||
| call mtr.add_suppression('Illegal character in variable'); | ||
| call mtr.add_suppression('unsafe for shell interpolation'); | ||
| call mtr.add_suppression('WSREP_SST:'); | ||
| call mtr.add_suppression('Failed to read .* from: wsrep_sst_rsync'); | ||
| call mtr.add_suppression('Failed to prepare for .* SST'); | ||
| call mtr.add_suppression('SST preparation failed'); | ||
| call mtr.add_suppression('SST request callback failed'); | ||
| call mtr.add_suppression('Will never receive state. Need to abort'); | ||
| call mtr.add_suppression('Parent mysqld process .* terminated unexpectedly'); | ||
| call mtr.add_suppression('Cleanup after exit with status'); | ||
| call mtr.add_suppression('State transfer to .* failed'); | ||
| call mtr.add_suppression('SST .* failed'); |
21 changes: 21 additions & 0 deletions
21
mysql-test/suite/galera/r/galera_sst_datadir_spaces.result
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| connection node_2; | ||
| connection node_1; | ||
| SELECT 1; | ||
| 1 | ||
| 1 | ||
| connection node_1; | ||
| call mtr.add_suppression('Process completed with error'); | ||
| call mtr.add_suppression('State transfer to .* failed'); | ||
| call mtr.add_suppression('Will never receive state. Need to abort'); | ||
| connection node_2; | ||
| connection node_2; | ||
| SELECT 1; | ||
| 1 | ||
| 1 | ||
| connection node_2; | ||
| connection node_2; | ||
| call mtr.add_suppression('Process completed with error'); | ||
| call mtr.add_suppression('WSREP_SST:'); | ||
| call mtr.add_suppression('Will never receive state. Need to abort'); | ||
| call mtr.add_suppression('State transfer to .* failed'); | ||
| call mtr.add_suppression('SST .* failed'); |
20 changes: 20 additions & 0 deletions
20
mysql-test/suite/galera/r/galera_sst_donor_datadir_injection.result
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| connection node_2; | ||
| connection node_1; | ||
| connection node_1; | ||
| call mtr.add_suppression('Process completed with error'); | ||
| call mtr.add_suppression('WSREP_SST:'); | ||
| call mtr.add_suppression('State transfer to .* failed'); | ||
| call mtr.add_suppression('SST failed'); | ||
| call mtr.add_suppression('SST preparation failed'); | ||
| call mtr.add_suppression('Will never receive state. Need to abort'); | ||
| call mtr.add_suppression('unsafe for shell interpolation'); | ||
| call mtr.add_suppression('Illegal character in variable'); | ||
| connection node_2; | ||
| FOUND 1 /unsafe for shell interpolation/ in mysqld.1.err | ||
| donor-side datadir injection prevented | ||
| FOUND 1 /Parent mysqld process .* terminated unexpectedly/ in mysqld.2.err | ||
| # restart | ||
| call mtr.add_suppression('Process completed with error'); | ||
| call mtr.add_suppression('WSREP_SST:'); | ||
| call mtr.add_suppression('State transfer to .* failed'); | ||
| call mtr.add_suppression('Will never receive state. Need to abort'); |
26 changes: 26 additions & 0 deletions
26
mysql-test/suite/galera/r/galera_sst_donor_datadir_injection_mysqldump.result
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| connection node_2; | ||
| connection node_1; | ||
| connection node_1; | ||
| call mtr.add_suppression('Process completed with error'); | ||
| call mtr.add_suppression('WSREP_SST:'); | ||
| call mtr.add_suppression('State transfer to .* failed'); | ||
| call mtr.add_suppression('SST failed'); | ||
| call mtr.add_suppression('SST preparation failed'); | ||
| call mtr.add_suppression('Will never receive state. Need to abort'); | ||
| call mtr.add_suppression('unsafe for shell interpolation'); | ||
| call mtr.add_suppression('Illegal character in variable'); | ||
| CREATE USER 'sst'; | ||
| GRANT ALL PRIVILEGES ON *.* TO 'sst'; | ||
| SET GLOBAL wsrep_sst_auth = 'sst:'; | ||
| connection node_2; | ||
| FOUND 1 /unsafe for shell interpolation/ in mysqld.1.err | ||
| donor-side datadir injection prevented | ||
| connection node_1; | ||
| SET GLOBAL wsrep_sst_auth = ''; | ||
| DROP USER 'sst'; | ||
| connection node_2; | ||
| # restart | ||
| call mtr.add_suppression('Process completed with error'); | ||
| call mtr.add_suppression('WSREP_SST:'); | ||
| call mtr.add_suppression('State transfer to .* failed'); | ||
| call mtr.add_suppression('Will never receive state. Need to abort'); |
18 changes: 18 additions & 0 deletions
18
mysql-test/suite/galera/r/galera_sst_mysqld_args_injection.result
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| connection node_2; | ||
| connection node_1; | ||
| SELECT 1; | ||
| 1 | ||
| 1 | ||
| connection node_1; | ||
| call mtr.add_suppression('Process completed with error'); | ||
| call mtr.add_suppression('State transfer to .* failed'); | ||
| call mtr.add_suppression('Will never receive state. Need to abort'); | ||
| connection node_2; | ||
| backquote injection prevented | ||
| connection node_2; | ||
| call mtr.add_suppression('Process completed with error'); | ||
| call mtr.add_suppression('WSREP_SST:'); | ||
| call mtr.add_suppression('Will never receive state. Need to abort'); | ||
| call mtr.add_suppression('State transfer to .* failed'); | ||
| call mtr.add_suppression('SST .* failed'); | ||
| call mtr.add_suppression('InnoDB: Cannot open .* for writing'); |
4 changes: 4 additions & 0 deletions
4
mysql-test/suite/galera/r/galera_sst_rsyncd_conf_injection.result
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| connection node_2; | ||
| connection node_1; | ||
| REJECTED_newline | ||
| PASS_clean |
6 changes: 6 additions & 0 deletions
6
mysql-test/suite/galera/t/galera_sst_buffer_pool_injection.cnf
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| !include ../galera_2nodes.cnf | ||
|
|
||
| [mysqld] | ||
| wsrep_sst_method=mariabackup | ||
| wsrep_sst_auth="root:" | ||
| wsrep_debug=1 | ||
76 changes: 76 additions & 0 deletions
76
mysql-test/suite/galera/t/galera_sst_buffer_pool_injection.test
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # | ||
| # mariabackup SST must pass innodb-buffer-pool-filename to mariadb-backup as a | ||
| # literal argument, so that shell metacharacters in it are not executed. | ||
| # | ||
| # Steps: | ||
| # 1. Bring up a 2-node mariabackup-SST cluster. | ||
| # 2. Force a full SST on node_2, restarting it with an | ||
| # innodb-buffer-pool-filename carrying a "touch <marker>" payload. It has | ||
| # to be on the command line: the SST script has no config-file fallback | ||
| # for this option. | ||
| # 3. Assert node_2 joins, the payload did not run, and the mariadb-backup | ||
| # command line is still logged. | ||
| # 4. Restart node_2 cleanly and rejoin. | ||
| # | ||
|
|
||
| --source include/galera_cluster.inc | ||
| --source include/have_innodb.inc | ||
| --source include/have_mariabackup.inc | ||
|
|
||
| SELECT 1; | ||
|
|
||
| --let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' | ||
| --source include/wait_condition.inc | ||
|
|
||
| --connection node_1 | ||
| call mtr.add_suppression('Process completed with error'); | ||
| call mtr.add_suppression('State transfer to .* failed'); | ||
| call mtr.add_suppression('Will never receive state. Need to abort'); | ||
|
|
||
| --connection node_2 | ||
| --source include/shutdown_mysqld.inc | ||
|
|
||
| --remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat | ||
| perl; | ||
| unlink "$ENV{MYSQL_TMP_DIR}/bp_inj_marker"; | ||
| EOF | ||
|
|
||
| # $start_mysqld_params is split on whitespace with no quote handling, so the | ||
| # payload must be a single space-free token; ">file" (a bare redirection, | ||
| # needs no command name or space) is used as the marker-creation payload. | ||
| --let $start_mysqld_params = --innodb-buffer-pool-filename=x'>$MYSQL_TMP_DIR/bp_inj_marker&'y | ||
| --source include/start_mysqld.inc | ||
| --let $start_mysqld_params = | ||
|
|
||
| --let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' | ||
| --source include/wait_condition.inc | ||
|
|
||
| perl; | ||
| die "FAIL: marker created - buffer-pool injection was NOT prevented\n" | ||
| if -e "$ENV{MYSQL_TMP_DIR}/bp_inj_marker"; | ||
| print "buffer-pool injection prevented\n"; | ||
| EOF | ||
|
|
||
| # SST failures are diagnosed from the logged command line | ||
| --let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.2.err | ||
| --let SEARCH_PATTERN = Running: .*mariadb-backup --prepare | ||
| --source include/search_pattern_in_file.inc | ||
|
|
||
| # restart node_2 cleanly (no malicious arg) and rejoin | ||
| --connection node_2 | ||
| --source include/shutdown_mysqld.inc | ||
| --remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat | ||
| --source include/start_mysqld.inc | ||
|
|
||
| --let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' | ||
| --source include/wait_condition.inc | ||
|
|
||
| perl; | ||
| unlink "$ENV{MYSQL_TMP_DIR}/bp_inj_marker"; | ||
| EOF | ||
|
|
||
| call mtr.add_suppression('Process completed with error'); | ||
| call mtr.add_suppression('WSREP_SST:'); | ||
| call mtr.add_suppression('Will never receive state. Need to abort'); | ||
| call mtr.add_suppression('State transfer to .* failed'); | ||
| call mtr.add_suppression('SST .* failed'); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| !include ../galera_2nodes.cnf | ||
|
|
||
| [mysqld] | ||
| wsrep_sst_method=rsync | ||
| wsrep_debug=1 |
97 changes: 97 additions & 0 deletions
97
mysql-test/suite/galera/t/galera_sst_datadir_injection.test
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| # | ||
| # mysqld must reject a datadir containing shell metacharacters before it | ||
| # builds the SST command line that it runs via sh -c. | ||
| # | ||
| # Steps: | ||
| # 1. Bring up a 2-node rsync-SST cluster. | ||
| # 2. Move node 2's datadir to a name carrying a "touch <marker>" payload and | ||
| # force a full SST. | ||
| # 3. Assert node 2 refuses the datadir and the payload did not run. | ||
| # 4. Restore the datadir and rejoin. | ||
| # | ||
|
|
||
| --source include/galera_cluster.inc | ||
| --source include/have_innodb.inc | ||
|
|
||
| SELECT 1; | ||
|
|
||
| --let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' | ||
| --source include/wait_condition.inc | ||
|
|
||
| # sanity: initial SST used rsync | ||
| --let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err | ||
| --let SEARCH_PATTERN = wsrep_sst_rsync | ||
| --source include/search_pattern_in_file.inc | ||
|
|
||
| --connection node_1 | ||
| call mtr.add_suppression('unsafe for shell interpolation'); | ||
| call mtr.add_suppression('Process completed with error'); | ||
| call mtr.add_suppression('State transfer to .* failed'); | ||
| call mtr.add_suppression('Will never receive state. Need to abort'); | ||
|
|
||
| --connection node_2 | ||
| --source include/shutdown_mysqld.inc | ||
|
|
||
| # move the datadir to a name carrying a shell-injection payload | ||
| perl; | ||
| use strict; | ||
| use File::Path; | ||
| my $tmp = $ENV{MYSQL_TMP_DIR}; | ||
| my $vardir = $ENV{MYSQLTEST_VARDIR}; | ||
| my $marker = "$tmp/datadir_inj_marker"; | ||
| my $ddir = "$tmp/dd_inj'&touch $marker&'x"; | ||
| my $cnf = "$vardir/my.cnf"; | ||
| unlink $marker; | ||
| (my $parent = $ddir) =~ s{/[^/]+$}{}; | ||
| mkpath($parent); | ||
| rename("$vardir/mysqld.2/data", $ddir) or die "rename datadir: $!"; | ||
| unlink "$ddir/grastate.dat"; | ||
| open(my $sz, '>', "$tmp/inj_cnf_size") or die $!; print $sz -s $cnf; close $sz; | ||
| open(my $fh, '>>', $cnf) or die $!; print $fh "[mysqld.2]\ndatadir=\"$ddir\"\n"; close $fh; | ||
| EOF | ||
|
|
||
| --connection node_2 | ||
| --error 1,134 | ||
| --exec $MYSQLD_LAST_CMD | ||
|
|
||
| --let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.2.err | ||
| --let SEARCH_PATTERN = unsafe for shell interpolation | ||
| --source include/search_pattern_in_file.inc | ||
|
|
||
| perl; | ||
| die "FAIL: marker created - datadir injection was NOT prevented\n" | ||
| if -e "$ENV{MYSQL_TMP_DIR}/datadir_inj_marker"; | ||
| print "datadir injection prevented\n"; | ||
| EOF | ||
|
|
||
| # restore datadir and rejoin | ||
| perl; | ||
| use strict; | ||
| my $tmp = $ENV{MYSQL_TMP_DIR}; | ||
| my $vardir = $ENV{MYSQLTEST_VARDIR}; | ||
| my $cnf = "$vardir/my.cnf"; | ||
| open(my $sz, '<', "$tmp/inj_cnf_size") or die $!; my $orig = <$sz>; close $sz; | ||
| truncate($cnf, $orig) or die "truncate: $!"; | ||
| unlink "$tmp/datadir_inj_marker", "$tmp/inj_cnf_size"; | ||
| rename("$tmp/dd_inj'&touch $tmp/datadir_inj_marker&'x", "$vardir/mysqld.2/data") | ||
| or die "restore datadir: $!"; | ||
| EOF | ||
|
|
||
| --connection node_2 | ||
| --source include/start_mysqld.inc | ||
| --let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' | ||
| --source include/wait_condition.inc | ||
|
|
||
| # suppress the rejected-SST noise on the final node_2 instance | ||
| call mtr.add_suppression('Illegal character in variable'); | ||
| call mtr.add_suppression('unsafe for shell interpolation'); | ||
| call mtr.add_suppression('WSREP_SST:'); | ||
| call mtr.add_suppression('Failed to read .* from: wsrep_sst_rsync'); | ||
| call mtr.add_suppression('Failed to prepare for .* SST'); | ||
| call mtr.add_suppression('SST preparation failed'); | ||
| call mtr.add_suppression('SST request callback failed'); | ||
| call mtr.add_suppression('Will never receive state. Need to abort'); | ||
| call mtr.add_suppression('Parent mysqld process .* terminated unexpectedly'); | ||
| call mtr.add_suppression('Cleanup after exit with status'); | ||
| call mtr.add_suppression('State transfer to .* failed'); | ||
| call mtr.add_suppression('SST .* failed'); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| !include ../galera_2nodes.cnf | ||
|
|
||
| [mysqld] | ||
| wsrep_sst_method=rsync | ||
| wsrep_debug=1 |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why these test are run only for either rsync or mariabackup not both and especially not for mysqldump?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why rsync-only for some, mariabackup-only for others?
And for why mysqldump specifically is missing?