google / google/go-tpm-tools

client.EndorsementKeyRSA could panic

Open
#698 4 comments 0 reactions 2 assignees Claimed by @jessieqliu View on GitHub
Dominant language
C
Stars
309
Forks
118
Avg merge
1d 16h
Merged PRs (30d)
33

Description

We have encountered a case where [EndorsementKeyRSA](https://github.com/google/go-tpm-tools/blob/c9fbf6f92c713424062c8defcbe0304d0f94f0e4/client/keys.go#L35) panics with following stack trace

time="2026-03-09T10:11:16+01:00" level=debug msg="Panic: interface conversion: interface is nil, not crypto.PublicKey"
time="2026-03-09T10:11:16+01:00" level=debug msg="Panic Stack Trace: goroutine 138 [running]: runtime/debug.Stack() \tC:/Program Files/go/src/runtime/debug/stack.go:26 +0x5e microsoft.com/azure/hybridagent/src/utils.StackDumpAfterPanic() \tC:/__w/1/s/src/utils/stackdump.go:20 +0x3a panic({0x11731c0?, 0xc00039a060?}) \tC:/Program Files/go/src/runtime/panic.go:791 +0x132 github.com/google/go-tpm-tools/client.(*Key).SetCert(0xc0003a7000?, 0x38c?) \tC:/Users/ContainerAdministrator/go/pkg/mod/github.com/google/go-tpm-tools@v0.4.5/client/keys.go:502 +0x13b github.com/google/go-tpm-tools/client.(*Key).trySetCertificateFromNvram(0xc0003e2120, 0x466a60?) \tC:/Users/ContainerAdministrator/go/pkg/mod/github.com/google/go-tpm-tools@v0.4.5/client/keys.go:526 +0x91 github.com/google/go-tpm-tools/client.EndorsementKeyRSA({0x152e1be6940, 0xc00004e660})

Type assertion fails when certificate.PublicKey is nil. However I am not sure why it would be nil after x509 certificate being successfully parsed

@jessieqliu This [PR](https://github.com/google/go-tpm-tools/pull/167/changes/14394bf50969f76b5e8d5ca720740cec092763e8) is related.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.