From 89e14b0d85a6fbbe36d983926521fdd162a55993 Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Tue, 13 Jan 2026 13:39:43 +0100 Subject: [PATCH] buildx(install): workaround to check subjectAlternativeName Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- src/buildx/install.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/buildx/install.ts b/src/buildx/install.ts index 644feae..29f15b7 100644 --- a/src/buildx/install.ts +++ b/src/buildx/install.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import {X509Certificate} from 'crypto'; import fs from 'fs'; import os from 'os'; import path from 'path'; @@ -245,10 +246,14 @@ export class Install { try { core.info(`Verifying Buildx binary signature`); const signedEntity = toSignedEntity(bundle, fs.readFileSync(binPath)); + const signingCert = new X509Certificate(signedEntity.signature.signature); + if (!signingCert.subjectAltName?.match(/^https:\/\/github\.com\/docker\/(github-builder-experimental|github-builder)\/\.github\/workflows\/bake\.yml.*$/)) { + throw new Error(`Signing certificate subjectAlternativeName "${signingCert.subjectAltName}" does not match expected pattern`); + } const verifier = new Verifier(trustMaterial); const signer = verifier.verify(signedEntity, { // FIXME: uncomment when subjectAlternativeName check with regex is supported: https://github.com/docker/actions-toolkit/pull/929#discussion_r2682150413 - //subjectAlternativeName: /^https:\/\/github\.com\/docker\/(github-builder-experimental|github-builder)\/\.github\/workflows\/build\.yml.*$/, + //subjectAlternativeName: /^https:\/\/github\.com\/docker\/(github-builder-experimental|github-builder)\/\.github\/workflows\/bake\.yml.*$/, extensions: {issuer: 'https://token.actions.githubusercontent.com'} }); core.debug(`Install.verifySignature signer: ${JSON.stringify(signer)}`);