Skip to content

[WIP/bp/1.39] CVE/wasmtime stack - #49061

Closed
phlax wants to merge 39 commits into
envoyproxy:release/v1.39from
phlax:bp-1.39-cve
Closed

phlax wants to merge 39 commits into
envoyproxy:release/v1.39from
phlax:bp-1.39-cve

Conversation

@phlax

@phlax phlax commented Nov 6, 2026

Copy link
Copy Markdown
Member

No description provided.

@repokitteh-read-only repokitteh-read-only Bot added the deps Approval required for changes to Envoy's external dependencies label Nov 6, 2026
@phlax
phlax marked this pull request as draft November 6, 2026 19:01
@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).
envoyproxy/dependency-shepherds assignee is @agrawroh

🐱

Caused by: #49061 was opened by phlax.

see: more, trace.

@phlax phlax changed the title [bp/1..39] CVE/wasmtime stack [WIP/bp/1.39] CVE/wasmtime stack Nov 6, 2026
agrawroh
agrawroh previously approved these changes Nov 10, 2026
@repokitteh-read-only repokitteh-read-only Bot removed the deps Approval required for changes to Envoy's external dependencies label Nov 10, 2026
phlax and others added 12 commits November 12, 2026 09:51
Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit 1b8e063)
Signed-off-by: Ryan Northey <[email protected]>
…oxy#49052)

Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit df17c97)
Signed-off-by: Ryan Northey <[email protected]>
Partial backport of envoyproxy#48434: `ENVOY_SKIP_CTO_WASMTIME` skipped the wasmtime leg unless set
(inverted since envoyproxy#43249), and add the `cto` alias.

(cherry picked from commit 6b08712)
Signed-off-by: Ryan Northey <[email protected]>
The vendored wasmtime-c-api-impl crate's build.rs only shells out to `cmake` to install the C
headers and emit `cargo:include`, which Bazel never uses: the headers come from the wasmtime
archive and `conf.h` is generated in wasmtime.BUILD. On RBE `cmake` is not on the build
script's PATH, so the wasmtime compile-time-options leg fails to build it.

Signed-off-by: Ryan Northey <[email protected]>
Bazel's patcher needs a blank line between files in a plain unified diff; without it the
appended hunk was read as part of the preceding BUILD hunk.

Signed-off-by: Ryan Northey <[email protected]>
Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit d5005ca)
Signed-off-by: Ryan Northey <[email protected]>
wasmtime 45.0.2 (wasmtime-environ) needs rustc >= 1.93.0 (`fmt::from_fn`); 1.93.1 is the newest
release with checksums in rules_rust 0.69.0.

Signed-off-by: Ryan Northey <[email protected]>
rules_rust 0.69.0's `_symlink_sysroot_tree` ignores its `target_files` argument, so the
`gcc-ld/` wrappers shipped as runfiles of the `rust-lld` linker target never reach the
sysroot. Since Rust 1.90, x86_64-unknown-linux-gnu links with the self-contained lld by default
and rustc fails: "the self-contained linker was requested, but it wasn't found in the target's
sysroot, or in rustc's sysroot". Fixed upstream in later rules_rust (0.74 iterates
`target_files`).

Signed-off-by: Ryan Northey <[email protected]>
… sysroot

rules_rust 0.69.0 symlinks the `rust-lld` linker to `<sysroot>/bin/`, but the `gcc-ld/ld.lld`
wrapper rustc now uses by default execs `../rust-lld` relative to itself, i.e.
`lib/rustlib/<triple>/bin/rust-lld`: "lld-wrapper: could not exec rust-lld". Place it where
later rules_rust (0.74) does.

Signed-off-by: Ryan Northey <[email protected]>
…module

Rust 1.93 clippy flags `is_some()` + `unwrap()` under `-Dwarnings`; use `if let` as main does
(from envoyproxy#48201).

Signed-off-by: Ryan Northey <[email protected]>
Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit 3422ca0)
Signed-off-by: Ryan Northey <[email protected]>
phlax and others added 13 commits November 12, 2026 09:51
…bled

MemoryTest::mode() is Disabled outside tcmalloc builds, but consumedBytes() still returned the raw allocator delta, and the EXPECT_MEMORY_EQ(x, 0) and plain EXPECT_EQ(consumedBytes(), 0) call sites assert on it regardless of mode. Under the jemalloc leg of compile_time_options on this branch that delta is noise (thread_local_store_test RejectPrefixDot saw memory freed mid-region, codec_impl_test saw 9600 bytes inside dumpState); the same tests pass on main/1.40 with the BCR jemalloc module, and matching that build on 1.39 (enabling jemalloc C++ support in the configure_make build) does not compile against the hermetic libc++. Return 0 when measurement is disabled so those assertions only mean something where the allocator is one they were written for.
Signed-off-by: Ryan Northey <[email protected]>
The Rust 1.93.1 repin only updated the root `Cargo.Bazel.lock`. The `docs`
and `bazel/tests/external` workspaces have their own lockfiles, whose
checksums were left stale, so `envoy_rust_crate_index` failed to fetch
there with a digest mismatch (config, external and docs CI).

Signed-off-by: Ryan Northey <[email protected]>
…indings

Since Rust 1.85 `unpredictable_function_pointer_comparisons` warns on
`PartialEq` derives over function pointers, and the SDK builds with
`#![deny(warnings)]`. bindgen derives `PartialEq` on system header structs
such as `__darwin_pthread_handler_rec`, so the SDK no longer compiles on
macOS with Rust 1.93.1.

Allow the lint on the generated `abi` module, as main does since envoyproxy#48201.

Signed-off-by: Ryan Northey <[email protected]>
`mcp_json_rest_bridge_filter_test` and
`client_side_weighted_round_robin_lb_test` are not pinned to a pool, and
their GCC compiles timed out after 30 minutes on the default pool in
consecutive attempts of the same CI run. Pin them to `6gig`, as most other
test targets on this branch are.

Signed-off-by: Ryan Northey <[email protected]>
…bility_integration_test (envoyproxy#47390)

Commit Message: Deflake test
//test/extensions/filters/http/ext_proc:ext_proc_observability_integration_test
Additional Description:
([flaky
failure](https://github.com/envoyproxy/envoy/actions/runs/34641194427/job/103401038646#annotation:20:4227))
```
  [ RUN      ] IpVersionsClientTypeDeferredProcessing/ExtProcIntegrationTest.ObservabilityModeWithLoggingCloseStream/2
  test/extensions/filters/http/ext_proc/logging_test_filter.cc:47: Failure
  Expected equality of these values:
    ext_proc_logging_info->httpResponseCodeDetails()
      Which is: ""
    expected_rcd_
      Which is: "via_upstream"
```
finishGrpcStream() only queues the gRPC trailers. In observability mode,
the main request proceeds independently and could complete first. The
logging filter then inspected the side-stream StreamInfo before its
response headers had been processed, so via_upstream had not yet been
assigned.

AI assisted with Codex Sol.
Risk Level: test-only
Testing: yes
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a

Signed-off-by: Raven Black <[email protected]>

Use `testing::Ge`, as this branch has no using-declaration for it.

(cherry picked from commit 43c353c)
Signed-off-by: Ryan Northey <[email protected]>
Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit 8fc0b64)
Signed-off-by: Ryan Northey <[email protected]>
WORKSPACE port of the bump on main: the version and sha256 in
`repository_locations.bzl` and the release date in `deps.yaml`, with the
test and changelog changes taken from the original commit.

The BCR build overlay is unchanged between 1.34.6 and 1.34.9, so
`bazel/external/c-ares.BUILD` and the config headers need no update, and
`bazel/c-ares.patch` still applies.

(ported from commit 4b80277)

Signed-off-by: Ryan Northey <[email protected]>
WORKSPACE port of envoyproxy#48777 and envoyproxy#49051: replace the in-repo CVE scanner with
toolshed's `cve_scan`, and include CVE Program (cvelist) data in the
scan and fetch.

The scan workflow now syncs the data bucket recursively, so the
`cvelist/` data that main fetches is picked up, and `cve_pip3` is
installed for the fetchers.

(ported from commit 1b4730b)
(ported from commit fbeeb37)

Signed-off-by: Ryan Northey <[email protected]>
wasmtime 49 needs rustc >= 1.96.0.

rules_rust 0.69.0 only has checksums up to 1.93.1, so pin the toolchain archives for Linux and
macOS (x86_64 and aarch64) and the wasm targets directly.

The crate_universe lockfile digests include the Rust version, so repin the three
`envoy_rust_crate_index` lockfiles (checksum only).

Signed-off-by: Ryan Northey <[email protected]>
Fixes the 17 CVEs reported against wasmtime 45.0.2. No 45.x release fixes them; 49.0.5 is the
current release, and what main uses.

Until now the `wasmtime` pin only supplied the C API headers. The runtime itself came from the
crates vendored in proxy_wasm_cpp_host, which are still at 45.0.2 upstream, so bumping the pin
alone would not have changed what is built.

Build the C API from the `wasmtime` source archive instead, as the bzlmod registry module does on
main, against a new `@wasmtime_crates` index:

- the `wasmtime` crates are requested at exactly the pinned version, so the pin now decides the
  runtime version
- everything else is pinned by `bazel/external/wasmtime/Cargo.lock`, seeded from the lockfile in
  the source archive (every locked version is one upstream locks)
- the crates vendored by proxy_wasm_cpp_host, its `wasmtime.BUILD` and its header prefix patch
  are no longer used, and the Envoy patches to them are dropped

The C API keeps being linked as a Rust staticlib. Its symbols are no longer prefixed with
`wasmtime_`, as on main: only one Wasm engine is linked into a build.

Signed-off-by: Ryan Northey <[email protected]>
With the Rust bump on this branch, wasm targets no longer link with
undefined symbols, and proxy-wasm-rust-sdk 0.2.4 declares its host
functions in plain `extern "C"` blocks. Every Rust wasm test module
failed to link:

  rust-lld: error: ... undefined symbol: proxy_set_effective_context

proxy-wasm-rust-sdk 0.2.5 fixes this by declaring the import module
(proxy-wasm/proxy-wasm-rust-sdk#365). 0.2.5 also restructures the Bazel
files this branch's WORKSPACE setup loads, so patch 0.2.4 with the same
37 attributes rather than bumping it.

Signed-off-by: Ryan Northey <[email protected]>
The bump to 0.4.13.post1 left the release date of 0.4.13.post0, which fails the
dependency check:

  [release_dates] Mismatch: envoy_toolshed 2026-09-29 != 2026-11-09

Signed-off-by: Ryan Northey <[email protected]>
phlax and others added 2 commits November 12, 2026 09:57
Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit f8b232f)
Signed-off-by: Ryan Northey <[email protected]>
envoyproxy#49180)

envoyproxy#48471 made the fatal signal handler write fault descriptions and
backtraces directly to stderr, so that it does not re-enter the logger.
The release note describes that as a bug fix, but does not say that the
output no longer reaches configured log sinks such as `--log-path`.

State it explicitly as a minor behavior change, as it matters to anyone
collecting crash backtraces from the log file, in particular when the
fix is backported to a stable branch.

Signed-off-by: Ryan Northey <[email protected]>
…_ENV (envoyproxy#47858)

Additional Description:
`export OVERWRITE_ALL_CVE_DATA=1` does not survive across steps, so the
Sunday full refetch only fetches the current month. The first Sunday run
after merge will refetch all months since 2021.

Risk Level: Low
Testing: Sunday and Tuesday scheduled runs both log only `RECV
(2026-09)`. Verified the fix on a fork.
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Sona Molnarova <[email protected]>
Signed-off-by: Ryan Northey <[email protected]>

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.

🟡 Changes recommended

Calling mode() on every sample allocates on tcmalloc builds, distorting memory measurements and violating the fatal-error callback’s allocation-free requirement; cache the mode before recording the construction baseline.

1 open issue
What changed in this PR

This backport updates Envoy’s Wasmtime and CVE tooling, hardens fatal-signal diagnostics, and fixes allocator accounting and test compatibility.

Changes:

  • Updates Wasmtime, c-ares, and Rust tooling, with associated build patches and dependency locks.
  • Replaces local CVE scripts with Toolshed scanning and fetching targets.
  • Improves signal-stack sizing, stderr backtraces, jemalloc accounting, and compile-time-option tests.
File Description
tools/​spelling/​spelling_dictionary.txt Adds architecture terminology.
tools/​dependency/​version.jq Removes local version comparison helpers.
tools/​dependency/​cves.sh Removes the local CVE scanner.
tools/​dependency/​cve.yaml Documents a C-only msgpack CVE exclusion.
tools/​dependency/​cve_utils.jq Removes local CVE matching utilities.
tools/​dependency/​cve_update.sh Removes the local update wrapper.
tools/​dependency/​cve_test.sh Removes the local CVE test script.
tools/​dependency/​cve_report.jq Removes local report formatting.
tools/​dependency/​cve_matcher.jq Removes the local matching entry point.
tools/​dependency/​cve_fetch.py Removes the local NVD downloader.
tools/​dependency/​BUILD Adopts Toolshed CVE targets and nested data files.
tools/​dependency/​ansi.jq Removes obsolete report color helpers.
test/​server/​backtrace_test.cc Tests stderr fault and backtrace output.
test/​integration/​base_integration_test.cc Handles listener diagnostics without admin support.
test/​extensions/​network/​dns_resolver/​cares/​dns_impl_test.cc Updates TTL and timer expectations for c-ares.
test/​extensions/​load_balancing_policies/​client_side_weighted_round_robin/​BUILD Assigns a larger remote execution pool.
test/​extensions/​filters/​http/​mcp_json_rest_bridge/​BUILD Assigns a larger remote execution pool.
test/​extensions/​filters/​http/​ext_proc/​ext_proc_integration_common.cc Waits for processor stream closure.
test/​extensions/​filters/​http/​bandwidth_share/​filter_integration_test.cc Skips an admin-dependent test when unavailable.
test/​extensions/​dynamic_modules/​test_data/​rust/​http.rs Replaces checked unwraps with pattern matching.
test/​extensions/​dynamic_modules/​test_data/​rust/​http_integration_test.rs Simplifies optional body handling.
test/​extensions/​dynamic_modules/​test_data/​rust/​cluster_integration_test.rs Avoids cloning single-element address slices.
test/​extensions/​dynamic_modules/​bootstrap/​integration_test.cc Guards an admin-dependent test.
test/​extensions/​common/​wasm/​test_data/​test_rust.rs Declares the host import module.
test/​extensions/​access_loggers/​stats/​stats_test.cc Handles negative allocation deltas in assertions.
test/​exe/​BUILD Restricts the Windows service test to Windows.
test/​common/​signal/​signals_test.cc Tests fatal-signal descriptions.
test/​common/​memory/​memory_test_utility.h Returns zero when memory measurement is disabled.
test/​common/​memory/​heap_shrinker_test.cc Adds jemalloc expectations and subtraction checks.
source/​server/​backtrace.h Adds decoder-compatible stderr diagnostics.
source/​extensions/​dynamic_modules/​sdk/​rust/​src/​lib.rs Allows a lint in generated ABI bindings.
source/​common/​signal/​signal_action.h Enlarges and dynamically sizes alternate stacks.
source/​common/​signal/​signal_action.cc Uses safe signal descriptions and bypasses logging sinks.
source/​common/​memory/​stats.cc Includes jemalloc retained pages in reserved memory.
docs/​Cargo.Bazel.lock Refreshes the Rust lockfile checksum.
ci/​do_ci.sh Adjusts Wasmtime test execution and Rust module exclusions.
changelogs/​current/​minor_behavior_changes/​logging__fatal-signal-backtraces-stderr.rst Documents the switch to stderr crash output.
changelogs/​current/​minor_behavior_changes/​dns__cares-ttl-clamping.rst Documents changed DNS TTL handling.
changelogs/​current/​bug_fixes/​memory__jemalloc-reserved-accounting.rst Documents corrected jemalloc accounting.
changelogs/​current/​bug_fixes/​logging__fatal-signal-backtraces.rst Documents backtrace and signal-stack fixes.
changelogs/​changelogs.yaml Adds the memory changelog area.
Cargo.Bazel.lock Refreshes the root Rust lockfile checksum.
bazel/​tests/​external/​Cargo.Bazel.lock Refreshes the downstream Rust lockfile checksum.
bazel/​rules_rust.patch Fixes sysroot file selection and linker placement.
bazel/​repository_locations.bzl Updates Toolshed, c-ares, and Wasmtime pins.
bazel/​repositories.bzl Applies Rust SDK fixes and the local Wasmtime build.
bazel/​repositories_extra.bzl Removes legacy Wasmtime crate registration.
bazel/​proxy_wasm_rust_sdk.patch Declares WebAssembly host import modules.
bazel/​proxy_wasm_cpp_host.patch Adds Wasmtime signature validation and tests.
bazel/​external/​wasmtime/​Cargo.lock Pins the Wasmtime crate dependency graph.
bazel/​external/​wasmtime/​BUILD Exports Wasmtime lockfiles.
bazel/​external/​wasmtime.BUILD Defines the Wasmtime C API build and feature header.
bazel/​envoy_test.bzl Exposes target platform compatibility constraints.
bazel/​deps.yaml Updates dependency dates and c-ares matching metadata.
bazel/​dependency_imports.bzl Registers CVE dependencies, Rust tooling, and Wasmtime crates.
bazel/​dependency_imports_extra.bzl Registers resolved Wasmtime crate repositories.
api/​bazel/​repository_locations.bzl Synchronizes the API workspace’s Toolshed pin.
api/​bazel/​deps.yaml Updates the API Toolshed release date.
.github/​workflows/​_cve_scan.yml Uses recursive data sync and the new scanner target.
.github/​workflows/​_cve_fetch.yml Updates fetch invocation, credentials, and refresh propagation.

Review effort: Balanced

@repokitteh-read-only repokitteh-read-only Bot added the deps Approval required for changes to Envoy's external dependencies label Nov 12, 2026
@phlax
phlax requested a balanced review from Copilot November 12, 2026 11:13

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.

🟡 Changes recommended

The signal handler mutates a process-wide non-atomic flag that backtrace logging reads without synchronization, creating a data race and potential undefined behavior in crash reporting.

1 open issue
1 resolved since last review

Review effort: Balanced

// The logger mutex may be held on this thread (a crash inside logging or a FatalAction
// raising another signal), or inherited locked across fork() in death tests. Neither
// backtrace may route through spdlog/absl::Mutex in the handler.
BackwardsTrace::setLogToStderr(true);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This comes from main (#48471) rather than this branch. Fixed there in #49207, where the flag is now a std::atomic<bool> in both BackwardsTrace and Coroutine::Backtrace; that will be backported once it lands.

phlax and others added 2 commits November 13, 2026 07:46
could deadlock or abort on the logger mutex, and sent it to `std::cerr`.
That is not async-signal-safe either: iostream output goes through the
stdio lock and is not guaranteed to be allocation free, so a signal
arriving while the same thread is inside a stream or allocator call can
still hang or fault again before the backtrace and the fatal actions
run.

This adds `StderrWriter`, which builds a line in a fixed buffer and
writes it with a single `write(2)`, and uses it for the fault line and
for the regular and coroutine backtraces when they are directed to
stderr. The output is unchanged.

`printTrace()` goes back to taking only a stream, as its prefixed form
was only used for this path.

Not covered: the fatal error handlers that run after the backtrace are
still handed `std::cerr`, as before.

Risk Level: low
Testing: unit test for `StderrWriter`; the existing
`Backward.FaultToStderr`, `Backward.TraceToStderr` and coroutine stderr
tests cover the output format
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a

---------

Signed-off-by: Ryan Northey <[email protected]>
`MemoryTest::mode()` allocates on tcmalloc builds, where it checks that
it can measure an allocation. `consumedBytes()` called it on every
sample, so every measurement included that allocation. Read it once, in
the constructor, before the baseline is taken.

This is the version of the earlier commit on this stack that went into

Signed-off-by: Ryan Northey <[email protected]>
envoyproxy#49205.
@phlax

phlax commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Superseded by #49205, which now has all of these commits, on top of the flattened CI layout (with cto.wasmtime turned on there).

@phlax phlax closed this Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deps Approval required for changes to Envoy's external dependencies workflows:untested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants