Skip to content
Business logic Audit finding Intermediate

contract with only `IOptimismMintableERC20` interface is not compatible with `StandardBridge`

A token contract that implements only the IOptimismMintableERC20 interface, but not the legacy ILegacyMintableERC20 interface, is incorrectly identified as compatible by the StandardBridge's check. When the bridge then calls the legacy l1Token function, the call fails, making the token incompatible with the bridge.

Barichek Follow with lemonmon

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-01-optimism-judging/issues/220

Found by

Barichek, lemonmon

Summary

If a custom contract implements only the IOptimismMintableERC20, but no the ILegacyMintableERC20, the contract is not compatible with the StandardBridge, as the bridge uses the l1Token function from the legacy interface

Vulnerability Detail

The comment in the IOptimismMintableERC20 suggests that one can make a custom implementation of OptimismMintableERC20 using the interface IOptimismMintableERC20.

https://github.com/sherlock-audit/2023-01-optimism/blob/main/optimism/packages/contracts-bedrock/contracts/universal/IOptimismMintableERC20.sol#L8-L10

Also, the StandardBridge, which uses the OptimismMintableERC20 has _isOptimismMintableERC20 function, which checks whether the given token address is implementing OptimismMintableERC20. The function will be true if either of ILegacyMintableERC20 or IOptimismMintableERC20 is implemented. it means that if a token implements only one of the interfaces, it will return true.

https://github.com/sherlock-audit/2023-01-optimism/blob/main/optimism/packages/contracts-bedrock/contracts/universal/StandardBridge.sol#L446-L450

However, if the given token passes the _isOptimismMintableERC20, the legacy function l1Token will be called on the token. If the token does not implement the legacy interface, the call will fail.

https://github.com/sherlock-audit/2023-01-optimism/blob/main/optimism/packages/contracts-bedrock/contracts/L2/L2StandardBridge.sol#L170

Therefore, the token which only implements IOptimismMintableERC20, but not the ILegacyMintableERC20, is not compatible with StandardBridge.

Impact

Any custom contract without l1Token function will not be compatible with StandardBridge

Code Snippet

https://github.com/sherlock-audit/2023-01-optimism/blob/main/optimism/packages/contracts-bedrock/contracts/universal/IOptimismMintableERC20.sol#L8-L10

https://github.com/sherlock-audit/2023-01-optimism/blob/main/optimism/packages/contracts-bedrock/contracts/universal/StandardBridge.sol#L446-L450

https://github.com/sherlock-audit/2023-01-optimism/blob/main/optimism/packages/contracts-bedrock/contracts/L2/L2StandardBridge.sol#L170

Tool used

Manual Review

Recommendation

It is unclear it is intended behavior. If the _isOptimismMintableERC20 function returns true only when the both of interfaces are implemented, the token with only the IOptimismMintableERC20 will be treated as if they are not the optimism mintable function, without failing.

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

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 compatibility check accepts tokens implementing either interface, but the bridge unconditionally calls a function from the legacy interface, causing a failure for tokens that only implement the new interface.

Impact

Any custom token contract without the l1Token function will not be compatible with StandardBridge, potentially causing failed transactions.

What the attacker needed

Token implements only IOptimismMintableERC20

The fix

The _isOptimismMintableERC20 function should return true only when both interfaces are implemented, so that tokens with only IOptimismMintableERC20 are treated as not mintable without failing.

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 bridge contract checks if a token is a special 'mintable' token by looking for certain functions. The check passes if the token has either of two sets of functions, but later the bridge always calls a function from the older set. If a token only has the newer set, the call fails and the token cannot be used with the bridge.

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 from Optimism Update

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.