VYPR
Critical severity9.9NVD Advisory· Published May 4, 2026· Updated May 12, 2026

CVE-2026-42812

CVE-2026-42812

Description

In Apache Iceberg, the table's metadata files are control files: they tell readers which data files belong to the table and which table version to read.

write.metadata.path is an optional table property that tells Polaris where to write those metadata files. For a table already registered in a Polaris-managed catalog, changing only that property through an ALTER TABLE-style settings change (not a row-level INSERT, SELECT, UPDATE, or DELETE) bypasses the commit-time branch that is supposed to revalidate storage locations.

The full persisted / credential-vending variant requires the affected catalog to have polaris.config.allow.unstructured.table.location=true, with allowedLocations broad enough to include the attacker-chosen target.

allowedLocations is the admin-configured allowlist of storage paths that the catalog is allowed to use. Public project materials suggest that this flag is a real supported compatibility / layout mode, not just a contrived lab-only prerequisite.

In that configuration, a user who can change table settings can cause Apache Polaris itself to write new table metadata to an attacker-chosen reachable storage location before the intended location-validation branch runs.

If the later concrete-path validation also accepts that location, Polaris persists the resulting metadata path into stored table state. Later table-load and credential APIs can then return temporary cloud-storage credentials for the same location without revalidating it. In plain terms, Polaris can later hand out temporary storage access for the same attacker-chosen area.

That attacker-chosen area does not need to be limited to the poisoned table's own files. If it is a broader storage prefix, another table's prefix, or, depending on configuration or provider behavior, even a bucket/container root, the resulting disclosure or corruption scope can extend to any data and metadata Polaris can reach there.

The practical consequences are therefore similar to the staged-create credential-vending issue already discussed: data and metadata reachable in that storage scope can be exposed and, if write-capable credentials are later issued, modified, corrupted, or removed. Even before that later credential step, Polaris itself performs the metadata write to the unchecked location.

So the core issue is not only later credential vending.

The primary defect is that Polaris skips its intended location checks before performing a security- sensitive metadata write when only write.metadata.path changes.

When polaris.config.allow.unstructured.table.location=false, current code review suggests the later updateTableLike(...) validation usually rejects out-of-tree metadata locations before the unsafe path is persisted. That may reduce the persisted / credential-vending variant, but it does not prevent the underlying defect: Polaris still skips the intended pre-write location check when only write.metadata.path changes.

Affected products

1
  • cpe:2.3:a:apache:polaris:*:*:*:*:*:*:*:*
    Range: <1.4.1

Patches

1
d6bbcc386e61

Improve locations-handling (#4330)

https://github.com/apache/polarisRobert StuppMay 1, 2026via ghsa
2 files changed · +144 30
  • runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java+49 30 modified
    @@ -1530,17 +1530,7 @@ public void doCommit(TableMetadata base, TableMetadata metadata) {
                       ResolvedPathKey.ofNamespace(tableIdentifier.namespace()))
                   : resolvedTableEntities;
     
    -      // refresh credentials because we need to read the metadata file to validate its location
    -      tableFileIO =
    -          loadFileIOForTableLike(
    -              tableIdentifier,
    -              StorageUtil.getLocationsUsedByTable(metadata),
    -              resolvedStorageEntity,
    -              new HashMap<>(metadata.properties()),
    -              Set.of(
    -                  PolarisStorageActions.READ,
    -                  PolarisStorageActions.WRITE,
    -                  PolarisStorageActions.LIST));
    +      Set<String> requestedLocations = StorageUtil.getLocationsUsedByTable(metadata);
     
           List<PolarisEntity> resolvedNamespace =
               resolvedTableEntities == null
    @@ -1549,21 +1539,13 @@ public void doCommit(TableMetadata base, TableMetadata metadata) {
                       .getRawFullPath()
                   : resolvedTableEntities.getRawParentPath();
     
    -      if (base == null
    -          || !metadata.location().equals(base.location())
    -          || !Objects.equal(
    -              base.properties().get(IcebergTableLikeEntity.USER_SPECIFIED_WRITE_DATA_LOCATION_KEY),
    -              metadata
    -                  .properties()
    -                  .get(IcebergTableLikeEntity.USER_SPECIFIED_WRITE_DATA_LOCATION_KEY))) {
    +      if (base == null || requestedTableLocationsChanged(base, metadata)) {
             // If location is changing then we must validate that the requested location is valid
             // for the storage configuration inherited under this entity's path.
    -        Set<String> dataLocations =
    -            StorageUtil.getLocationsUsedByTable(metadata.location(), metadata.properties());
             CatalogUtils.validateLocationsForTableLike(
    -            realmConfig, tableIdentifier, dataLocations, resolvedStorageEntity);
    +            realmConfig, tableIdentifier, requestedLocations, resolvedStorageEntity);
             // also validate that the table location doesn't overlap an existing table
    -        dataLocations.forEach(
    +        requestedLocations.forEach(
                 location ->
                     validateNoLocationOverlap(
                         catalogEntity,
    @@ -1572,11 +1554,21 @@ public void doCommit(TableMetadata base, TableMetadata metadata) {
                         location,
                         resolvedStorageEntity.getRawLeafEntity()));
             // and that the metadata file points to a location within the table's directory structure
    -        if (metadata.metadataFileLocation() != null) {
    -          validateMetadataFileInTableDir(tableIdentifier, metadata);
    -        }
    +        validateMetadataFileInTableDir(
    +            tableIdentifier, metadata.location(), nextMetadataFileLocation(metadata));
           }
     
    +      tableFileIO =
    +          loadFileIOForTableLike(
    +              tableIdentifier,
    +              requestedLocations,
    +              resolvedStorageEntity,
    +              new HashMap<>(metadata.properties()),
    +              Set.of(
    +                  PolarisStorageActions.READ,
    +                  PolarisStorageActions.WRITE,
    +                  PolarisStorageActions.LIST));
    +
           String newLocation = writeNewMetadataIfRequired(base == null, metadata);
           String oldLocation = base == null ? null : base.metadataFileLocation();
     
    @@ -1656,6 +1648,27 @@ public void doCommit(TableMetadata base, TableMetadata metadata) {
           }
         }
     
    +    private boolean requestedTableLocationsChanged(TableMetadata base, TableMetadata metadata) {
    +      return !metadata.location().equals(base.location())
    +          || !Objects.equal(
    +              base.properties().get(IcebergTableLikeEntity.USER_SPECIFIED_WRITE_DATA_LOCATION_KEY),
    +              metadata
    +                  .properties()
    +                  .get(IcebergTableLikeEntity.USER_SPECIFIED_WRITE_DATA_LOCATION_KEY))
    +          || !Objects.equal(
    +              base.properties()
    +                  .get(IcebergTableLikeEntity.USER_SPECIFIED_WRITE_METADATA_LOCATION_KEY),
    +              metadata
    +                  .properties()
    +                  .get(IcebergTableLikeEntity.USER_SPECIFIED_WRITE_METADATA_LOCATION_KEY));
    +    }
    +
    +    private String nextMetadataFileLocation(TableMetadata metadata) {
    +      return metadata.metadataFileLocation() != null
    +          ? metadata.metadataFileLocation()
    +          : metadataFileLocation(metadata, "metadata.json");
    +    }
    +
         @Override
         public TableOperations temp(TableMetadata uncommittedMetadata) {
           return new TableOperations() {
    @@ -2171,20 +2184,26 @@ protected void refreshFromMetadataLocation(
       }
     
       private void validateMetadataFileInTableDir(TableIdentifier identifier, TableMetadata metadata) {
    +    validateMetadataFileInTableDir(
    +        identifier, metadata.location(), metadata.metadataFileLocation());
    +  }
    +
    +  private void validateMetadataFileInTableDir(
    +      TableIdentifier identifier, String tableLocation, String metadataLocation) {
         boolean allowEscape = realmConfig.getConfig(FeatureConfiguration.ALLOW_EXTERNAL_TABLE_LOCATION);
         if (!allowEscape
             && !realmConfig.getConfig(FeatureConfiguration.ALLOW_EXTERNAL_METADATA_FILE_LOCATION)) {
           LOGGER.debug(
               "Validating base location {} for table {} in metadata file {}",
    -          metadata.location(),
    +          tableLocation,
               identifier,
    -          metadata.metadataFileLocation());
    -      StorageLocation metadataFileLocation = StorageLocation.of(metadata.metadataFileLocation());
    -      StorageLocation baseLocation = StorageLocation.of(metadata.location());
    +          metadataLocation);
    +      StorageLocation metadataFileLocation = StorageLocation.of(metadataLocation);
    +      StorageLocation baseLocation = StorageLocation.of(tableLocation);
           if (!metadataFileLocation.isChildOf(baseLocation)) {
             throw new BadRequestException(
                 "Metadata location %s is not allowed outside of table location %s",
    -            metadata.metadataFileLocation(), metadata.location());
    +            metadataLocation, tableLocation);
           }
         }
       }
    
  • runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/AbstractIcebergCatalogTest.java+95 0 modified
    @@ -93,6 +93,7 @@
     import org.apache.iceberg.rest.requests.UpdateTableRequest;
     import org.apache.iceberg.types.Types;
     import org.apache.iceberg.util.CharSequenceSet;
    +import org.apache.iceberg.util.LocationUtil;
     import org.apache.polaris.core.PolarisCallContext;
     import org.apache.polaris.core.PolarisDiagnostics;
     import org.apache.polaris.core.admin.model.AwsStorageConfigInfo;
    @@ -2445,6 +2446,74 @@ public void testTableInternalPropertiesStoredOnCommit() {
             table -> String.valueOf(table.sortOrder().orderId()));
       }
     
    +  @Test
    +  public void testUpdatePropertiesRejectsOutOfTableWriteMetadataLocation() {
    +    Assumptions.assumeTrue(
    +        requiresNamespaceCreate(),
    +        "Only applicable if namespaces must be created before adding children");
    +
    +    updateCatalogProperties(
    +        Map.of(
    +            FeatureConfiguration.ALLOW_EXTERNAL_TABLE_LOCATION.catalogConfig(), "false",
    +            FeatureConfiguration.ALLOW_UNSTRUCTURED_TABLE_LOCATION.catalogConfig(), "true"));
    +
    +    catalog.createNamespace(NS);
    +    Table table = catalog.buildTable(TABLE, SCHEMA).create();
    +
    +    String storageLocation = "s3://my-bucket/path/to/data";
    +    String metadataDirectory =
    +        "%s/table-metadata/%s"
    +            .formatted(LocationUtil.stripTrailingSlash(storageLocation), UUID.randomUUID());
    +    String metadataPrefix = metadataDirectory + "/";
    +
    +    Assertions.assertThatThrownBy(
    +            () ->
    +                table
    +                    .updateProperties()
    +                    .set(TableProperties.WRITE_METADATA_LOCATION, metadataDirectory)
    +                    .commit())
    +        .isInstanceOf(BadRequestException.class)
    +        .hasMessageContaining("is not allowed outside of table location");
    +
    +    Assertions.assertThat(inMemoryFilesUnderPrefix(metadataPrefix)).isEmpty();
    +    Assertions.assertThat(catalog.loadTable(TABLE).properties())
    +        .doesNotContainKey(TableProperties.WRITE_METADATA_LOCATION);
    +  }
    +
    +  @Test
    +  public void testUpdatePropertiesAcceptsInTableWriteMetadataLocation() {
    +    Assumptions.assumeTrue(
    +        requiresNamespaceCreate(),
    +        "Only applicable if namespaces must be created before adding children");
    +
    +    updateCatalogProperties(
    +        Map.of(
    +            FeatureConfiguration.ALLOW_EXTERNAL_TABLE_LOCATION.catalogConfig(), "false",
    +            FeatureConfiguration.ALLOW_UNSTRUCTURED_TABLE_LOCATION.catalogConfig(), "true"));
    +
    +    catalog.createNamespace(NS);
    +    Table table = catalog.buildTable(TABLE, SCHEMA).create();
    +
    +    String metadataDirectory =
    +        "%s/custom-metadata/%s"
    +            .formatted(LocationUtil.stripTrailingSlash(table.location()), UUID.randomUUID());
    +    String metadataPrefix = metadataDirectory + "/";
    +    table
    +        .updateProperties()
    +        .set(TableProperties.WRITE_METADATA_LOCATION, metadataDirectory)
    +        .commit();
    +
    +    Table updatedTable = catalog.loadTable(TABLE);
    +    String metadataFileLocation =
    +        ((BaseTable) updatedTable).operations().current().metadataFileLocation();
    +
    +    Assertions.assertThat(metadataFileLocation).startsWith(metadataPrefix);
    +    Assertions.assertThat(fileIO.fileExists(metadataFileLocation)).isTrue();
    +    Assertions.assertThat(inMemoryFilesUnderPrefix(metadataPrefix)).contains(metadataFileLocation);
    +    Assertions.assertThat(updatedTable.properties())
    +        .containsEntry(TableProperties.WRITE_METADATA_LOCATION, metadataDirectory);
    +  }
    +
       private void validatePropertiesUpdated(
           EntityResult schemaResult, String key, Function<Table, String> expectedValue) {
         Table afterUpdate = catalog.loadTable(TABLE);
    @@ -2463,6 +2532,32 @@ private void validatePropertiesUpdated(
             .containsEntry(key, expectedValue.apply(afterUpdate));
       }
     
    +  private void updateCatalogProperties(Map<String, String> properties) {
    +    CatalogEntity.Builder builder = new CatalogEntity.Builder(CatalogEntity.of(catalogEntity));
    +    properties.forEach(builder::addProperty);
    +
    +    EntityResult result =
    +        metaStoreManager.updateEntityPropertiesIfNotChanged(
    +            polarisContext, List.of(PolarisEntity.toCore(catalogEntity)), builder.build());
    +
    +    Assertions.assertThat(result).returns(true, EntityResult::isSuccess);
    +    catalogEntity = PolarisEntity.of(result.getEntity());
    +  }
    +
    +  @SuppressWarnings("unchecked")
    +  private Set<String> inMemoryFilesUnderPrefix(String prefix) {
    +    try {
    +      var field = InMemoryFileIO.class.getDeclaredField("IN_MEMORY_FILES");
    +      field.setAccessible(true);
    +      Map<String, byte[]> files = (Map<String, byte[]>) field.get(null);
    +      return files.keySet().stream()
    +          .filter(location -> location.startsWith(prefix))
    +          .collect(Collectors.toSet());
    +    } catch (ReflectiveOperationException e) {
    +      throw new AssertionError("Unable to inspect in-memory file contents", e);
    +    }
    +  }
    +
       @Test
       public void testEventsAreEmitted() {
         IcebergCatalog catalog = catalog();
    

Vulnerability mechanics

AI mechanics synthesis has not run for this CVE yet.

References

5

News mentions

0

No linked articles in our index yet.