Skip to content
Business logic Audit finding Intermediate

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.

Rhaydden Follow

Originally disclosed on Immunefi

Informational View original
  • 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

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:

  1. An HttpApplication instance is created for notification.

  2. A Backend enum instance (representing the key storage backend) is created.

  3. A SignerBackend enum instance (used to retrieve the public key) is created. This creation happens before the actual key rotation. The SignerBackend is initialized with the canonical_string which 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)),
    };
    
  4. A KeyManager is created, which is responsible for performing the key rotation using the Backend.

  5. The key_manager.rotate_key() function is called. This function interacts with either AWS KMS or HashiCorp Vault to rotate the key associated with the canonical_string.

    Rust
    key_manager
        .rotate_key(&canonical_string)
        .await
        .context("Failed to rotate the key")?;
    
  6. The public_key() method is called on the signer instance 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")?;
    
  7. The application.notify_public_key() function is called with the public_key obtained 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

https://github.com/immunefi-team/attackathon-movement//blob/a2790c6ac17b7cf02a69aea172c2b38d2be8ce00/util/signing/signing-admin/src/cli/rotate\\_key.rs#L37-L106

Proof of Concept

  1. Set up the signing-admin with either AWS KMS or HashiCorp Vault backend
  2. Configure an application to receive public key updates
  3. Run the key rotation command:
Rust
signing-admin rotate-key --canonical-string "my-key" --application-url "http://my-app/api" --backend "aws"
  1. Verify that the application receives a public key
  2. Inspect the AWS KMS or Vault to confirm that key rotation has occurred
  3. Compare the public key sent to the application with the current public key in the backend
  4. 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.

The original report as published on Immunefi, by Rhaydden. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

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

  1. Set up signing-admin with an AWS KMS or HashiCorp Vault backend
  2. Configure an application to receive public key updates
  3. Run the key rotation command for a given key
  4. Confirm the application received a public key and that rotation happened in the backend
  5. 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.

More by Rhaydden

View all

36 more disclosed reports, best first.

More from Movement Labs

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.