# Release of Vitess v24.0.6 ## Summary ### ZooKeeper topology znodes are restricted to the `--topo-zk-auth-file` identity With `--topo-zk-auth-file` set, `zk2topo` authenticated its ZooKeeper session but still created every znode, lock and election nodes included, with a `world:anyone` ACL, so any client that could reach the ensemble could read, change or delete the topology ([GHSA-9c2c-hxwj-c5jr](https://github.com/vitessio/vitess/security/advisories/GHSA-9c2c-hxwj-c5jr)). Znodes are now created with ZooKeeper's `auth` ACL scheme, so only the auth file's identity can access them. A missing, unreadable or malformed auth file, or a failed `AddAuth`, now fails the connection instead of continuing unauthenticated. A `digest` auth file must hold both a user and a password, and a trailing CR is dropped like a trailing LF. `vtctldclient`, `topo2topo` and the `zk` tool now take the `--topo-zk-*` flags, and `vttestserver` passes `--topo-zk-auth-file` and the `--topo-zk-tls-*` flags on to `vtcombo`. Without an auth file, nothing changes. #### Impact - Every component that shares the topology must use the same ZooKeeper identity, `vtctldclient --server internal` and `topo2topo` included. A component with another identity, or none, gets `zk: not authenticated`. - A component whose auth file can't be read or parsed, or a `digest` file without a password, now fails every topology call. Before upgrading, check that no component logs `failed to read topo-zk-auth-file`, `failed to parse topo-zk-auth-file contents` or `failed to add auth from topo-zk-auth-file`. - Znodes created before the upgrade keep their `world:anyone` ACLs. Once every component runs this release with the auth file, run `addauth digest :` in `zkCli.sh`, then `setAcl -R auth::cdrwa` on the common parent of the global and cell roots (for example `/vitess`), in each ZooKeeper ensemble. Credential rotation and first-time setup are described in [#22231](https://github.com/vitessio/vitess/pull/22231). See [#22231](https://github.com/vitessio/vitess/pull/22231) for details. ### gRPC mTLS authorization checks only the verified client certificate With `--grpc-auth-mode=mtls`, `--grpc-auth-mtls-allowed-substrings` was matched against every certificate the client presented, not just the one verified against `--grpc-ca`. A client with any certificate from that CA could append a self-signed certificate with an allowed subject and be admitted ([GHSA-xhx6-rmm2-5h2p](https://github.com/vitessio/vitess/security/advisories/GHSA-xhx6-rmm2-5h2p)). The flag is now matched only against the subject of the verified leaf certificate. In mtls mode the flag can also no longer have an empty entry, which matched every subject: an unset or empty value (the default), or a leading, trailing or repeated colon, such as in `CN=vtctld:`. #### Impact - A process started with `--grpc-auth-mode=mtls` logs `Failed to load auth plugin` and exits with status 1 if `--grpc-auth-mtls-allowed-substrings` has an empty entry. - An entry that matches only a non-leaf certificate, such as an intermediate CA's subject, no longer admits the client. RPCs between components, such as VTGate, VTOrc or vtctld calling an upgraded VTTablet, can fail with `client certificate not authorized` (gRPC code `Unauthenticated`), which the server doesn't log. - Before upgrading, set the flag to non-empty entries, and check that each client certificate's subject, as Go formats it (`CN=vtctld,OU=Vitess,O=Example,C=US`), contains one of them. See [#22234](https://github.com/vitessio/vitess/pull/22234) for details. ### Table ACL: tables bound by MERGE `UNION`, `CREATE TABLE ... LIKE` and `EXCHANGE PARTITION` are checked Under strict table ACL (`--queryserver-config-strict-table-acl`), only the table a `CREATE TABLE` or `ALTER TABLE` names was checked. A MERGE table's `UNION=(...)` option, a `CREATE TABLE ... LIKE` of a MERGE table, and `ALTER TABLE ... EXCHANGE PARTITION` let a user with ADMIN on one table read and write tables the ACL denied them, and so could a FEDERATED table's `CONNECTION` string where that engine is enabled ([GHSA-q4ch-mhpm-9368](https://github.com/vitessio/vitess/security/advisories/GHSA-q4ch-mhpm-9368)). Now: - tables named by a table option, and the source of `CREATE TABLE ... LIKE`, require READER and WRITER; - both tables of `EXCHANGE PARTITION` require ADMIN, READER and WRITER; - a partially parsed `ALTER TABLE` or `CREATE INDEX`, and a `CREATE TABLE` or `ALTER TABLE` that sets `CONNECTION`, are denied with `command denied ... for a table set that cannot be determined`. The exceptions are the exempt ACL (`--queryserver-config-acl-exempt-acl`) and a caller with every role in a table group covering every table (`%`). #### Impact - Partition maintenance that the parser doesn't fully parse is denied for non-exempt callers, such as `ADD PARTITION` with more than one partition definition, or `ADD PARTITION PARTITIONS n`. Add one partition per statement, or run the job as the exempt user. A failing job may only show up later, as inserts that fail past a RANGE table's last bound. - On this release the parser also has no `SERIAL` column type, so an `ALTER TABLE` that defines a `SERIAL` column is denied as well. Spell the type out (`BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE`). - Upgrading doesn't undo bindings made before it. Find MERGE and FEDERATED tables on each shard's primary with `SELECT table_schema, table_name, engine FROM information_schema.tables WHERE engine IN ('MRG_MYISAM', 'FEDERATED')`, check each one's `UNION` list or `CONNECTION` string with `SHOW CREATE TABLE`, and drop any binding that isn't intended. A past `EXCHANGE PARTITION` leaves no such trace; only the binary log or an audit log shows it. See [#22237](https://github.com/vitessio/vitess/pull/22237) for details. ### Schema-derived text is no longer interpreted as a Go template or format string `CopySchemaShard`, which `Reshard` also runs for each new shard unless `--skip-schema-copy` is set, filled the `{{.DatabaseName}}` placeholder by executing each copied `SHOW CREATE` statement as a Go `text/template`. A user able to run DDL could put template actions in, for example, a table comment, and make Vitess run arbitrary SQL as the DBA user on the destination primaries ([GHSA-7g75-v57j-2ghw](https://github.com/vitessio/vitess/security/advisories/GHSA-7g75-v57j-2ghw)). The same pattern existed when a Reshard migrates the keyspace's other workflows (each stream's filter, which can contain table names, was executed as a template to fill in the key range) and in the legacy `vtctl` materializer (`MoveTables`, `Materialize`, `Migrate`, `CreateLookupVindex`). VDiff's `--debug-query` used the diffed query's `FROM` clause as a format string, so a `%` in a table name crashed vttablet. Placeholders are now substituted literally, and nothing else in the text is interpreted. #### Impact - `CopySchemaShard`, and so `Reshard`'s schema copy, refuses a copied definition that is more than one statement once the database name is filled in. - A Reshard's `SwitchTraffic` fails to switch writes if another workflow in the keyspace has a filter that contains `{{`, for example a moved table whose name contains it. Writes stay on the source shards; replica and rdonly reads that the same command switched stay switched, and `--dry-run` reports the error. - The legacy `vtctl` `Materialize` no longer substitutes a `{{.keyrange}}` or `{{.dbname}}` written in a source expression. This was never documented, and `vtctldclient Materialize` never supported it. See [#22240](https://github.com/vitessio/vitess/pull/22240) for details. ### Security fixes - Fixes [GHSA-mmjh-49cg-g5v2](https://github.com/vitessio/vitess/security/advisories/GHSA-mmjh-49cg-g5v2): SQL injection through table names in the `ANALYZE TABLE` that VDiff runs for `--update-table-stats`. See [#22243](https://github.com/vitessio/vitess/pull/22243). - Fixes [GHSA-g6c2-qp3p-x2w2](https://github.com/vitessio/vitess/security/advisories/GHSA-g6c2-qp3p-x2w2): the VTGate MySQL server kept reading a client's packet after returning its buffer to the shared buffer pool, where another connection could overwrite it. The auth switch response checked during login, the arguments of the replication commands, and the error replies to some malformed commands could use bytes from another connection's packet. See [#22247](https://github.com/vitessio/vitess/pull/22247). - Fixes [GHSA-hqg6-fhvc-3vmf](https://github.com/vitessio/vitess/security/advisories/GHSA-hqg6-fhvc-3vmf): SQL injection through a replication position from a source tablet in the `stop_pos` update that VDiff runs and in the update that `Reshard` runs when switching writes. See [#22250](https://github.com/vitessio/vitess/pull/22250). ------------ The entire changelog for this release can be found [here](https://github.com/vitessio/vitess/blob/main/changelog/24.0/24.0.6/changelog.md). The release includes 96 merged Pull Requests. Thanks to all our contributors: @app/vitess-bot, @arthurschreiber, @mattlord, @mhamza15