Skip to content
DoS Audit finding Intermediate

asdRouter.sol is at risk of DOS due to vulnerable implementation of NOTE address

The router contract stored the NOTE token address once at deployment instead of reading it dynamically from the cNOTE contract, so it effectively hardcoded the address. If NOTE is redeployed at a new address, the swap and cross-chain compose functions would break, causing a denial of service.

oakcobalt Follow

Originally disclosed on Code4rena

Submitted by oakcobalt

Proof of Concept

Based on Canto doc, NOTE address may be modified and redeployed:

The NOTE smart contract may be modified and redeployed at a new address in the future. For this reason, DApps should use the CToken.underlying() view on the cNOTE contract to determine the address for NOTE instead of hardcoding it.

As stated in doc, Dapp should use CToken.underlying() to ensure that NOTE address used is always correct.

The problem is current implementation in asdRouter.sol will only initiate noteAddress at contract deployment. noteAddress can not be changed afterward and the effect is the same as hardcoding an address.

//contracts/asd/asdRouter.sol
    constructor(address _noteAddress, uint32 _cantoLzEID, address _crocSwapAddress, address _crocImpactAddress, address _asdUSDCAddress) {
        //@audit No method to change noteAddress after deployment.
|>      noteAddress = _noteAddress;
        cantoLzEID = _cantoLzEID;
        crocSwapAddress = _crocSwapAddress;
        crocImpactAddress = _crocImpactAddress;
        asdUSDC = _asdUSDCAddress;
    }

https://github.com/code-423n4/2024-03-canto/blob/52dd3d7083ca9bed0484180f4a5f3af84a10a9bc/contracts/asd/asdRouter.sol#L45

Note: When performing swap from asdUSDC to NOTE, noteAddress will be used instead of CToken.underlying(). This means when NOTE address changes, swap and lzcompose will be DOSed.

//contracts/asd/asdRouter.sol
    function _swapOFTForNote(address _oftAddress, uint _amount, uint _minAmountNote) internal returns (uint, bool) {
...
        if (_oftAddress < noteAddress) {
            baseToken = _oftAddress;
|>          quoteToken = noteAddress;
        } else {
|>          baseToken = noteAddress;
            quoteToken = _oftAddress;
        }
...

https://github.com/code-423n4/2024-03-canto/blob/52dd3d7083ca9bed0484180f4a5f3af84a10a9bc/contracts/asd/asdRouter.sol#L214-L218

For comparison, asdOFT.sol has the correct NOTE address implementation where cNoteToken.underlying() is used.

Recommended Mitigation Steps

Change to store cNote address and only use CNote.underlying().

dsudit01 (Canto) confirmed and commented:

PR here.

SpicyMeatball (warden) commented:

@3docSec - I think QA is more appropriate:

  • The probability is low, changing the NOTE address is a rare event which may never occur.
  • The impact is medium at best, a temporary DOS which can be mitigated by redeploying the router with a new NOTE address. Canto can do it prior to redeploying the NOTE token to streamline the process.

3docSec (judge) commented:

The doc is clear about this, cNOTE address changes are a design choice in the ecosystem, and that’s a fact. That the event is rare and may never happen is subjective.

As per the second point, the SC helped clear out that the possibility of deploying a new version of the contract should not be reason for mitigating severity of a finding.


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

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

Likely the router cached the NOTE address in its constructor rather than querying the cNOTE contract's underlying() view each time, so it cannot follow a redeployment.

Impact

If NOTE is redeployed, swap and lzcompose calls would be denied service; the report notes this is a rare event and could be mitigated by redeploying the router.

What the attacker needed

NOTE token is redeployed at a new address

The fix

The router should store the cNOTE address and read the NOTE address through CNote.underlying() instead of caching it; the text links a pull request but does not state it was merged.

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 smart contract can store another contract's address when it is first deployed. If that other contract later moves to a new address, the stored one points at nothing useful. Here the router kept the old address, so swaps involving that token would stop working until the router itself was redeployed.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by oakcobalt

View all

50 more disclosed reports, best first.

More from Canto

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.