As the Distribution_init
function in Distribution.sol implementation permits any token without undergoing a legitimacy check, it is possible to introduce a valid token that is not ERC20 compliant, (or an invalid token which can be non compliant as well).
According to Morpheus documentation (https://github.com/MorpheusAIs/Morpheus/blob/main/!KEYDOCS%20README%20FIRST!/2.WhitePaper.md) the expected token for interacting with the contracts is stETH. For example:
“The Morpheus full node comes with a wallet or the user can connect their existing wallet. This enables the user to sign and send transactions recommended by their Smart Agent. So users will be able to participate in the proofs through the Morpheus software. However Capital Providers are not required to have a full node for example. They can interact directly with the Smart Contracts on Ethereum / Arbitrum using stETH”.
The token is expected to be ERC20 compliant, i.e. tokens that must adhere to guidelines outlined by ERC20 to be considered ERC20-compliant.
The functions a token must have are:
TotalSupply: The total number of tokens that will ever be issued
BalanceOf: The account balance of a token owner's account
Transfer: Automatically executes transfers of a specified number of tokens to a specified address for transactions using the token
TransferFrom: Automatically executes transfers of a specified number of tokens from a specified address using the token
Approve: Allows a spender to withdraw a set number of tokens from a specified account, up to a specific amount
Allowance: Returns a set number of tokens from a spender to the owner
The events that must be included in the token are:
Transfer: An event triggered when a transfer is successful
Approval: A log of an approved event (an event)
Distribution_init
function allows to set incorrect data, with invalid pools according to the tests provided below. As mentioned in the documentation this function is only meant to be called with a valid ERC20 token (the stETH) but the function is generic enough to accept non compliant tokens.
As a proof of concept a fake token contract was included into the /tokens folder named FooToken.sol
At a glance, this fake token is not ERC20 compliant, and it is still accepted into the Pool creation:
This fake token can be used in the depositedToken variable and will be included during the Pool creation:
When running the test and the FooToken is injected, we verify that our Fake, non compliant token is accepted into the Distribution_init function when this should be prohibited:
Verifying the ERC20 compliance of the token is essential for validating pool creation. Neglecting this verification could result in the formation of invalid pools, triggering unforeseen issues in various functionalities of the Distribution.sol contract, including the potential for a Denial of Service (DoS) scenario.
Properly managing non-standard ERC20 contracts is essential for their support. A recommended approach is to employ a trusted library like OpenZeppelin’s SafeERC20.
https://solodit.xyz/issues/make-token-erc20-compliant-openzeppelin-unikoingold-token-audit-markdown
https://solodit.xyz/issues/non-standard-erc20-tokens-are-not-supported-and-locked-in-the-contract-sigmaprime-none-sushi-pdf
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.