OpenFile drops footer KeyMetadata when resolving footer-key-encrypted columns

perfloop-oss/parquet-go · Uncatalogued correctness

https://perfloop.ai/t/oss/case_0zg4tzggpf

Verdict

VERIFIED · settled 2026-11-24 · merged as parquet-go/parquet-go#760

What happened: The check fails before this change and passes with it.

Hypothesis

Opening an encrypted Parquet file whose footer carries key metadata fails for any KMS-backed KeyRetriever that requires KeyMetadata to look up the footer key. Although OpenFile passes the stored key metadata when decrypting or verifying the footer itself, it discards both the key and metadata and later calls FooterKey(nil) for every column encrypted with the footer key.

In encrypt.go lines 112-115, KeyRetriever.FooterKey(keyMetadata []byte) documents that keyMetadata carries the bytes stored in FileCryptoMetaData.KeyMetadata (or FooterSigningKeyMetadata in plaintext-footer mode). OpenFile passes cryptoMeta.KeyMetadata at file.go:162 and f.metadata.FooterSigningKeyMetadata at file.go:206, but never stores the resolved key or metadata on File. Downstream, ReadPageIndex (file.go:461), decryptAllColumnMetadata (file.go:651), and FileRowGroup.init (file.go:803) each call FooterKey(nil) for every EncryptionWithFooterKey column chunk. Upstream open PRs on parquet-go/parquet-go were checked (no open PR addresses footer key metadata propagation).

Testing an encrypted-footer file with FileCryptoMetaData.KeyMetadata set to a non-empty key identifier failed in both SkipPageIndex=false (failing at ReadPageIndex line 461 with keyMetadata="") and SkipPageIndex=true (failing at FileRowGroup.init line 803 with keyMetadata=""). Running `go test . -run '^TestHuntOpenFileFooterKeyMetadataReplay$' -count=1` deterministically reproduces both failures.

The Case should verify that footer key metadata (or the already-resolved footer key) is preserved across encrypted-footer and signed plaintext-footer files for column metadata decryption, page index reading, and column chunk initialization without passing nil metadata to FooterKey. The submitted test file layout is provisional.

Change to test: Retain the footer key (or footer key metadata) resolved during OpenFile on File and reuse it for EncryptionWithFooterKey columns in decryptAllColumnMetadata, ReadPageIndex, and FileRowGroup.init instead of calling FooterKey(nil).

Where it lives

perfloop-oss/parquet-go

Evidence

The check fails before this change and passes with it: `For valid AES-GCM encrypted-footer and signed plaintext-footer files carrying footer key metadata, OpenFile preserves that metadata for footer-key column lookups so column metadata, page indexes, and rows can be read with a matching KeyRetriever, with or without eager page-index loading.`

Checks: 3 of 3 passed. Verification: no defect found.

Timeline