8000 SECURITY: gcloud: trust the system CA store instead of the SDK's vendored bundles (CVE-2026-111943) by bryan-minimal · Pull Request #954 · gominimal/pkgs · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/gcloud/build.ncl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let { standaloneTest, subsetOf, Attrs, BuildSpec, Local, OutputBin, OutputData, Source, Test, .. } = import "minimal.ncl" in
let { target, .. } = import "config.ncl" in
let base = import "../base/build.ncl" in
let ca-certificates = import "../ca-certificates/build.ncl" in
let python = import "../python/build.ncl" in
let glibc = import "../glibc/build.ncl" in
let sqlite = import "../sqlite/build.ncl" in
Expand Down Expand Up @@ -41,6 +42,10 @@ in
],
runtime_deps = [
base,
# The SDK's installation properties point core/custom_ca_certs_file at this
# package's /etc/ssl/certs/ca-certificates.crt (see build.sh, CVE-2026-111943),
# and gcloud rejects that property when the file does not exist.
ca-certificates,
python,
glibc,
subsetOf sqlite ["libs"],
Expand Down Expand Up @@ -69,6 +74,22 @@ in
["/bin/bash", "-c", "gcloud config set project test-project 2>/dev/null && gcloud config get project 2>/dev/null | grep -q 'test-project'"],
],
} | Test,

# CVE-2026-111943: the SDK's vendored CA bundles still trust emSign ECC Root
# CA - G3, so build.sh points core/custom_ca_certs_file at the system store
# in the installation properties. Offline: checks that a user with no config
# of their own resolves the property to the system bundle, that the bundle
# is there, and that gsutil's and bq's bootstraps still forward it.
ca_certs_from_system_store =
{
class = 'Standalone,
test_deps = [base],
cmds = [
["/bin/bash", "-c", "export CLOUDSDK_CONFIG=$(mktemp -d) && test \"$(gcloud config get core/custom_ca_certs_file 2>/dev/null)\" = /etc/ssl/certs/ca-certificates.crt"],
["/bin/bash", "-c", "test -s /etc/ssl/certs/ca-certificates.crt"],
["/bin/bash", "-c", "grep -q 'properties.VALUES.core.custom_ca_certs_file' /usr/lib/google-cloud-sdk/bin/bootstrapping/gsutil.py && grep -q 'properties.VALUES.core.custom_ca_certs_file' /usr/lib/google-cloud-sdk/bin/bootstrapping/bq.py"],
],
} | Test,
},

attrs =
Expand Down
52 changes: 52 additions & 0 deletions packages/gcloud/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,58 @@ grep -q "apache.org/licenses/LICENSE-2.0" google-cloud-sdk/LICENSE || {
mkdir -p $OUTPUT_DIR/usr/{bin,lib}
mv google-cloud-sdk $OUTPUT_DIR/usr/lib/google-cloud-sdk

# Trust the system CA store, not the SDK's own copies (CVE-2026-111943).
#
# The SDK vendors about a dozen CA bundles: certifi for gcloud and for bq,
# gsutil's gslib/data/cacerts.txt and its own certifi, grpc's roots.pem, and
# more. In 581.0.0 six of them still trust "emSign ECC Root CA - G3"
# (SHA-256 86A1ECBA...A36BBE6B), which Mozilla distrusted after eMudhra's
# intermediate key compromise (bug 2083449). 590.0.0, the newest release, ships
# the same bundles, so moving the version does not fix it.
#
# `core/custom_ca_certs_file` does. gcloud reads it for its requests, httplib2
# and gRPC transports, and bin/bootstrapping/{gsutil,bq}.py forward it to
# gsutil (`-o Boto:ca_certificates_file=`) and bq (`--ca_certificates_file=`).
# Setting it in the INSTALLATION properties file (`<sdk root>/properties`, the
# same layer as `gcloud config set --installation`) applies it to every user,
# while an A7B9 explicit user or env setting can still override it. The path is
# ca-certificates' bundle (a runtime dep). gcloud refuses a value that does not
# name an existing file, so this works only together with that dep.
#
# Fail closed: the shipped properties file must have exactly one [core] section
# and no existing value, and the value must be there afterwards.
PROPS="$OUTPUT_DIR/usr/lib/google-cloud-sdk/properties"
SYSTEM_CA="/etc/ssl/certs/ca-certificates.crt"
[ -s "$PROPS" ] || {
echo "gcloud: the SDK no longer ships an installation properties file at $PROPS" >&2
exit 1
}
[ "$(grep -c '^\[core\]$' "$PROPS")" = 1 ] || {
echo "gcloud: expected exactly one [core] section in $PROPS" >&2
exit 1
}
if grep -q '^custom_ca_certs_file' "$PROPS"; then
echo "gcloud: $PROPS already sets custom_ca_certs_file; re-audit before overriding it" >&2
exit 1
fi
awk -v line="custom_ca_certs_file = $SYSTEM_CA" '{ print } $0 == "[core]" { print line }' \
"$PROPS" > "$PROPS.new"
mv "$PROPS.new" "$PROPS"
grep -qx "custom_ca_certs_file = $SYSTEM_CA" "$PROPS" || {
echo "gcloud: failed to set custom_ca_certs_file in $PROPS" >&2
exit 1
}
# The value only reaches gsutil and bq because their bootstrap scripts forward
# it. If a future SDK stops doing that, they would silently fall back to their
# vendored bundles, so check that the forwarding is still there.
for tool in gsutil bq; do
grep -q 'properties.VALUES.core.custom_ca_certs_file' \
"$OUTPUT_DIR/usr/lib/google-cloud-sdk/bin/bootstrapping/$tool.py" || {
echo "gcloud: bin/bootstrapping/$tool.py no longer forwards core/custom_ca_certs_file" >&2
exit 1
}
done

# Create wrapper scripts for the main CLI tools
for bin in gcloud gsutil bq; do
cat > "${OUTPUT_DIR}/usr/bin/${bin}" << EOF
Expand Down
Loading
0