Repository navigation
Cherry pick #129605 to 26.9: Do not let filtered source grants be bypassed by INSERT INTO FUNCTION destinations or CREATE TABLE ... AS - #132308
Merged
robot-ch-test-poll merged 22 commits intoNov 20, 2026
Conversation
The SQL query `INSERT INTO FUNCTION ... PARTITION BY` checked the source grant once against
the URI with `{_partition_id}` placeholder still in it without any replacement. The partition
ids come from the inserted data, so a partition id like `../protected/foo` could write outside
the path that a filtered grant such as `WRITE ON URL('^http://host/allowed/.*$')` allows.
Now the table function passes a write access check to its storage, and each partitioned sink
runs it on the destination of every new partition before writing to it. For object storages,
the check uses the key that is actually written: the decoded key, so that a percent-encoded
`{_partition_id}` cannot hide it, and the key after a rename by `s3_create_new_file_on_insert`.
The key is checked before it is looked up, so that an existing object outside the grant is not
disclosed. `hdfs` grants filter only the authority, so its partitions are checked against the
authority, which a partition cannot change.
This covers `url`, `s3`, `azureBlobStorage`, `hdfs` and their `*Cluster` variants. Tables with
these engines are not affected, because creating one requires an unfiltered grant on the source.
The `file` function is not affected either, because its grant has no URI to filter.
…endent of where the sequence number goes Related: #129630
…se bucket switches only on S3
…re `ON CLUSTER` dispatch `ON CLUSTER` workers create the table with full access, so the grant is now in `getRequiredAccess`.
… copy AS src` or restored `ON CLUSTER`
…R` pre-check Resolving the function there fails when its named collection is restored from the same backup. Checking `RESTORE ON CLUSTER` without resolving live dependencies is out of scope; a local `RESTORE` is still checked after `setEngine`.
…e function Parsing a table function may change its arguments: `mysql` and `postgresql` take out their `SETTINGS`. The check parsed the definition itself, so structure inference no longer saw them.
…-filter Do not let filtered source grants be bypassed by `INSERT INTO FUNCTION` destinations or `CREATE TABLE ... AS`
Adapted to the release: `StorageTableFunctionProxy` has no `hasUnreplicatedTableDataOnDisk` argument, `StorageURL` names the method `http_method`, and `StorageObjectStorage::createSink` writes `paths.back()`, so that path is checked. `05565_azure_structure_inference_does_not_create_container` is not on the release, so it stays deleted. The new integration test imports `uuid`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Original pull-request #129605
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job