Skip to content

Cosign Panic When Signing with Yubikey Hardware Token #4748

@Kynson

Description

@Kynson

Description
When trying to sign something (I have tested sign for image and sign-blob) with a Yubikey 5C NFC result in a goroutine panic:

$ cosign sign --sk --slot 'authentication' $IMAGE_DIGEST
panic: interface conversion: interface is nil, not crypto.Signer

goroutine 1 [running]:
github.com/sigstore/cosign/v3/pkg/cosign/pivkey.(*Key).SignMessage(0x140008412d8?, {0x1060e7180?, 0x140006502a0?}, {0x105d13dc0?, 0x1?, 0x14000a7acf0?})
	github.com/sigstore/cosign/v3/pkg/cosign/pivkey/pivkey.go:273 +0x1cc
github.com/sigstore/cosign/v3/internal/key.(*SignerVerifierKeypair).SignData(0x1400038b780, {0x10611dd00, 0x107f45c80}, {0x1400031c480, 0x111, 0x120})
	github.com/sigstore/cosign/v3/internal/key/svkeypair.go:132 +0x1c8
github.com/sigstore/sigstore-go/pkg/sign.Bundle({0x106100420, 0x14000650240}, {0x10612d8f0, 0x1400038b780}, {{0x1060e7d40, 0x14000a7acc0}, 0x0, {0x0, 0x0, 0x0}, ...})
	github.com/sigstore/sigstore-go@v1.1.4/pkg/sign/signer.go:68 +0xd0
github.com/sigstore/cosign/v3/pkg/cosign/bundle.SignData({0x10611dd38, 0x1400063b7a0}, {0x106100420, 0x14000650240}, {0x10612d8f0, 0x1400038b780}, {0x0?, 0x0}, {0x14000a41400?, 0x2a8?, ...}, ...)
	github.com/sigstore/cosign/v3/pkg/cosign/bundle/sign.go:140 +0x930
github.com/sigstore/cosign/v3/cmd/cosign/cli/signcommon.WriteNewBundleWithSigningConfig({_, _}, {0x1, {0x16d6b3488, 0xe}, {0x0, 0x0}, {0x104cb7236, 0x1b}, {0x104cb2bce, ...}, ...}, ...)
	github.com/sigstore/cosign/v3/cmd/cosign/cli/signcommon/common.go:534 +0x1fc
github.com/sigstore/cosign/v3/cmd/cosign/cli/sign.signDigestBundle({_, _}, {{{_, {_, _}}, {_, _}}, {_, _}, {_, ...}}, ...)
	github.com/sigstore/cosign/v3/cmd/cosign/cli/sign/sign.go:200 +0x610
github.com/sigstore/cosign/v3/cmd/cosign/cli/sign.SignCmd.func1({0x10611dd38, 0x1400063b7a0}, {0x10611e2e8, 0x1400063b770})
	github.com/sigstore/cosign/v3/cmd/cosign/cli/sign/sign.go:141 +0x2f8
github.com/sigstore/cosign/v3/pkg/oci/walk.SignedEntity.func1({0x10611dd38?, 0x1400063b7a0?}, {0x10611e2e8, 0x1400063b770})
	github.com/sigstore/cosign/v3/pkg/oci/walk/walk.go:35 +0x34
github.com/sigstore/cosign/v3/pkg/oci/mutate.Map({0x10611dde0, 0x140000f1180}, {0x10611e2e8, 0x1400063b770}, 0x140008428d8)
	github.com/sigstore/cosign/v3/pkg/oci/mutate/map.go:48 +0x6c
github.com/sigstore/cosign/v3/pkg/oci/walk.SignedEntity({0x10611dde0?, 0x140000f1180?}, {0x10611e2e8?, 0x1400063b770?}, 0x1?)
	github.com/sigstore/cosign/v3/pkg/oci/walk/walk.go:34 +0x3c
github.com/sigstore/cosign/v3/cmd/cosign/cli/sign.SignCmd({_, _}, _, {0x1, {0x16d6b3488, 0xe}, {0x0, 0x0}, {0x104cb7236, 0x1b}, ...}, ...)
	github.com/sigstore/cosign/v3/cmd/cosign/cli/sign/sign.go:133 +0x814
github.com/sigstore/cosign/v3/cmd/cosign/cli.Sign.func1(0x140008b3808, {0x14000148600, 0x1, 0x6})
	github.com/sigstore/cosign/v3/cmd/cosign/cli/sign.go:137 +0x2d8
github.com/spf13/cobra.(*Command).execute(0x140008b3808, {0x140001485a0, 0x6, 0x6})
	github.com/spf13/cobra@v1.10.2/command.go:1015 +0x7d4
github.com/spf13/cobra.(*Command).ExecuteC(0x14000690f08)
	github.com/spf13/cobra@v1.10.2/command.go:1148 +0x350
github.com/spf13/cobra.(*Command).Execute(0x104c967db?)
	github.com/spf13/cobra@v1.10.2/command.go:1071 +0x1c
main.main()
	github.com/sigstore/cosign/v3/cmd/cosign/main.go:64 +0x3b8

Key Pair Info: Both Ed25519 and ECCP384 key pair fail.

Note: This key is generated by Yubico Authenticator on device (not imported, cosign piv-tool attestation --slot 'authentication' is successful) as I cannot use cosign piv-tool generate-key due to #3742.

Note 2: I also tried to use pkcs#11, but as described in this discussion. Unfortunately, I have to recompile cosign for this to have a chance to work.

Version
Installed with nix darwin, compiled with pivkey and pkcs11key tags

  ______   ______        _______. __    _______ .__   __.
 /      | /  __  \      /       ||  |  /  _____||  \ |  |
|  ,----'|  |  |  |    |   (----`|  | |  |  __  |   \|  |
|  |     |  |  |  |     \   \    |  | |  | |_ | |  . `  |
|  `----.|  `--'  | .----)   |   |  | |  |__| | |  |\   |
 \______| \______/  |_______/    |__|  \______| |__| \__|
cosign: A tool for Container Signing, Verification and Storage in an OCI registry.

GitVersion:    v3.0.5
GitCommit:     unknown
GitTreeState:  clean
BuildDate:     unknown
GoVersion:     go1.25.7
Compiler:      gc
Platform:      darwin/arm64

YubiKey Firmware Version: 5.7.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions