The governance will fail to add an ecosystem token if someone creates a hToken that uses that ecosystem token
Anyone can create a local token whose underlying asset is an ecosystem token before governance adds it, causing the mapping to be set. When governance later calls addEcosystemToken, the transaction reverts because the check sees a non-zero address, preventing the ecosystem token from being added.
Submitted by Arz
Ecosystem tokens are tokens that don’t have an underlying token address in any branch and only the global representation exists. The governance adds them by calling addEcosystemToken() where the _ecoTokenGlobalAddress will be the Maia or Hermes token, as the sponsor mentioned, or any other tokens that could be added in the future.
The problem is that anyone can create a hToken where the underlying asset is the ecosystem token and then this mapping will get updated in setAddresses():
252: getLocalTokenFromUnderlying[_underlyingAddress][_srcChainId] = _localAddress;
The _underlyingAddress equals to the _ecoTokenGlobalAddress and when the admin calls addEcosystemToken(), it will then revert because of this check that is incorrect:
493: if (getLocalTokenFromUnderlying[_ecoTokenGlobalAddress][localChainId] != address(0)) {
494: revert AlreadyAddedEcosystemToken();
495: }
getLocalTokenFromUnderlying[_ecoTokenGlobalAddress] will not be a zero address because it was set when the attacker added the hToken.
The check here is redundant. Even if someone creates a hToken where the underlying asset will be the ecosystem token, it will not be tied to the ecosystem token in any way, as it has a different global address and a different local address.
Impact
The governance will fail to add the ecosystem tokens. They will not work with this part of Ulysses because an attacker can easily create a hToken before the ecosystem token is set.
Proof of Concept
Add this to RootTest.t.sol
function testAddEcosystemTokenAttack() public {
//arbitrumMockToken will be the Maia or Hermes token
hevm.deal(address(this), 1 ether);
//Attacker adds the Maia or Hermes token
arbitrumCoreRouter.addLocalToken{value: 0.0005 ether}(
address(arbitrumMockToken), GasParams(0.5 ether, 0.5 ether)
);
newArbitrumAssetGlobalAddress =
RootPort(rootPort).getLocalTokenFromUnderlying(address(arbitrumMockToken), rootChainId);
require(
RootPort(rootPort).getGlobalTokenFromLocal(address(newArbitrumAssetGlobalAddress), rootChainId)
== address(newArbitrumAssetGlobalAddress),
"Token should be added"
);
require(
RootPort(rootPort).getLocalTokenFromGlobal(newArbitrumAssetGlobalAddress, rootChainId)
== address(newArbitrumAssetGlobalAddress),
"Token should be added"
);
require(
RootPort(rootPort).getUnderlyingTokenFromLocal(address(newArbitrumAssetGlobalAddress), rootChainId)
== address(arbitrumMockToken),
"Token should be added"
);
//The admin will then fail to add an ecosystem token because the tx reverts
rootPort.addEcosystemToken(address(arbitrumMockToken));
}
As you can see here, the tx reverts because of that check and the admin will fail to add the ecosystem token.
Tools Used
Foundry
Recommended Mitigation Steps
Remove this check as it’s redundant, as setting the ecosystem tokens when initializing is not the best solution because other tokens can be added in the future.
if (getLocalTokenFromUnderlying[_ecoTokenGlobalAddress][localChainId] != address(0)) {
revert AlreadyAddedEcosystemToken();
}
Assessed type
DoS
0xBugsy (Maia) disputed and commented:
If the token has not yet been added to the system, a new one can simply be deployed. In addition, this can be done in a multicall paired with the token deployment itself for added security. Removing this check would lead to added governance power / responsibility.
Regardless of the mitigation, which might not be great, the issue is that if an ecosystem token is not set, an attacker can add it as an underlying of some other token. Then, it will not be possible to set it anymore as a global address (because the ecosystem token already is an underlying token).
The attacker would have to act between token deployment and adding it as an ecosystem token. The only way for that to happen would need to come from a governance/setup mistake.
The check cannot be overridden if there is any deposits of that underlying or there would be funds lost. Mitigation could be improved by this, allowing an ecosystem token to override a global token if its total supply is zero. This way, any mistake can be circumvented without any redeployment (if the ecosystem token is not distributed yet) and our setup can be more flexible.
Adding an ecosystem token immediately after creation is not obvious, or in the documentation. This is then a valid DoS attack, which you can mitigate with careful governance.
0xLightt (Maia) confirmed, but disagreed with severity and commented:
Updated review and feedback to reflect our opinion on this issue.
Addressed here.
Note: For full discussion, see here.
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 check in addEcosystemToken incorrectly assumes that if a local token exists for the ecosystem token's global address, the ecosystem token has already been added, but that mapping can be populated by anyone creating a local token with that underlying.
What the attacker needed
Ecosystem token not yet added; attacker can call addLocalToken
The fix
The check should be removed or improved to allow an ecosystem token to override a global token if its total supply is zero, as suggested in the discussion.
How it was found
- Attacker calls addLocalToken on a core router, specifying the ecosystem token as the underlying asset.
- This sets getLocalTokenFromUnderlying for the ecosystem token's address.
- Later, governance calls addEcosystemToken for that token.
- The call reverts because the check finds a non-zero local token address.
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 project has a special kind of token (ecosystem token) that only exists globally, not on each chain. The system lets anyone create a local version of a token by specifying its underlying asset. If someone creates a local token using the ecosystem token as the underlying before the project officially adds the ecosystem token, a record is set. Later, when the project tries to add the ecosystem token, a safety check sees that record and blocks the addition, so the ecosystem token can never be used.
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.