Skip to content

chore(deps): update flate2 to 1.1.11, which decompresses with miniz_oxide 0.9.1 - #12191

Merged
basvandijk merged 2 commits into
masterfrom
bas/bump-flate2-1.1.11
Nov 19, 2026
Merged

basvandijk merged 2 commits into
masterfrom
bas/bump-flate2-1.1.11

Conversation

@basvandijk

@basvandijk basvandijk commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Updates flate2 from 1.1.9 (Cargo) and 1.1.5 (Bazel) to 1.1.11 in both builds. Since 1.1.10, flate2's default backend is miniz_oxide 0.9 instead of 0.8, and the locks resolve it to miniz_oxide 0.9.1.

#12180 held flate2 back for this reason:

  • miniz_oxide 0.9.1 rejects some deflate streams that 0.8.9 accepted.
  • The replica decodes a canister's stored gzipped Wasm module again whenever it compiles it, so an installed module could stop loading after a replica upgrade.

This description sets out how far that risk goes. Whether to take it is for the Execution team to decide (@dfinity/core-protocol, which owns rs/embedders).

Recommendation: take it. A hit is very unlikely (see below). If one happens, it is limited to that canister, it shows in the replica's metrics, and a replica release that restores the old rule undoes it.

What changes for gzipped canister modules

One stream shape is newly rejected.

  • The shape: a dynamic Huffman block whose literal/length or distance code gives a code to exactly one symbol, with a code length of 2 to 15.
  • zlib already rejects it, and so do GNU gzip and pigz. 0.9.1's table checks follow zlib's inflate_table rule for rule.
  • No other acceptance change: the 0.8.9 → 0.9.1 inflate diff changes only this table check.
    • In 11 million differential cases, every stream that 0.8.9 accepted and 0.9.1 rejected had this shape. 0.9.1 accepted nothing that 0.8.9 rejected, and streams both accepted decoded to the same bytes.
    • Nothing else on the decode_wasm path changes which modules are accepted.

No common compressor produces that shape:

  • At least two codes:

    • zlib and its derivatives (zlib-ng, zlib-rs, pako, Node), GNU gzip, pigz, 7-Zip and ISA-L always emit at least two codes.
    • So does libdeflate from 1.19. Earlier versions emit an empty code or two 1-bit codes, which both versions accept.
  • A 1-bit code: miniz, miniz_oxide, zopfli, libflate and Go's compress/flate give a lone symbol a 1-bit code, which both versions accept.

  • dfx compresses with flate2 when "gzip": true is set and whenever it rewrites a gzipped module. It has used miniz_oxide since 0.24.2 (fix(sdk): Asset evidence computation reproducibility fix sdk#3958), and zlib-ng before that.

  • IC tooling:

    • Our canisters are gzipped with pigz. The bundled ic-btc-canister release uses GNU gzip.
    • The asset canister and Internet Identity use gzip --best --no-name.
    • icp-cli's recipes use gzip --no-name.
  • Experiments: none of the encoders that could be run here produced such a table. They were GNU gzip, pigz, busybox, 7-Zip, zlib via Python, Node and Java, zlib-rs, libdeflate, zopfli, libflate, the deflate crate, and miniz_oxide 0.8.9 and 0.9.1, directly and through flate2. The runs covered:

    • 35,522 gzip streams from 57 edge-case and real inputs;
    • 948,000 raw streams from 6,000 random inputs, using the Rust encoders.

    Go, ISA-L, pako and zlib-ng were checked in source only.

None of the real modules we could obtain has it. All 2,290 distinct canister modules we found decode to identical bytes with flate2 1.1.5, 1.1.9 and 1.1.11. None of their 79,097 dynamic blocks has an incomplete or single-symbol table. The modules came from:

  • the history of mainnet-canister-revisions.json since 2024-10 (581 module hashes);
  • DFINITY's CDN for 23 IC versions since 2023-01 (1,043 release canisters);
  • the asset canister and wallet bundled with dfx since 2022-08;
  • 22 public IC projects' GitHub releases (529 assets);
  • our current canisters, and the modules our Bazel build downloads as test data.

Most installed modules are not among them. A sample of 3,000 mainnet canisters from the public dashboard API had 843 with a module. Only 252 of those run one of the modules above, and 241 of the 252 are asset canisters. Checking the rest needs the installed modules themselves. Someone with access to a recent checkpoint could scan the canisters' and snapshots' software.wasm files for the shape; this is the check #12180 asked for.

If an installed module has the shape, for example because it was hand-crafted or fuzzed:

  • Its developer would not have noticed. Today's decoder, miniz_oxide 0.8.9 (on mainnet since chore: simplify dependency graph #11669 in October 2026), accepts it. So did libflate, which the replica used before, and so do dfx, ic-wasm and 7-Zip.
  • After the replica upgrade:
    • Every message to the canister fails with IC0505 (CanisterInvalidWasm) on every node, and so do heartbeats and timers.
    • The failure is deterministic, so there's no divergence between nodes and no effect on the rest of the subnet.
    • The canister still pays the fixed execution fee for each failed call, callback and heartbeat. A canister that exports canister_heartbeat pays it every round until it freezes, and a global timer that fires is used up.
  • A normal upgrade fails too if the module exports canister_pre_upgrade, because the upgrade runs that hook from the old module. The options:
    • Upgrade with skip_pre_upgrade: this works and keeps stable memory. It loses whatever canister_pre_upgrade would have saved, which for canisters that serialize their heap in that hook is all heap state. With enhanced orthogonal persistence, adding wasm_memory_persistence = keep loses nothing.
    • Reinstall: this also works, but wipes all state, stable memory included.
    • Load a snapshot: this should work without losing state, but is untested. Take a snapshot, which doesn't decode the module. Download it, replace its module with the same Wasm gzipped by a standard tool, upload that as a new snapshot and load it.
    • No controller: a canister without one can only be fixed by a replica change.
  • Detection: the replica counter sandboxed_execution_replica_cache_lookups with lookup_result embedder_cache_hit_compilation_error or compilation_cache_hit_compilation_error counts executions that hit a cached compilation error. A broken canister would make it rise after the rollout.
  • Reversal: nothing derived from the failed decode is persisted. The module and the canister's memory stay as they are, and compilation results, errors included, are only cached in memory and in a temporary directory that is wiped when the replica starts. So a replica release that restores the old rule makes the canister work again. Only the effects of the failed messages remain: rejects, fees and used-up timers.

Alternatives, if execution wants no change in what is accepted:

  • Stay on flate2 1.1.9 / 1.1.5 (miniz_oxide 0.8.9).
  • Hold miniz_oxide at =0.9.0. flate2 1.1.11 accepts it, and it still has 0.8.9's rule; 0.9.1's only other changes affect wasm32. The costs:
    • No crate of ours depends on miniz_oxide directly, so this needs a pinned direct dependency in Cargo.toml and a crate.spec in bazel/rust.MODULE.bazel.
    • It moves backtrace's copy back from 0.9.1.
    • It only defers the decision.
  • Measure first. Keep the old rule, ship a check in decode_wasm that counts decoded modules with the rejected shape in a metric, and switch once mainnet reports none for a release. The costs:
    • decode_wasm runs in the compiler sandbox, so the count has to come back with the compilation result.
    • Modules are only decoded when a canister is installed or executes, so idle canisters and stored snapshots stay unchecked.

Other changes

  • Error text: a gzip module whose deflate data is truncated, but whose size trailer looks plausible, now fails with "failed to decode compressed Wasm module: incomplete deflate stream". Before, it was "...: unexpected end of file". The text appears in reject messages, and no test asserts it. Most truncated uploads fail the module size check before reaching flate2.
  • Raw-deflate and zlib decoders now report truncated input as an error instead of returning partial output, and zlib streams missing their Adler-32 trailer now fail. Where this applies, all off-chain:
    • ICP Rosetta (@dfinity/defi): request bodies with Content-Encoding: deflate that are truncated or lack the trailer are now rejected instead of parsed. Truncated gzip bodies only get a different error. Bodies with the newly rejected table shape are rejected too. ICRC Rosetta doesn't decompress requests.
    • ic-response-verification's raw DeflateDecoder, for v1-certified deflate responses. It runs in PocketIC's HTTP gateway and in the ic-gateway binary that GuestOS ships for cloud engine nodes.
  • Other gzip decoders: two places use the same gzip decoder on inputs from standard compressors:
    • the .tar.gz branch of ic-http-utils' archive extraction, which only the orchestrator calls, to fetch the registry store during subnet recovery;
    • PocketIC.
  • Compression:
    • Unchanged: one-shot gzip and raw-deflate output is byte-identical at every level.
    • Changed:
      • zlib-wrapped output at level 0 changes only its 2-byte header (08 1D → 78 01);
      • output in flush edge cases;
      • output of read::GzEncoder and bufread::GzEncoder at level 1.
    • Production use: production code compresses with flate2 only for ic-boundary's and ic-gateway's /metrics responses, through tower-http at the default level. Nothing stores, hashes or certifies those bytes. No production canister links flate2, so all 44 canisters in //publish/canisters are byte-identical with and without this change (PR base 4b4fc5d).
  • Requirements and locks:
    • flate2's requirement goes from 1.0.31 to 1.1.11 in Cargo.toml and bazel/rust.MODULE.bazel.
    • miniz_oxide 0.8.9 drops out of both locks.
    • zlib-rs 0.6.8, an optional flate2 backend, appears in them but isn't built.
    • miniz_oxide 0.9.1 gains its default, simd and with-alloc features, which backtrace's copy now also gets.
    • flate2's new default feature runtime_detection only enables crc32fast's std feature, which was already on.
    • No other package changes version.

Verification

  • Locks: in the dev container, cargo update --workspace reports "Locking 0 packages". ./bin/bazel-pin.sh reports "Nothing to repin.", and MODULE.bazel.lock doesn't change.

  • Lint: ./ci/scripts/rust-lint.sh passes.

  • Tests: these pass on the rebased head:

    • //rs/embedders:embedders_test;
    • //rs/embedders:embedders_integration_tests/misc_tests;
    • //rs/execution_environment:execution_environment_misc_integration_tests/execution_test_test, which installs gzipped modules;
    • the //rs/http_utils tests.
  • Evidence: the figures above come from:

    • differential tests of miniz_oxide 0.8.9 and 0.9.1 and of flate2 1.1.5, 1.1.9 and 1.1.11 against zlib;
    • encoder experiments;
    • decoding the module corpus;
    • the dashboard sample;
    • local builds of //publish/canisters with and without this change.

    For each part except the dashboard sample, a second AI agent re-checked the first one's findings with its own code and runs. The figures above include its corrections. The scripts and raw results are not in the repo.

This PR carries the CI_ALL_BAZEL_TARGETS label.

🤖 Generated with Claude Code

…xide 0.9

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@basvandijk basvandijk added the CI_ALL_BAZEL_TARGETS Runs all bazel targets label Nov 19, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Execution-owner sign-off is needed because miniz_oxide 0.9.1 can reject previously installed Wasm during recompilation, while mainnet coverage is incomplete and the proposed lossless recovery path is untested.

No open issues 🎉

What changed in this PR

Updates flate2 to 1.1.11 across Cargo and Bazel, lifting the dependency hold from #12180. This switches decompression to miniz_oxide 0.9.1; the PR documents the compatibility risk for previously accepted, unusual gzipped canister modules.

Changes:

  • Aligns both build systems on flate2 1.1.11.
  • Removes miniz_oxide 0.8.9 from the locks and updates dependency features and references.
  • Records the optional zlib-rs backend without enabling it.
File Description
Cargo.toml Raises the workspace flate2 requirement to 1.1.11.
Cargo.lock Updates Cargo’s resolved compression dependencies.
Cargo.Bazel.toml.lock Updates Bazel’s resolved compression dependencies.
Cargo.Bazel.json.lock Refreshes Bazel dependency references, features, and checksums.
bazel/​rust.MODULE.bazel Aligns Bazel’s flate2 requirement with Cargo.

Review effort: Balanced

@basvandijk
basvandijk marked this pull request as ready for review November 19, 2026 15:26
@basvandijk
basvandijk requested a review from a team as a code owner November 19, 2026 15:26
@basvandijk
basvandijk requested review from a team and a balanced review from Copilot November 19, 2026 15:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Execution-team sign-off is needed because stricter persisted-Wasm decoding may stop existing canisters from executing, while compatibility for most installed modules and stored snapshots remains unverified.

No open issues 🎉

Review effort: Balanced

@basvandijk
basvandijk added this pull request to the merge queue Nov 19, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Nov 19, 2026
@basvandijk
basvandijk added this pull request to stack #12202 November 19, 2026 18:06
@basvandijk
basvandijk added this pull request to the merge queue Nov 19, 2026
Merged via the queue into master with commit 7347360 Nov 19, 2026
59 checks passed
@basvandijk
basvandijk deleted the bas/bump-flate2-1.1.11 branch November 19, 2026 19:28
cameronraysmith pushed a commit to cameronraysmith/ic that referenced this pull request Nov 20, 2026
…e (RUSTSEC-2026-0258) (dfinity#12193)

Removes h2 0.3.27 from both lock files by turning off actix-web's
`http2` feature. The daily RustSec job
(`.github/workflows/rust-advisories.yml`, e.g. [run
44535761188](https://github.com/dfinity/ic/actions/runs/44535761188))
reports h2 0.3.27 with RUSTSEC-2026-0258:
- h2 accepts and queues empty DATA frames without limit.
- If a stream is not drained, the peer can make memory grow without
bound, or cause a panic once the length overflows.
- The advisory rates it low severity.

**Why h2 0.3 can't be updated:**
- h2 0.3 has no fixed release; the 0.4 line is fixed from 0.4.16. A 0.3
backport (hyperium/h2#948) was closed unmerged.
- Our other h2 users (hyper, tonic, reqwest, hickory-net) are on 0.4.20.
- h2 0.3 comes only from actix-http's optional `http2` feature, and
actix-http has no release on h2 0.4. actix/actix-web#4199 asks for one,
and moving to h2 0.4 also means moving actix-http from http 0.2 to http
1.

**Who uses actix-web:**
- ICP Rosetta uses it directly.
- rosetta-core, which ICRC Rosetta also uses, pulls it in through
actix-web-prom, which enables only actix-web's `macros` feature.
- Only ICP Rosetta runs an actix-web server. ICRC Rosetta serves with
axum.

# Behaviour change: ICP Rosetta serves HTTP/1.x only

- ICP Rosetta's server listens on plain TCP (`HttpServer::bind`),
without TLS.
- Since actix-web 4.19, a plaintext listener also accepts cleartext
HTTP/2 (h2c) by default when the `http2` feature is on.
- dfinity#12177 moved actix-web from 4.13 (Cargo) and 4.9 (Bazel) to 4.20. So
ICP Rosetta built from master since then accepts h2c, and with it
reaches h2 0.3.
- Without the feature it accepts HTTP/1.x only, as every released ICP
Rosetta did. A client that starts with the HTTP/2 preface now gets a 400
from the HTTP/1 parser.
- The last release, 2.1.10 (2026-07-01), predates dfinity#12177, and Rosetta
images are only published by the manual Rosetta Release workflow. So no
published image ever accepted h2c, and the CHANGELOG needs no entry.
- Released images do link h2 0.3.27, but can't reach it. Image scanners
will keep flagging it until the next ICP Rosetta release.
- No client in the repo talks to ICP Rosetta over HTTP/2. Its clients
use plain reqwest over `http://`, which speaks HTTP/1.1.

FYI @dfinity/defi, who own `rs/rosetta-api`.

# Changes

- `Cargo.toml` and `bazel/rust.MODULE.bazel`: remove `http2` from
actix-web's features.
- **Locks:**
- In both lock sets only h2 0.3.27 goes, and the only dependency edge
removed is actix-http's edge to it.
- hyper, tonic, reqwest and hickory-net now list plain `h2` instead of
`h2 0.4.20`, since only one h2 is left.

# Verification

- **Advisories:** I ran the workflow's pinned tools on this branch,
cargo-deny 0.21.0 on `Cargo.lock` and cargo-audit 0.23.0 on
`Cargo.Bazel.toml.lock`. Neither reports RUSTSEC-2026-0258 any more;
three vulnerabilities remain:
  - libsqlite3-sys, fixed in dfinity#12194;
  - rsa 0.9 and crypto-bigint 0.5, which need upstream releases first.
- **Locks:** in the dev container, `cargo update --workspace` reports
"Locking 0 packages". A second `./bin/bazel-pin.sh` reports "Nothing to
repin.", and `bazel mod deps` leaves `MODULE.bazel.lock` unchanged.
- **Build:** `cargo check --all-targets --all-features -p ic-rosetta-api
-p rosetta-core` passes, and the ICP Rosetta binaries build with Bazel.
The Bazel-built binaries contain no h2 0.3 code.
- **Tests:** these pass locally. They exercise HTTP/1.1; nothing tests
that h2c is refused.
  - `//rs/rosetta-api/common/rosetta_core:rosetta_core_unit_tests`;
  - `//rs/rosetta-api/icp:rosetta-api_test`;
- `//rs/rosetta-api/icp:icp_rosetta_system_tests`, which serves the
Rosetta API over HTTP;
-
`//rs/rosetta-api/icp/tests/integration_tests:rosetta-integration_tests/tests_test`.
- **Lint:** CI's Cargo Lint job, which runs `./ci/scripts/rust-lint.sh`,
passes.
- **CI:** before this PR was stacked on dfinity#12191, CI ran every Bazel
target, long tests included, on 419d088 (the same change on top of
375a6af). All 1,163 tests pass, including `icp_rosetta_system_tests`
and the `rosetta_test_local` and `rosetta_neuron_follow_test_local`
system tests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

miniz_oxide accepts invalid literal/length trees

3 participants