Sign GCS service-account JWTs with aws-lc-rs [SECURITY] - #2734
Open
MarcusSorealheis wants to merge 4 commits into
Open
Sign GCS service-account JWTs with aws-lc-rs [SECURITY]#2734MarcusSorealheis wants to merge 4 commits into
MarcusSorealheis wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
MarcusSorealheis
force-pushed
the
fix-vuln-2023-0071
branch
from
September 5, 2026 03:48
5363462 to
a874f2e
Compare
MarcusSorealheis
force-pushed
the
fix-vuln-2023-0071
branch
from
September 5, 2026 07:04
a874f2e to
f21d9bc
Compare
MarcusSorealheis
force-pushed
the
fix-vuln-2023-0071
branch
from
September 5, 2026 08:07
f21d9bc to
86ef402
Compare
MarcusSorealheis
force-pushed
the
fix-vuln-2023-0071
branch
from
September 5, 2026 08:24
86ef402 to
c854d82
Compare
Fixes RUSTSEC-2023-0071 (Marvin attack) by dropping the `rsa` crate, which has no patched release. Its only consumer was jsonwebtoken's `rust_crypto` backend behind gcloud-auth's `jwt-rust-crypto` feature; switch to `jwt-aws-lc-rs`, gcloud-auth's default backend. aws-lc-rs is linked only for JWT signing. Every rustls stack still runs on ring through the process-default provider, and rustls's aws-lc-rs feature stays off. Under Bazel, aws-lc-sys's cargo build script compiles against glibc headers while the LRE toolchain links musl, leaving `__isoc23_sscanf` undefined. Adopt the rules_rs recipe instead: build script off, link against the BCR `aws-lc` module with bindgen-generated bindings. The Cargo Native workflow sets AWS_LC_SYS_PREBUILT_NASM=1 so the x86_64 Windows job builds aws-lc-sys from the crate's prebuilt NASM objects instead of requiring NASM on the runner. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RW4DfubnMqK4UXHmG1J4vE
MarcusSorealheis
force-pushed
the
fix-vuln-2023-0071
branch
from
September 5, 2026 08:32
c854d82 to
3bce3bc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Removes the
rsacrate from the dependency graph to clearRUSTSEC-2023-0071 (Marvin attack:
non-constant-time RSA that can leak private-key material through timing).
The advisory has no fixed version, so the only way to make the OpenSSF
Scorecard vulnerabilities check stop flagging it is to stop depending on
rsaaltogether.The single consumer is
jsonwebtoken'srust_cryptobackend, whichgcloud-authuses to sign Google service-account JWTs. This switchesnativelink-store'sgcloud-authfeature fromjwt-rust-cryptotojwt-aws-lc-rs, which isgcloud-auth's own default backend. That dropsrsaplus 22 other RustCrypto crates (p256,p384,ed25519-dalek,num-bigint-dig,pkcs1, ...) and addsaws-lc-rs,aws-lc-sys,cmake,fs_extraanduntrusted.Scope of the crypto change:
aws-lc-rsis only linked for JWT signing.Every rustls stack in the binary still runs on
ringvia the processdefault provider installed in
common_s3_utilsandnativelink.rs; therustlscrate'saws-lc-rsfeature stays off, so there is no second rustlsprovider to race with. The comments in
nativelink-store/Cargo.tomlareupdated to say so. The rules_rs crate metadata in
MODULE.bazel.lockwasregenerated for the new graph.
Bazel: hermetic aws-lc instead of the cargo build script
The first CI run of this PR failed every Linux Bazel job at link time with
mold: error: undefined symbol: __isoc23_sscanf(referenced fromaws-lc-sys'sbcm.c).aws-lc-sys's cargo build script compiles its Cwith the toolchain's glibc 2.42 headers, which rename
sscanfto__isoc23_sscanf, while the LRE Rust toolchain links against musl, whichhas no such symbol. #2452 hit the same wall and #2472 avoided it by dropping
aws-lc entirely.
rules_rs ships a supported answer for exactly this: it prints a warning
recommending the well-known annotation that turns the build script off and
links the crate against the BCR
aws-lcmodule (built by Bazel's own C++toolchain for the target platform) with bindgen-generated bindings.
MODULE.bazelnow carries that recipe verbatim:bazel_dep(aws-lc), theprebuilt bindgen toolchain from rules_rs,
gen_build_script = "off"foraws-lc-rs/aws-lc-sys, andinject_repo(crate, "aws-lc"). Cargo buildsare unaffected.
That moved the C compile into Bazel, but the Nix clang used for Linux builds
(LRE-CC under Bazel,
TARGET_CCfor the cargo/Nix packages) still compilesagainst glibc headers while the Rust side links musl, so the second CI run
failed on the same class of symbol, and the Nix
cargo llvm-covbuild inthe Coverage job failed the same way:
fopen64,__isoc23_sscanfand__isoc23_strtol, the complete list mold reports. A blanket--defsymlink flag was tried next and broke every lld-based job (lldrefuses an alias whose target is absent from the link).
What is in the PR now:
nativelink-store/aws_lc_musl_shims.c, threeforwarders that give those glibc names a definition on musl targets. It is
compiled by a new
build.rsfor cargo (only whenCARGO_CFG_TARGET_ENVismusl) and by anaws_lc_musl_shimscc_libraryfor Bazel (only under@local-remote-execution//libc:musl), which the aws-lc-sys annotation linksin with
alwayslink. On glibc targets both are empty. The crane sourcefilter in
flake.nixnow lets that one.cfile through, since it onlypasses cargo sources by default. The proper fix is a
musl C toolchain for the musl Rust platforms in the Nix/LRE setup; that is
out of scope for a dependency bump, and this PR is the first thing that
makes the mismatch visible.
Worth weighing before merging. This is the third build-system
accommodation for one advisory: the hermetic
aws-lcmodule for Bazel, themusl shims for Bazel and cargo, and the NASM env for Windows. #2452 and
#2472 both backed away from aws-lc for the same musl pain. The Marvin attack
needs an attacker who can time RSA private-key operations on chosen inputs;
here the only RSA operation is signing a JWT NativeLink builds itself, so
the practical exposure is close to nil. Accepting RUSTSEC-2023-0071 as a
known, unexploitable finding is a legitimate alternative to this PR.
How was this verified?
cargo update -wafter the feature change;cargo tree -i rsanowreturns nothing.
cargo check --allpasses.cargo test -p nativelink-store --profile=smol --test gcs_client_test --test gcs_store_testpasses (35 tests) with the new backend linked in.bazel build --nobuild //:nativelinkregenerated the crate metadata andpulled the
aws-lcmodule;bazel build @crates//:aws-lc-sys-0.45.0 @crates//:aws-lc-rs-1.18.1, a fullbazel build //:nativelink, andbazel test //nativelink-store:integration_tests/gcs_client_test_testall succeed on aarch64 macOS with the repository's LLVM toolchain. The
resulting binary links AWS-LC's
aws_lc_bazel_-prefixed symbols andaws-lc-sysno longer has a_bsbuild-script target.windows-2022:aws-lc-sysneeds NASM toassemble on x86_64 Windows and the runner image does not ship it. The
Cargo Native workflow now sets
AWS_LC_SYS_PREBUILT_NASM=1, which makesthe crate use the prebuilt NASM objects it carries (a no-op on every other
target). Anyone building on Windows locally needs NASM on
PATHor thatvariable set.
needed extra C flags for
aws-lcunder musl and Migrate Azure Blob store to azure_storage_blob 1.0 #2472 later moved thetree to ring-only, so the LRE and native-bazel CI jobs are the real test
for this PR.
Risk
Moderate. This adds a C crypto library to the build for every platform that
compiles
nativelink-store, which is where a regression would show first(build breakage in the Linux/musl CI jobs, or a larger binary), not at
runtime. Runtime behavior only changes for GCS deployments authenticating
with a service-account key file: the JWT is now signed by aws-lc instead of
the
rsacrate. Deployments using workload identity or the metadata servernever sign a JWT and are unaffected.
🤖 Generated with Claude Code
https://claude.ai/code/session_01RW4DfubnMqK4UXHmG1J4vE
This change is