Repository navigation
[Server] Remove MODIFY from table metadata checks - #2016
Conversation
31176eb to
00b06ec
Compare
fc61c32 to
6c897e0
Compare
## 🥞 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]>
1b1d3bd to
2592c25
Compare
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
[AI Assisted] The direction looks right: GET_TABLE was the only table read rule that accepted MODIFY without SELECT, and pointing listTables at the shared constant removes a copy that could drift. A few comments inline.
Two smaller things, not blocking:
- No test checks that a
MODIFY-only user is denied on DeltaloadTableandtableExistsin strict mode.SdkTableAccessControlCRUDTestalready grantsREGULAR_1MODIFYnext to its Delta section, so it would be one line there. - Can the description say why this breaks no one? Writes already need
SELECT+MODIFY, so aMODIFY-only grant had no write use.
|
|
||
| Set `server.authorization.strict-privilege-checks=false` to restore the previous metadata rules. | ||
| With both usage permissions, `MODIFY` without `SELECT` again permits table details and listings. | ||
| This also restores its previous access to Iceberg `loadTable`, `tableExists`, and `loadCredentials`. |
There was a problem hiding this comment.
[AI Assisted] This overlaps with #2015, which moves Iceberg loadTable and loadCredentials off GET_TABLE onto their own rule. Both PRs also edit the GET_TABLE Javadoc, UnityAccessEvaluatorTest, and the Iceberg section of SdkIcebergRestCatalogAccessControlTest. If #2015 lands first, this sentence, the loadCredentials denial on tbl_mod, and the Iceberg assertions in SdkTableMetadataMigrationTest need rebasing onto the new rule. Can you note the overlap in the description so whoever rebases knows what to fix?
There was a problem hiding this comment.
yes, rebased it.
| @@ -24,8 +24,8 @@ private AuthorizeExpressions() {} | |||
| * Authorization policy for reading table metadata (UC REST {@code GET /tables/{name}}, UC Delta | |||
There was a problem hiding this comment.
[AI Assisted] This list is partial: GET_TABLE now also gates UC listTables and Iceberg tableExists, loadCredentials, loadView, reportMetrics and listTables, plus the per-table listing filters. Someone changing the expression later wouldn't know it changes what listings show. Can we say "every table read endpoint and the per-table listing filter" instead of naming endpoints? Same for the endpoint list in the auth.md section.
There was a problem hiding this comment.
done. changed to talk about metadata reads and listing too -- also made it shorter :-)
| #authorize(#principal, #schema, USE_SCHEMA) && | ||
| #authorizeAny(#principal, #table, OWNER, SELECT, MODIFY)) | ||
| (#authorizeAny(#principal, #table, OWNER, SELECT) || | ||
| (!#strict_privilege_checks && #authorize(#principal, #table, MODIFY)))) |
There was a problem hiding this comment.
[AI Assisted] The description says this clause and the fallback-mode test go away after migration. Can we have a tracking issue and a TODO(#issue) here and on SdkTableMetadataMigrationTest? #2014, #2015, #2017 and #2018 each add a similar temporary test class, so listing them all in that issue, or using one naming scheme ("Migration" or "Legacy"), would make the cleanup one pass.
There was a problem hiding this comment.
added TODO(#2024) here and on SdkTableMetadataMigrationTest
| assertThat( | ||
| new UnityAccessEvaluator(authorizer, strictPrivilegeChecks) | ||
| .evaluate(principal, AuthorizeExpressions.GET_TABLE, resources, Map.of())) | ||
| .isEqualTo(expected || (!strictPrivilegeChecks && useCatalog && useSchema && modify)); |
There was a problem hiding this comment.
[AI Assisted] For strict=false this expected value is the production clause rewritten, so a bug in the clause would be mirrored here. Can we add an explicit expectedWhenNotStrict column? Adding .as("strict=%s", strictPrivilegeChecks) would also make a failure say which mode broke.
There was a problem hiding this comment.
done. now cases gives the expected result for both modes. failures show the mode, owner and grants.
2592c25 to
db7fc52
Compare
|
/review |
|
|
||
| class UnityAccessEvaluatorTest { | ||
|
|
||
| @ParameterizedTest |
There was a problem hiding this comment.
[AI Assisted] Can we make this a plain @Test that calls a helper, like NormalizedURLTest does? Passing the grants as a set reads better than six positional CSV columns, and spelling out the result for each mode removes the expected || (!strict && ...) formula, which copies the production rule. For example:
@Test
void getTableRequiresSelectOrAnOwnerRule() throws Exception {
assertGetTable(/* owned= */ null, Set.of(), /* strict= */ false, /* legacy= */ false);
assertGetTable(null, Set.of(USE_CATALOG, USE_SCHEMA, SELECT), true, true);
// MODIFY without SELECT passes only with strict checks off.
assertGetTable(null, Set.of(USE_CATALOG, USE_SCHEMA, MODIFY), false, true);
assertGetTable(null, Set.of(USE_SCHEMA, SELECT, MODIFY), false, false);
assertGetTable(METASTORE, Set.of(), true, true);
assertGetTable(CATALOG, Set.of(), true, true);
assertGetTable(SCHEMA, Set.of(USE_CATALOG), true, true);
assertGetTable(SCHEMA, Set.of(USE_SCHEMA, SELECT, MODIFY), false, false);
assertGetTable(TABLE, Set.of(USE_CATALOG, USE_SCHEMA), true, true);
assertGetTable(TABLE, Set.of(USE_SCHEMA), false, false);
...
}assertGetTable(owned, grants, expectedStrict, expectedLegacy) would hold the mock setup and evaluate GET_TABLE once per mode.
There was a problem hiding this comment.
yeah, switched to a plain @test with the helper and named grants
|
Please rebase |
Signed-off-by: Timothy Wang <[email protected]>
Signed-off-by: Timothy Wang <[email protected]>
ccddd3f to
f38bbf5
Compare
Signed-off-by: Timothy Wang <[email protected]>
Signed-off-by: Timothy Wang <[email protected]>
|
/review |
Signed-off-by: Timothy Wang <[email protected]>
Signed-off-by: Timothy Wang <[email protected]>
|
/review |
|
i didn't find the nits in the ai review pressing. |
| Existing invalid grants can still be removed. | ||
| - [Iceberg credentials](#table-credential-permissions): returning credentials from `loadTable` | ||
| or `loadCredentials` requires `USE CATALOG`, `USE SCHEMA`, and `SELECT`, or ownership at each level. | ||
| - Table metadata: `MODIFY` no longer substitutes for `SELECT` for table details, listings, |
There was a problem hiding this comment.
[AI Assisted] This now conflicts with the end of the "Table credential permissions" section (line 445): "Table listings and tableExists keep their existing permission checks." That sentence came from #2015, and this PR changes both. Can we update it, e.g. "Table listings and tableExists use the table metadata rule, so MODIFY alone does not qualify."?
There was a problem hiding this comment.
updated it -- removed below
Signed-off-by: Timothy Wang <[email protected]>
PR Checklist
docsis updatedDescription of changes
MODIFYcurrently allows table details and listings withoutSELECT. Stop accepting it as a substitute forSELECTinGET_TABLE. Use the same rule for UC table listings.server.authorization.strict-privilege-checks=falsekeeps the old behavior.Tests: 24 focused tests and formatting passed.