Closed c4-bot-2 closed 7 months ago
Seems invalid. Asset must be registered first which only admin can do. Leaving for sponsor review though.
0xRobocop marked the issue as primary issue
0xRobocop marked the issue as sufficient quality report
No issue at all. That's how substrate works with public functions.
Why would you bother with adding an asset - if you can call Balances::transfer, which is also public function.
enthusiastmartin (sponsor) disputed
See #131
OpenCoreCH marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2024-02-hydradx/blob/main/HydraDX-node/pallets/omnipool/src/lib.rs#L1965-L1972
Vulnerability details
Impact
In the
omnipool/src/lib.rs
, theadd_asset()
function is a public function defined in a Pallet implementation. Since this function is clearly marked public, it can be called outside the pallet. Hence any user or smart contract within the runtime can make a call toadd_asset()
and update the state of any omnipool contract by adding a new asset with assetState before an authorized user does.The function adds new asset to list of Omnipool assets. Once added, the
add_token()
cannot be called by the AuthorizedOrigin since the asset is already added on the list. The function also sets an AssetState for the asset, thus allowing any user to set any arbitruary value as the state for asset, e.g setting the shares value to a high amount.Proof of Concept
https://github.com/code-423n4/2024-02-hydradx/blob/main/HydraDX-node/pallets/omnipool/src/lib.rs#L1965-L1972
Test PoC
Tools Used
Manual review
Recommended Mitigation Steps
Add an access control check to ensure the function can only be called by authorized accounts.
Assessed type
Access Control