Skip to content
Access control Disclosed report Advanced

Unauthorized coins transfer from locking account(s)

The locking account's SendCoins function trusts the sender field from the message instead of the authenticated context, so an attacker can transfer funds from a victim's locking account once the lock period ends. The proof of concept shows this for the periodic-locking-account, and the same flaw likely affects other locking account types.

unknown_feature Follow

Originally disclosed on HackerOne

Critical View original
  • Disclosed after 5 months

Summary of Impact

An attacker can transfer money from the locking account they don't own(if the account has unlocked funds, can be after locking period is over). The POC is done for periodic-locking-account. But it seems like more locking accounts are affected because the issue seems to be in SendCoins. And it's used by all of them. When it calls the function it passes sender from the message msg.Sender in checkSender it checks that the sender == owner. But the issue here is that msg.Sender is not validated anywhere bc this message is packed into MsgExecute. While executing it sets original sender into the context . And in case of multisig account it correctly takes it from ctx . At least in those places I looked at. But these locking accounts take it from the message. And it can be anything.

POC scenario

  1. We first create a periodic-locking-account at the victim . Locking period is small so we wouldn't wait long.
  2. Then we wait for locking period to end and transfer money to the attacker

Steps to Reproduce

Go and Rust required

  1. Checkout latest version of cosmos-sdk and run make build. Note the path to binariy and when it's done replace the path in setup_chain.

  2. Create rust project with attached Cargo.toml. Download all attached *.rs files and put them into src folder.

  3. Make sure setup_chain has execute permission. Run ./setup_chain. Wait for it to start. And then run the rust project. See the POC video.

Workarounds

Doesn't seem like there are any

Supporting Material/References

  1. setup_chain - script that sets up and starts the chain
  2. main.rs, types.rs, client.rs, func.rs, msg.rs and Cargo.toml the attack itself. Sorry there are a lot of files. I'll probably push it all somewhere and update the report.
  3. attack.mov - the video of POC

Impact

An attacker can take over someone's funds that were locked and then unlocked on the locking account. The POC particularly demonstrates periodic-locking-account. But there are reasons to believe more locking accounts are affected.

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

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 locking account reads the sender from the user-supplied message field instead of the authenticated execution context, so the ownership check can be bypassed.

Impact

An attacker could take funds that were locked and then unlocked on a victim's locking account; the proof of concept shows this for the periodic-locking-account, and other locking accounts may be affected.

What the attacker needed

Victim has a locking account with unlocked funds; attacker can submit a message to the chain

How it was found

  1. Build the cosmos-sdk and note the binary path, then update the setup_chain script with that path.
  2. Create a Rust project with the provided Cargo.toml and source files.
  3. Run the setup_chain script to start the chain.
  4. Run the Rust project to execute the attack.

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 locking account is a special wallet that holds coins until a set time. When someone asks it to send coins, the code checks a 'sender' name that the requester supplies, rather than checking who actually signed the request. So anyone can pretend to be the owner and move the coins out after the lock expires.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by unknown_feature

View all

2 more disclosed reports, best first.

More from Cosmos

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.