fix(verifier): handle missing ACME hist_keys and guest_agent_info gracefully#38
Merged
kingsleydon merged 1 commit intomainfrom Mar 24, 2026
Merged
Conversation
…cefully - Add AcmeInfoSchema for runtime validation of Gateway ACME info responses instead of unsafe `as AcmeInfo` type assertion - Add null check for hist_keys before accessing historicalKeys[0] in verifyCertificateKey to prevent runtime crash - Fall back to legacy stub verifiers when kms_guest_agent_info or gateway_guest_agent_info is missing, even if KMS version >= 0.5.3 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Comment on lines
+43
to
+46
| const useLegacyStubs = | ||
| !supportsOnchainKms(systemInfo.kms_info.version) || | ||
| !systemInfo.kms_guest_agent_info || | ||
| !systemInfo.gateway_guest_agent_info |
There was a problem hiding this comment.
Bug: The code falls back to a stub verifier if gateway_guest_agent_info is missing, unnecessarily skipping verification, as GatewayVerifier can handle this case internally.
Severity: MEDIUM
Suggested Fix
Modify the condition to only fall back to the stub verifier for the PhalaCloudKmsVerifier when kms_guest_agent_info is missing. Allow the GatewayVerifier to proceed even without gateway_guest_agent_info, as it has its own internal fallback logic.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: packages/verifier/src/verifierChain.ts#L43-L46
Potential issue: The code at `verifierChain.ts` introduces a fallback to a stub verifier
when `gateway_guest_agent_info` is missing from the system information. This is an
unnecessary security degradation because the `GatewayVerifier` is capable of handling
this absence by fetching the required information from a Gateway RPC endpoint. By
falling back to the stub verifier, which performs no actual validation and simply
returns a hardcoded success result, the system bypasses a legitimate verification path
that could have otherwise completed successfully.
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AcmeInfoSchemaZod validation for Gateway ACME info API responses, replacing unsafeas AcmeInfotype assertion that causedundefined is not an object (evaluating 'historicalKeys[0]')crasheshist_keysbefore accessinghistoricalKeys[0]inverifyCertificateKey()kms_guest_agent_infoorgateway_guest_agent_infois missing in SystemInfo, even for KMS versions >= 0.5.3, preventingkms_guest_agent_info not availableerrorsTest plan
hist_keysin ACME info return a descriptive error instead of crashingkms_guest_agent_infogracefully degrade to legacy stubs🤖 Generated with Claude Code