You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@polaris.apache.org by "hkwi (via GitHub)" <gi...@apache.org> on 2026/07/29 14:51:34 UTC

[PR] [2/2] Enforce encrypted Iceberg metadata integrity [polaris]

hkwi opened a new pull request, #5186:
URL: https://github.com/apache/polaris/pull/5186

   ## Summary
   
   - Store a versioned canonical SHA-256 digest for protected encrypted Iceberg metadata in trusted Polaris internal entity state.
   - Verify the key-ID pin and digest when metadata is loaded and before asynchronous cleanup traverses it.
   - Define register new and missing-table notification as authorized trust-on-first-use admissions.
   - Define register overwrite as `TABLE_FULL_METADATA`-authorized re-admission after key-ID validation.
   - Reject notification updates of existing protected encrypted tables until an authenticated expected digest can be bound to the request.
   - Map integrity failures to non-retryable HTTP 422 responses and stop asynchronous cleanup without deleting storage when verification fails.
   
   This implements the metadata-integrity alternative in Iceberg's [catalog security requirements](https://iceberg.apache.org/docs/nightly/encryption/#catalog-security-requirements) for deployments where plaintext `metadata.json` is held in storage that must not be treated as authoritative. The digest construction follows Iceberg HiveCatalog: canonical `TableMetadataParser` JSON, UTF-8 SHA-256, and Base64 storage outside the metadata file.
   
   ## Stack
   
   This is **2/2** of a stacked change and depends on the key-ID pinning PR: https://github.com/apache/polaris/pull/5185.
   
   Both PRs target `main` because their head branches are in an external fork. The branch for this PR contains the first PR's commit followed by one metadata-integrity commit. Until the first PR lands, the incremental second-layer diff is:
   
   https://github.com/hkwi/polaris/compare/upstream/enforce-immutable-encryption-key-id...upstream/enforce-encrypted-metadata-integrity
   
   After the first PR is merged, this head branch will need to be updated against the resulting `main` history so that this PR contains only the metadata-integrity layer. This follow-up Git operation is required because the fork-only parent branch cannot be selected as the base of a PR in `apache/polaris`.
   
   ## Guarantee and compatibility boundary
   
   - New protected encrypted tables atomically store the pin marker, exact key ID, metadata pointer, digest, and digest version.
   - Protected encrypted state with a missing or unsupported digest fails closed.
   - Existing unpinned tables retain legacy behavior without automatic digest backfill.
   - Direct object-storage rereads by clients that ignore inline REST metadata remain outside the guarantee.
   
   ## Verification
   
   - `./gradlew format compileAll`
   - Runtime-service checkstyle passed.
   - All 22,103 runtime-service unit tests passed (0 failures, 0 errors, 43 skipped).
   - Runtime-service integration tests fail before test execution in the common Quarkus `TestHTTPResourceManager` initialization path; all 28 suites report the same `ParameterResolutionException` caused by the NPE at `TestHTTPResourceManager.java:190`.
   
   ## Checklist
   
   - [x] 🛡️ Don't disclose security issues! (contact security@apache.org)
   - [x] 🔗 Clearly explained why the changes are needed, or linked related issues: related to #2829 and complementary to #5060
   - [x] 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
   - [x] 💡 Added comments for complex logic
   - [x] 🧾 Updated `CHANGELOG.md` (if needed)
   - [x] 📚 Updated documentation in `site/content/in-dev/unreleased` (if needed): not needed for internal catalog invariants
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [2/2] Enforce encrypted Iceberg metadata integrity [polaris]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #5186: [2/2] Enforce encrypted Iceberg metadata integrity
URL: https://github.com/apache/polaris/pull/5186


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [2/2] Enforce encrypted Iceberg metadata integrity [polaris]

Posted by "flyingImer (via GitHub)" <gi...@apache.org>.
flyingImer commented on code in PR #5186:
URL: https://github.com/apache/polaris/pull/5186#discussion_r3867069862


##########
runtime/service/src/main/java/org/apache/polaris/service/exception/IcebergExceptionMapper.java:
##########
@@ -175,6 +176,7 @@ static int mapExceptionToResponseCode(RuntimeException rex) {
       case FileIOUnknownHostException e -> Status.NOT_FOUND.getStatusCode();
       case AlreadyExistsException e -> Status.CONFLICT.getStatusCode();
       case CommitFailedException e -> Status.CONFLICT.getStatusCode();
+      case TableMetadataIntegrityException e -> 422;

Review Comment:
   This makes a Polaris implementation class part of the Iceberg wire contract. toResponse() emits runtimeException.getClass().getSimpleName(), so this path returns type=TableMetadataIntegrityException.
   
   Could we translate the internal integrity failure to an Iceberg-owned exception (for example UnprocessableEntityException) at the Iceberg boundary and keep the internal exception for cleanup only? Also, if 422 is intentionally reachable from load/refresh, the served OpenAPI should declare that response and the mapper test should pin the response type as well as the status.



##########
runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/LocalIcebergCatalog.java:
##########
@@ -3092,6 +3115,27 @@ private boolean sendNotificationForTableLike(
       // finally, validate that the metadata file is within the table directory
       validateMetadataFileInTableDir(tableIdentifier, tableMetadata);
 
+      if (existingLocation != null) {
+        TableMetadataTransitionValidator.validate(
+            entity.getInternalPropertiesAsMap(), tableMetadata);
+        if (entity
+            .getInternalPropertiesAsMap()
+            .containsKey(TableMetadataTransitionValidator.KEY_ID_PROPERTY)) {
+          throw new ValidationException(
+              "Cannot update a protected table by notification without an authenticated expected "
+                  + "metadata digest");
+        }

Review Comment:
   This makes UPDATE notifications unavailable for every existing protected encrypted table, regardless of whether the caller can provide trustworthy metadata for the new revision.
   
   Since notifications are the synchronization contract for external catalogs, I don't think we should make encrypted tables unable to advance through this API without defining the replacement admission mechanism. Could we support request-side binding of the expected metadata/content here (the notification payload already has an optional metadata field), or otherwise introduce an explicit expected digest?
   
   If that cannot be supported in this change, I think we should at least treat disabling encrypted-table UPDATE notifications as an explicit API compatibility decision rather than an implementation detail.



##########
runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/LocalIcebergCatalog.java:
##########
@@ -3092,6 +3115,27 @@ private boolean sendNotificationForTableLike(
       // finally, validate that the metadata file is within the table directory
       validateMetadataFileInTableDir(tableIdentifier, tableMetadata);
 
+      if (existingLocation != null) {
+        TableMetadataTransitionValidator.validate(
+            entity.getInternalPropertiesAsMap(), tableMetadata);
+        if (entity
+            .getInternalPropertiesAsMap()
+            .containsKey(TableMetadataTransitionValidator.KEY_ID_PROPERTY)) {
+          throw new ValidationException(
+              "Cannot update a protected table by notification without an authenticated expected "
+                  + "metadata digest");
+        }
+      }
+      Map<String, String> internalProperties = new HashMap<>(entity.getInternalPropertiesAsMap());
+      if (existingLocation == null) {
+        TableMetadataTransitionValidator.pin(internalProperties, tableMetadata);
+      }
+      TableMetadataIntegrity.pin(internalProperties, tableMetadata);

Review Comment:
   For a missing table, this establishes the trusted digest from the same object-store metadata being admitted. That gives us protection against tampering after admission, but not against the metadata having already been modified before the notification is processed.
   
   Is that intentionally the trust boundary for the “trust-on-first-use” admission described in the PR? If pre-admission storage tampering is also in scope, the authorized notification would need to bind the expected content/digest rather than pinning whatever bytes happen to be present at metadata-location.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [2/2] Enforce encrypted Iceberg metadata integrity [polaris]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #5186:
URL: https://github.com/apache/polaris/pull/5186#issuecomment-5842044442

   This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org