ggershinsky commented on code in PR #9752: URL: https://github.com/apache/iceberg/pull/9752#discussion_r1502705557
########## core/src/main/java/org/apache/iceberg/encryption/AesGcmInputFile.java: ########## @@ -20,39 +20,33 @@ import org.apache.iceberg.io.InputFile; import org.apache.iceberg.io.SeekableInputStream; -import org.apache.iceberg.relocated.com.google.common.base.Preconditions; public class AesGcmInputFile implements InputFile { private final InputFile sourceFile; private final byte[] dataKey; private final byte[] fileAADPrefix; private long plaintextLength; + /** + * Important: sourceFile.getLength() must return the verified plaintext content length, not the + * physical file size after encryption. This protects against tampering with the file size in + * untrusted storage systems. + */ public AesGcmInputFile(InputFile sourceFile, byte[] dataKey, byte[] fileAADPrefix) { this.sourceFile = sourceFile; this.dataKey = dataKey; this.fileAADPrefix = fileAADPrefix; - this.plaintextLength = -1; + this.plaintextLength = sourceFile.getLength(); Review Comment: Ok. Should we add a method to the`org.apache.iceberg.io.PositionOutputStream` interface? Or maybe to the `org.apache.iceberg.io.OutputFile`? (the latter is passed to the `AvroFileAppender` constructor) -- 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-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org