Skip to content

[Server] Require schema creation permission for volume rename - #2017

Merged
yili-db merged 3 commits into
unitycatalog:mainfrom
timothyw553:fix/volume-rename-permissions
Oct 28, 2026
Merged

yili-db merged 3 commits into
unitycatalog:mainfrom
timothyw553:fix/volume-rename-permissions

Conversation

@timothyw553

@timothyw553 timothyw553 commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

Require permission to create volumes in the containing schema before renaming a volume. Check any request with new_name, including the current name. Comment-only updates keep the existing checks.

This is the default, so a rename that works today returns 403 unless the caller also owns the schema or has USE SCHEMA and CREATE VOLUME on it. This includes requests whose new_name is the current name. Set server.authorization.strict-privilege-checks=false to keep the old behavior.

Tests: SdkVolumeAccessControlCRUDTest (strict mode, all owner and grant combinations), SdkVolumeRenameLegacyAccessControlTest (flag off), and SdkVolumeCRUDTest pass; formatting passed.

@timothyw553
timothyw553 force-pushed the fix/volume-rename-permissions branch from 0323d50 to 5b216da Compare October 19, 2026 18:57
@timothyw553
timothyw553 force-pushed the fix/volume-rename-permissions branch 7 times, most recently from a4fa506 to 0ad5aee Compare October 21, 2026 19:33
yili-db pushed a commit that referenced this pull request Oct 22, 2026
## 🥞 Stacked PR
Use this
[link](https://github.com/unitycatalog/unitycatalog/pull/2023/files) to
review incremental changes.
-
[**feat/strict-privilege-checks**](#2023)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2023/files)]
← _this PR_
-
[fix/iceberg-credential-authorization](#2015)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2015/files/d63e70154a6f21c4d23d596491c779b66a250367..1e627b250bb34d8df390f050d8307fd5442dddc6)]
-
[fix/model-rename-permissions](#2018)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2018/files/d63e70154a6f21c4d23d596491c779b66a250367..49d68ec662b2f29c588c8f5d67ec74cfc3fe017f)]
-
[fix/permission-grant-validation](#2014)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2014/files/d63e70154a6f21c4d23d596491c779b66a250367..c6a5d3bf21127e62fc81b2b291ea54bb56463b55)]
-
[fix/table-details-permissions](#2016)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2016/files/d63e70154a6f21c4d23d596491c779b66a250367..6c897e034918a99ea3a2c4bdbeac64905c8f9d93)]
-
[fix/volume-rename-permissions](#2017)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2017/files/d63e70154a6f21c4d23d596491c779b66a250367..0ad5aee5216d2ed8085e969c287cc7dee7cdfa98)]

---------
**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [x] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [x] If you've added or modified a feature, documentation in `docs` is
updated

**Description of changes**

Add `server.authorization.strict-privilege-checks`, which defaults to
`true`.
The following permission fixes use this setting so deployments can keep
the previous rules
temporarily while updating their applications and grants. Setting it to
`false` retains the
previous behavior, including access that the corrected checks would
deny.

This PR adds the validated setting and passes it to authorization
expressions as the trusted
`#strict_privilege_checks` variable. Request values cannot change it.
The setting also reaches
response filtering through the shared evaluator. This base PR does not
change permission decisions.

Use the same value on every server instance and restart each instance
after changing it.
The fallback conditions and the setting can be deleted after the
migration.

Tests passed with JDK 17:

```sh
build/sbt javafmtAll "server/testOnly io.unitycatalog.server.utils.ServerPropertiesTest io.unitycatalog.server.UnityCatalogServerTest"
build/sbt "server/testOnly io.unitycatalog.server.auth.decorator.UnityAccessEvaluatorTest"
```

33 tests passed.

Combined validation with all five dependent fixes:
`build/sbt -J-Xmx2G javafmtAll "server/test"`: 923 tests passed.

Signed-off-by: Timothy Wang <[email protected]>
@timothyw553
timothyw553 force-pushed the fix/volume-rename-permissions branch 3 times, most recently from 4b7af66 to 822cc4e Compare October 22, 2026 18:26
@yili-db

yili-db commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

/review

@AuthorizeExpression(
"""
#authorize(#principal, #catalog, OWNER) ||
(#authorize(#principal, #catalog, OWNER) ||

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please indent after the new (

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, fixed the indentation.

#authorize(#principal, #volume, OWNER))
#authorize(#principal, #volume, OWNER))) &&
(!#strict_privilege_checks || #new_name == null ||
#new_name == #full_name.substring(#full_name.lastIndexOf('.') + 1) ||

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove the same-name check. It only changes the error for a request that does nothing anyway, so there's no need to handle it in the authorization rule. A rename to the current name now goes through the same checks as any other rename. The canComment branch in testVolumeRenamePermissions that expects RESOURCE_ALREADY_EXISTS, and the "requests with the current name" sentence in auth.md, need to change with it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. same-name requests use the rename checks now. updated the tests and removed the old docs wording.

(!#strict_privilege_checks || #new_name == null ||
#new_name == #full_name.substring(#full_name.lastIndexOf('.') + 1) ||
#authorize(#principal, #schema, OWNER) ||
#authorizeAll(#principal, #schema, USE_SCHEMA, CREATE_VOLUME))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AI Assisted] This copies the schema part of createVolume's rule (#authorize(#principal, #schema, OWNER) || #authorizeAll(#principal, #schema, USE_SCHEMA, CREATE_VOLUME)). If the create rule changes later, rename will quietly drift from it. Could it be a shared fragment in AuthorizeExpressions, next to UPDATE_SCHEMA?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AI Assisted] Ping on this. There is a precedent: AuthorizeExpressions.RENAME_TABLE composes DELETE_TABLE with a create-in-schema check. Volume rename could follow the same shape (an UPDATE_VOLUME constant plus the create-in-schema part), which also keeps the #strict_privilege_checks term as one piece that is easy to drop when the flag is removed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd prefer to keep this inline. the shared check is two lines in the same class, and i find both annotations easier to follow this way.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yili-db up to you if you'd prefer we have it extracted. this is your proposal:

--- a/server/src/main/java/io/unitycatalog/server/auth/AuthorizeExpressions.java
+++ b/server/src/main/java/io/unitycatalog/server/auth/AuthorizeExpressions.java
@@
   public static final String DELETE_SCHEMA = UPDATE_SCHEMA;

+  /** Schema permissions shared by volume creation and rename. */
+  public static final String CREATE_VOLUME_IN_SCHEMA =
+      """
+      (#authorize(#principal, #schema, OWNER) ||
+          #authorizeAll(#principal, #schema, USE_SCHEMA, CREATE_VOLUME))
+      """;
+

--- a/server/src/main/java/io/unitycatalog/server/service/VolumeService.java
+++ b/server/src/main/java/io/unitycatalog/server/service/VolumeService.java
@@
 import com.linecorp.armeria.server.annotation.Post;
+import io.unitycatalog.server.auth.AuthorizeExpressions;
 import io.unitycatalog.server.auth.UnityCatalogAuthorizer;
@@
   @Post("")
   @AuthorizeExpression(
-      """
-      #authorizeAny(#principal, #catalog, OWNER, USE_CATALOG) &&
-      (#authorize(#principal, #schema, OWNER) ||
-        #authorizeAll(#principal, #schema, USE_SCHEMA, CREATE_VOLUME)) &&
-      (#volume_type != 'EXTERNAL' ||
-        (#no_overlap_with_data_securable &&
-          (#external_location == null ||
-           #authorizeAny(#principal, #external_location, OWNER, CREATE_EXTERNAL_VOLUME))))
-      """)
+      "#authorizeAny(#principal, #catalog, OWNER, USE_CATALOG) && "
+          + AuthorizeExpressions.CREATE_VOLUME_IN_SCHEMA
+          + """
+          && (#volume_type != 'EXTERNAL' ||
+            (#no_overlap_with_data_securable &&
+              (#external_location == null ||
+               #authorizeAny(#principal, #external_location, OWNER, CREATE_EXTERNAL_VOLUME))))
+          """)
@@
               #authorize(#principal, #schema, USE_SCHEMA) &&
               #authorize(#principal, #volume, OWNER))) &&
       (!#strict_privilege_checks || #new_name == null ||
-          #authorize(#principal, #schema, OWNER) ||
-          #authorizeAll(#principal, #schema, USE_SCHEMA, CREATE_VOLUME))
-      """)
+      """
+          + AuthorizeExpressions.CREATE_VOLUME_IN_SCHEMA
+          + ")")

"VOLUME, true, false, SCHEMA, false, false",
"SCHEMA, true, false, , true, true",
"SCHEMA, false, false, , false, false",
"CATALOG, false, false, , true, false",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AI Assisted] These CATALOG, false, ... rows don't test what they say. setupCommonCatalogAndSchema() grants PRINCIPAL_1 USE_CATALOG on cat_pr1, and the revoke block below only removes grants from PRINCIPAL_2 and REGULAR_1. So useCatalog=false is never actually true for the catalog owner. Can you also revoke USE_CATALOG from PRINCIPAL_1 there?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. the setup now revokes USE_CATALOG from PRINCIPAL_1 too.

TestUtils.SCHEMA_FULL_NAME,
Privileges.USE_SCHEMA,
Privileges.CREATE_VOLUME);
VolumeInfo original =

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AI Assisted] nit: this "create the volume as REGULAR_1, then revoke its catalog and schema grants" setup is almost the same as the one in SdkVolumeAccessControlCRUDTest.testVolumeRenamePermissions. Can we move it into a helper in SdkAccessControlBaseCRUDTest and call it from both?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AI Assisted] Ping on this one too.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd keep this setup in the two test classes. the legacy test will go away with the flag, so i don't think we need to move it into the common base.

@timothyw553
timothyw553 force-pushed the fix/volume-rename-permissions branch from 822cc4e to 78064bb Compare October 23, 2026 18:46
@yili-db

yili-db commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

/review

", true, true, SCHEMA, false, false"
})
@SneakyThrows
public void testVolumeRenamePermissions(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change this to a plain @Test, like NormalizedURLTest.testToStandardizedURIString? A small helper plus one call per case reads much better than positional CSV rows, where it's hard to tell which column means what.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. switched to a plain @Test with a helper. the loops cover all 60 combinations, with a separate catalog for each case.

@timothyw553
timothyw553 force-pushed the fix/volume-rename-permissions branch from 58551a8 to 90bdb7e Compare October 27, 2026 21:59
@timothyw553
timothyw553 force-pushed the fix/volume-rename-permissions branch from 90bdb7e to 750e926 Compare October 28, 2026 18:48
@yili-db

yili-db commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

/review

@timothyw553

Copy link
Copy Markdown
Collaborator Author

@yili-db
yili-db merged commit 35df64c into unitycatalog:main Oct 28, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants