Skip to content

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 into
backport/26.9/129605from
cherrypick/26.9/129605
Nov 20, 2026
Merged

robot-ch-test-poll merged 22 commits into
backport/26.9/129605from
cherrypick/26.9/129605

Conversation

@robot-ch-test-poll

Copy link
Copy Markdown
Contributor

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-pick locally.
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:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

foadl added 21 commits November 5, 2026 19:49
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
…re `ON CLUSTER` dispatch

`ON CLUSTER` workers create the table with full access, so the grant is now in `getRequiredAccess`.
…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`
@robot-ch-test-poll robot-ch-test-poll added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-critical-bugfix labels Nov 17, 2026
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]>
@robot-ch-test-poll
robot-ch-test-poll merged commit 41ce58c into backport/26.9/129605 Nov 20, 2026
2 checks passed
@robot-ch-test-poll
robot-ch-test-poll deleted the cherrypick/26.9/129605 branch November 20, 2026 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! pr-critical-bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants