Skip to content

[java-storage] CRC32C validation is skipped on all normal HTTP downloads #14773

Open

Description

@diwu-sf

Issue Details

CRC32C validation is effectively disabled for ALL normal HTTP downloads through reader(), readAllBytes(), and downloadTo(). Damaged data can be returned without a checksum error.

GCS sends x-goog-stored-content-encoding and x-goog-stored-content-length to describe the stored file. The client treats either header as evidence that GCS changed the file before sending it, so it skips validation even when the bytes are unchanged.

Environment

  • OS: Ubuntu 24.04
  • Java: OpenJDK 21 (Ubuntu)
  • Service: Google Cloud Storage, HTTP transport

Dependencies

com.google.cloud:google-cloud-storage:2.75.0

Reproducer

Set a breakpoint in HttpStorageRpcHasherHelper.shouldValidate() and run this download of a public Landsat file. No credentials are needed.

import com.google.cloud.NoCredentials;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageOptions;

public class LandsatRepro {
  public static void main(String[] args) throws Exception {
    String scene = "LC08_L1GT_044034_20130330_20170310_01_T2";
    String object = "LC08/01/044/034/" + scene + "/" + scene + "_MTL.txt";

    try (Storage storage = StorageOptions.http()
        .setProjectId("landsat-crc32c-repro")
        .setCredentials(NoCredentials.getInstance())
        .build()
        .getService()) {
      byte[] data = storage.readAllBytes("gcp-public-data-landsat", object);
      System.out.println("Downloaded " + data.length + " bytes");
    }
  }
}
  • Expected: shouldValidate() returns true, and the client checks the downloaded bytes against GCS's checksum.
  • Actual: It returns false, and the download completes without checking the checksum.

Logs and Stack Trace

GCS returns HTTP 200 with:

Content-Length: 8454
x-goog-stored-content-length: 8454
x-goog-stored-content-encoding: identity
x-goog-hash: crc32c=TeBDMA==,md5=ziZNd8uikTtDCkBTgS5Riw==

There is no Content-Encoding header. The program prints Downloaded 8454 bytes. No exception is thrown.

The public file is intact; this example shows the skipped check. In separate tests that changed one downloaded byte, the client accepted the damaged data without an error.

Proposed fix: #14768

Activity

  1. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions