← Back to Pull requests

Distrust incident CA roots in Bionic and Focal workers #1275

Merged
cpuguy83 merged 3 files (124 lines) on Oct 27, 2026 21:30 UTC
View on GitHub
cpuguy83 cpuguy83 commented on Oct 26, 2026 23:50 UTC
Author

What this PR does / why we need it:

Deselect emSign ECC Root CA - G3 and Comodo AAA Services root in Bionic/Focal workers and regenerate their system trust stores, matching USN-8944-2 where fixed packages require ESM. Covers native and cross-architecture worker builds without changing other distributions.

Which issue(s) this PR fixes:

N/A

Special notes for your reviewer:

Integration tests verify both roots are absent from decoded CA bundles and hashed stores on amd64 and arm64. All four worker cases, short tests, custom lint, and generation checks passed. Both worker images also rejected the incident test endpoint with curl error 60.

Named worker overrides remain unchanged. This adjusts the system CA store, not independent application/NSS stores.

Diff: 124 lines (+123 / -1) across 3 files Reviewer: jeremyrickard Review duration: 1299m
All Vouch review confidence checks passed
Residual risk 0.04 = Change Risk (0.35) × (1 − Review Confidence (0.89)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.35 · 124 lines diff across 3 files
0.35
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.85 · 5 substantive comment(s)
0.85
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
88%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.289
Real PR Conversation Timeline
14 items
copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Oct 26, 2026 23:55 UTC
Reviewer

<!-- ccr-overview-v2 -->

🟢 Approval recommended

The mitigation is narrowly scoped, includes regression coverage for both worker architectures, and has no unresolved review findings.

No open issues 🎉

<details>
<summary><strong>What changed in this PR</strong></summary>

This PR removes trust in two incident CA roots from Dalec’s constructed Bionic and Focal workers, covering native and cross-architecture builds without changing other distributions or named worker overrides.

Changes:

  • Deselects the emSign ECC G3 and Comodo AAA Services roots and regenerates the system trust store.

  • Adds amd64 and arm64 integration checks that decode certificates and verify both roots are absent from CA bundles and hashed stores.
  • | File | Description |
    | ---- | ----------- |
    | test/​worker_ca_test.go | Adds certificate checks for both architectures and trust-store formats. |
    | test/​target_ubuntu_test.go | Enables CA distrust checks for Bionic and Focal. |
    | targets/​linux/​deb/​distro/​worker.go | Applies targeted CA distrust during native and cross-architecture worker construction. |
    </details>

    <sub>Review effort: Balanced</sub>

    jeremyrickard jeremyrickard approved these changes on Oct 27, 2026 00:53 UTC
    Approved Reviewer

    Approved these changes.

    invidian invidian commented on code on Oct 27, 2026 14:43 UTC
    Code Review
    test/worker_ca_test.go:1
    @@ -0,0 +1,83 @@
    +package test
    +
    +import (
    +	"context"
    +	"crypto/x509"
    +	"encoding/pem"
    +	"path"
    +	"regexp"
    +	"strings"
    +	"testing"
    +
    +	gwclient "github.com/moby/buildkit/frontend/gateway/client"
    +	ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
    +	"gotest.tools/v3/assert"
    +)
    +
    +func testWorkerCADistrust(t *testing.T, target targetConfig) {
    +	t.Run("worker-ca-distrust", func(t *testing.T) {
    +		for _, arch := range []string{"amd64", "arm64"} {
    +			t.Run(arch, func(t *testing.T) {
    +				t.Parallel()
    +
    +				ctx := startTestSpan(baseCtx, t)
    +				platform := ocispecs.Platform{OS: "linux", Architecture: arch}
    +				testEnv.RunTest(ctx, t, func(ctx context.Context, client gwclient.Client) {
    +					// Deliberately use the constructed worker, without a custom worker context.
    +					req := newSolveRequest(withSpec(ctx, t, nil), withBuildTarget(target.Worker), withPlatform(platform))
    +					res := solveT(ctx, t, client, req)
    +					ref, err := res.SingleRef()
    +					assert.NilError(t, err)
    +					checkWorkerCAs(ctx, t, ref)
    +				})
    +			})
    +		}
    +	})
    +}
    +
    +func readWorkerCertificates(ctx context.Context, t *testing.T, ref gwclient.Reference, filename string) []*x509.Certificate {
    +	t.Helper()
    +
    +	data, err := ref.ReadFile(ctx, gwclient.ReadRequest{Filename: filename})
    +	assert.NilError(t, err, filename)
    +
    +	var certs []*x509.Certificate
    +	for len(strings.TrimSpace(string(data))) != 0 {
    +		block, rest := pem.Decode(data)
    +		assert.Assert(t, block != nil, "invalid PEM in %s", filename)
    +		assert.Equal(t, block.Type, "CERTIFICATE", filename)
    +		cert, err := x509.ParseCertificate(block.Bytes)
    +		assert.NilError(t, err, filename)
    +
    +		certs = append(certs, cert)
    +		data = rest
    +	}
    +	assert.Assert(t, len(certs) != 0, "no certificates in %s", filename)
    +
    +	return certs
    +}
    +
    +func checkWorkerCAs(ctx context.Context, t *testing.T, ref gwclient.Reference) {

    nit: seems like this could be inlined in testWorkerCADistrust. I'd rather add a helper for setting up test, rather than putting actual test logic in separate function.

    invidian invidian commented on code on Oct 27, 2026 14:43 UTC
    Code Review
    test/worker_ca_test.go:1
    @@ -0,0 +1,83 @@
    +package test
    +
    +import (
    +	"context"
    +	"crypto/x509"
    +	"encoding/pem"
    +	"path"
    +	"regexp"
    +	"strings"
    +	"testing"
    +
    +	gwclient "github.com/moby/buildkit/frontend/gateway/client"
    +	ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
    +	"gotest.tools/v3/assert"
    +)
    +
    +func testWorkerCADistrust(t *testing.T, target targetConfig) {
    +	t.Run("worker-ca-distrust", func(t *testing.T) {
    +		for _, arch := range []string{"amd64", "arm64"} {
    +			t.Run(arch, func(t *testing.T) {
    +				t.Parallel()
    +
    +				ctx := startTestSpan(baseCtx, t)
    +				platform := ocispecs.Platform{OS: "linux", Architecture: arch}
    +				testEnv.RunTest(ctx, t, func(ctx context.Context, client gwclient.Client) {
    +					// Deliberately use the constructed worker, without a custom worker context.
    +					req := newSolveRequest(withSpec(ctx, t, nil), withBuildTarget(target.Worker), withPlatform(platform))
    +					res := solveT(ctx, t, client, req)
    +					ref, err := res.SingleRef()
    +					assert.NilError(t, err)
    +					checkWorkerCAs(ctx, t, ref)
    +				})
    +			})
    +		}
    +	})
    +}
    +
    +func readWorkerCertificates(ctx context.Context, t *testing.T, ref gwclient.Reference, filename string) []*x509.Certificate {

    nit: could go below checkWorkerCAs if we keep it, since it's a less significant helper.

    invidian invidian commented on code on Oct 27, 2026 14:48 UTC
    Code Review
    targets/linux/deb/distro/worker.go:1
    @@ -210,7 +238,17 @@ func (cfg *Config) workerWithBuildPlatform(sOpt dalec.SourceOpts, buildPlat ocis
     		dalec.WithMountedAptCache(cacheKey),
     	)
     
    -	return es.GetMount(rootfsMount).Platform(targetPlat)
    +	worker := es.GetMount(rootfsMount).Platform(targetPlat)
    +	if script := cfg.workerCADistrustScript(); script != "" {

    nit: Maybe it could be defined in Worker(), so we check this condition only once? Or make workerCADistrustScript return llb.State, either amended or not to confine the conditional?

    invidian invidian approved these changes on Oct 27, 2026 14:48 UTC
    Approved Reviewer

    LGTM, some suggestions for more simplicity.

    cpuguy83 cpuguy83 commented on code on Oct 27, 2026 16:15 UTC
    Code Review
    targets/linux/deb/distro/worker.go:1
    @@ -210,7 +238,17 @@ func (cfg *Config) workerWithBuildPlatform(sOpt dalec.SourceOpts, buildPlat ocis
     		dalec.WithMountedAptCache(cacheKey),
     	)
     
    -	return es.GetMount(rootfsMount).Platform(targetPlat)
    +	worker := es.GetMount(rootfsMount).Platform(targetPlat)
    +	if script := cfg.workerCADistrustScript(); script != "" {

    The result of this function is what Worker() returns. I could factor it out into an llb.StateOption instead, but its effectively the same thing.
    I'm not sure I follow what you mean by checking the condition only once?

    cpuguy83 cpuguy83 commented on code on Oct 27, 2026 16:30 UTC
    Code Review
    targets/linux/deb/distro/worker.go:1
    @@ -210,7 +238,17 @@ func (cfg *Config) workerWithBuildPlatform(sOpt dalec.SourceOpts, buildPlat ocis
     		dalec.WithMountedAptCache(cacheKey),
     	)
     
    -	return es.GetMount(rootfsMount).Platform(targetPlat)
    +	worker := es.GetMount(rootfsMount).Platform(targetPlat)
    +	if script := cfg.workerCADistrustScript(); script != "" {

    Actually trying to factor it out into a state option is far more complicated.

    invidian invidian commented on code on Oct 27, 2026 16:54 UTC
    Code Review
    targets/linux/deb/distro/worker.go:1
    @@ -210,7 +238,17 @@ func (cfg *Config) workerWithBuildPlatform(sOpt dalec.SourceOpts, buildPlat ocis
     		dalec.WithMountedAptCache(cacheKey),
     	)
     
    -	return es.GetMount(rootfsMount).Platform(targetPlat)
    +	worker := es.GetMount(rootfsMount).Platform(targetPlat)
    +	if script := cfg.workerCADistrustScript(); script != "" {

    >I'm not sure I follow what you mean by checking the condition only once?

    I mean so that workerCADistrustScript or equivalent is called unconditionally, once, so it becomes part of the composition with internal logic, rather than a conditional path.

    cpuguy83 cpuguy83 commented on code on Oct 27, 2026 18:17 UTC
    Code Review
    targets/linux/deb/distro/worker.go:1
    @@ -210,7 +238,17 @@ func (cfg *Config) workerWithBuildPlatform(sOpt dalec.SourceOpts, buildPlat ocis
     		dalec.WithMountedAptCache(cacheKey),
     	)
     
    -	return es.GetMount(rootfsMount).Platform(targetPlat)
    +	worker := es.GetMount(rootfsMount).Platform(targetPlat)
    +	if script := cfg.workerCADistrustScript(); script != "" {

    I realized we didn't need this chroot nonsense for the CA stuff. So simplified this up a bit.

    invidian invidian commented on code on Oct 27, 2026 18:27 UTC
    Code Review
    targets/linux/deb/distro/worker.go:1
    @@ -147,7 +166,7 @@ func (cfg *Config) Worker(sOpt dalec.SourceOpts, opts ...llb.ConstraintsOpt) llb
     // buildPlat represents the native executor platform where build-time tools
     // (e.g. apt, dpkg) are run, enabling cross-platform worker builds when it differs
     // from the target platform.
    -func (cfg *Config) workerWithBuildPlatform(sOpt dalec.SourceOpts, buildPlat ocispecs.Platform, opts ...llb.ConstraintsOpt) llb.State {
    +func (cfg *Config) workerWithBuildPlatform(sOpt dalec.SourceOpts, buildPlat ocispecs.Platform, opts ...llb.ConstraintsOpt) (retState llb.State) {

    named return and defer to mutate the return at the end, that's fairly complex and annoying to read. Perhaps workerWithBuildPlatform content should be moved to separate function and workerWithBuildPlatform should become a compound of both instead (if not moving the call to Worker()`?

    cpuguy83 cpuguy83 commented on code on Oct 27, 2026 19:17 UTC
    Code Review
    targets/linux/deb/distro/worker.go:1
    @@ -147,7 +166,7 @@ func (cfg *Config) Worker(sOpt dalec.SourceOpts, opts ...llb.ConstraintsOpt) llb
     // buildPlat represents the native executor platform where build-time tools
     // (e.g. apt, dpkg) are run, enabling cross-platform worker builds when it differs
     // from the target platform.
    -func (cfg *Config) workerWithBuildPlatform(sOpt dalec.SourceOpts, buildPlat ocispecs.Platform, opts ...llb.ConstraintsOpt) llb.State {
    +func (cfg *Config) workerWithBuildPlatform(sOpt dalec.SourceOpts, buildPlat ocispecs.Platform, opts ...llb.ConstraintsOpt) (retState llb.State) {

    Ok, I extracted the main build logic out into a separate function.
    Right now this is called in 3 places: Worker, SysextWorker, and HandleWorker.

    invidian invidian approved these changes on Oct 27, 2026 19:22 UTC
    Approved Reviewer

    LGTM, thanks for addressing comments!

    Reviewers
    Assignees
    cpuguy83 cpuguy83
    Labels
    risk: low confidence: 88.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 34.8% (LOW) · Higher = larger blast radius
    34.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 88.7% · Lower = rushed or shallow review
    88.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 3.9% · Safe to merge
    3.9%