Incorrect public key notification after key rotation
The signing-admin CLI tool fetched the public key from a signer object created before the key rotation took place, so after rotating a key in AWS KMS or HashiCorp Vault it notified the application with the old public key. Applications that verify signatures with the notified key would then fail verification for signatures made by the new key.
- Disclosed after under an hour
#43217 [BC-Insight] Incorrect public key notification after key rotation
Submitted on Apr 3rd 2025 at 19:05:25 UTC by @Rhaydden for Attackathon | Movement Labs
- Report ID: #43217
- Report Type: Blockchain/DLT
- Report severity: Insight
- Target: https://github.com/immunefi-team/attackathon-movement/tree/main/util/signing/signing-admin
- Impacts:
- A bug in the respective layer 0/1/2 network code that results in unintended smart contract behavior with no concrete funds at direct risk
Description
Brief/Intro
The signing-admin CLI tool has a flaw in its key rotation. Afterr rotating a signing key in either AWS KMS or HashiCorp Vault, the app is notified with the public key of the old key instead of the newly rotated key. This happens because the key retrieves the public key before the rotation operation has actually taken place from the perspective of the SignerBackend.
Vulnerability Details
In the rotate_key function in rotate_key.rs, the function's execution flow is as follows:
-
An
HttpApplicationinstance is created for notification. -
A
Backendenum instance (representing the key storage backend) is created. -
A
SignerBackendenum instance (used to retrieve the public key) is created. This creation happens before the actual key rotation. TheSignerBackendis initialized with thecanonical_stringwhich identifies the key to be rotated.Rust let signer = match backend_name.as_str() { "vault" => { // ... Vault client creation ... SignerBackend::Vault(HashiCorpVault::<Ed25519>::new( client, canonical_string.clone(), "transit".to_string(), )) } "aws" => { // ... AWS client creation ... SignerBackend::Aws(AwsKms::<Secp256k1>::new( client, canonical_string.clone(), )) } _ => return Err(anyhow::anyhow!("Unsupported signer backend: {}", backend_name)), }; -
A
KeyManageris created, which is responsible for performing the key rotation using theBackend. -
The
key_manager.rotate_key()function is called. This function interacts with either AWS KMS or HashiCorp Vault to rotate the key associated with thecanonical_string.Rust key_manager .rotate_key(&canonical_string) .await .context("Failed to rotate the key")?; -
The
public_key()method is called on thesignerinstance that was created in step 3. Since this instance was created before the rotation, it is still associated with the old key material.Rust let public_key = signer .public_key() .await .context("Failed to fetch the public key from signer")?; -
The
application.notify_public_key()function is called with thepublic_keyobtained in step 6, which is the public key of the old key.Rust key_manager .application .notify_public_key(public_key) .await .context("Failed to notify the application with the public key")?;
As a result, applications will be configured to verify signatures with the wrong key.
Impact Details
Apps relying on the key rotation notification mechanism will receive the incorrect public key. If the application uses the notified public key to verify signatures generated by the new key, the verification will fail because the notified public key corresponds to the old key. In scenarios where the public key is used for authentication purposes, the application will not be able to authenticate entities using the new key.
This falls under the category of "A bug in the respective layer 0/1/2 network code that results in unintended smart contract behavior with no concrete funds at direct risk" since it affects the signature verification without directly exposing funds to theft.
References
Proof of Concept
- Set up the signing-admin with either AWS KMS or HashiCorp Vault backend
- Configure an application to receive public key updates
- Run the key rotation command:
signing-admin rotate-key --canonical-string "my-key" --application-url "http://my-app/api" --backend "aws"
- Verify that the application receives a public key
- Inspect the AWS KMS or Vault to confirm that key rotation has occurred
- Compare the public key sent to the application with the current public key in the backend
- The keys will not match.
Fix
Move the SignerBackend creation code to after the key_manager.rotate_key() call. This ensures that the signer is created with the new key, and applications are notified with the correct public key.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The signer object used to read the public key was created before the rotation was performed, so it still referred to the old key material.
Impact
Applications relying on the notification would receive the wrong public key, so signature verification with the new key would fail and authentication using the new key would not work; no funds are directly at risk.
What the attacker needed
Access to signing-admin CLI; AWS KMS or HashiCorp Vault backend; an application endpoint for notifications
The fix
The signer backend should be created after the rotation call so the new key's public key is fetched and notified.
How it was found
- Set up signing-admin with an AWS KMS or HashiCorp Vault backend
- Configure an application to receive public key updates
- Run the key rotation command for a given key
- Confirm the application received a public key and that rotation happened in the backend
- Compare the notified public key with the current backend public key; they do not match
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A tool rotates a signing key and then tells an application the new public key so it can check signatures. The bug is that it reads the public key before the rotation happens, so it sends the old one. The application then checks signatures against the wrong key and rejects valid ones.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.