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.
Submitted by oakcobalt
Proof of Concept
Based on Canto doc, NOTE address may be modified and redeployed:
The
NOTEsmart contract may be modified and redeployed at a new address in the future. For this reason, DApps should use theCToken.underlying()view on thecNOTEcontract to determine the address forNOTEinstead 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;
}
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;
}
...
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
NOTEaddress 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
NOTEaddress. Canto can do it prior to redeploying theNOTEtoken to streamline the process.
The doc is clear about this,
cNOTEaddress 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.
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.