Skip to content

Commit 7c393af

Browse files
leodidoona-agent
andcommitted
feat(signing): enforce strict OIDC extraction, remove fallback
Remove silent fallback to GITHUB_WORKFLOW_REF when OIDC extraction fails. This prevents creating attestations with incorrect builder IDs that will fail verification. Breaking Change: - Operations now fail fast with clear error when OIDC token extraction fails - No longer falls back to GITHUB_WORKFLOW_REF (which creates broken attestations) - Users must properly configure OIDC environment (id-token: write permission) Benefits: - Prevents wasted CI resources (fails before signing, not at verification) - Clear error messages guide users to fix OIDC configuration - Eliminates security risk of silent degradation to wrong builder ID - Ensures attestations match Fulcio certificate identity Updated tests to reflect new fail-fast behavior. Co-authored-by: Ona <no-reply@ona.com>
1 parent ffb6270 commit 7c393af

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

pkg/leeway/signing/attestation.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ func GenerateSignedSLSAAttestation(ctx context.Context, artifactPath string, git
9595
// This is critical for compatibility with reusable workflows
9696
builderID, err := extractBuilderIDFromOIDC(ctx, githubCtx)
9797
if err != nil {
98-
// Fallback to GITHUB_WORKFLOW_REF if OIDC token extraction fails
99-
// This maintains backward compatibility but may cause verification issues
100-
log.WithError(err).Warn("Failed to extract builder ID from OIDC token, falling back to GITHUB_WORKFLOW_REF")
101-
builderID = fmt.Sprintf("%s/%s", githubCtx.ServerURL, githubCtx.WorkflowRef)
98+
return nil, fmt.Errorf("failed to extract builder ID from OIDC token: %w", err)
10299
}
103100

104101
log.WithFields(log.Fields{

pkg/leeway/signing/attestation_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -599,12 +599,12 @@ func TestGenerateSignedSLSAAttestation_Integration(t *testing.T) {
599599
githubCtx := createMockGitHubContext()
600600

601601
// Test that the function exists and has the right signature
602-
// We expect it to fail due to missing Sigstore environment, but that's expected
602+
// We expect it to fail due to missing OIDC environment (strict mode)
603603
_, err := GenerateSignedSLSAAttestation(context.Background(), artifactPath, githubCtx)
604604

605-
// We expect an error related to Sigstore/signing, not basic validation
605+
// We expect an error related to OIDC extraction (fails fast before signing)
606606
assert.Error(t, err)
607-
assert.Contains(t, err.Error(), "sign", "Error should be related to signing process")
607+
assert.Contains(t, err.Error(), "failed to extract builder ID from OIDC token", "Error should be related to OIDC extraction")
608608
}
609609

610610
// TestSignedAttestationResult_Structure tests the result structure
@@ -1091,10 +1091,10 @@ func TestSignProvenanceWithSigstore_EnvironmentValidation(t *testing.T) {
10911091
artifactPath := createTestArtifact(t, "test content")
10921092
githubCtx := createMockGitHubContext()
10931093

1094-
// This should fail at Sigstore environment validation
1094+
// This should fail at OIDC extraction (strict mode - fails fast)
10951095
_, err := GenerateSignedSLSAAttestation(context.Background(), artifactPath, githubCtx)
10961096
assert.Error(t, err)
1097-
assert.Contains(t, err.Error(), "failed to sign SLSA provenance")
1097+
assert.Contains(t, err.Error(), "failed to extract builder ID from OIDC token")
10981098
}
10991099

11001100
func TestFetchGitHubOIDCToken(t *testing.T) {

0 commit comments

Comments
 (0)