The unrestricted external call capability in the MembershipERC1155 contract poses a critical security vulnerability that could lead to complete compromise of token security and financial assets. Since the contract manages membership tokens and profit distribution, a malicious actor with OWP_FACTORY_ROLE could exploit this to drain funds, manipulate token balances, or execute unauthorized operations through carefully crafted external calls. The lack of contract and function whitelisting means any contract address and any function signature can be called, effectively bypassing the carefully designed access controls and financial safeguards present in the rest of the contract.
The issue stems from the callExternalContract function implementing a generic delegatecall pattern without proper boundaries on what can be executed. While the function is protected by OWP_FACTORY_ROLE, this single authorization check is insufficient given the broad capabilities granted. The implementation allows for arbitrary execution of any function on any external contract, opening attack vectors where a malicious actor could potentially:
Execute malicious code that reenters the contract during profit distribution
Call sensitive functions on connected protocol contracts
Upgrade proxy implementations if connected to upgradeable contracts
Manipulate token balances through unauthorized minting or burning
Drain accumulated profits before legitimate distribution
The vulnerability is particularly severe because the contract handles financial assets and membership governance, where any compromise could affect both asset security and organizational control.
Consider a scenario where the contract is part of a DAO's membership system. A malicious actor who gains OWP_FACTORY_ROLE could craft a call to an external contract that they control. This contract could then execute a series of actions like:
Call back into profit distribution functions multiple times through reentrancy
Execute state changes during an ongoing profit distribution
Manipulate token balances during critical operations
Call sensitive admin functions on connected protocol contracts
The attack becomes possible because the current implementation places no restrictions on which contracts can be called or which functions can be executed, making the OWP_FACTORY_ROLE effectively equivalent to complete admin control over the entire system.
This implementation adds several critical security improvements:
Contract whitelist management with admin-only control
Function signature whitelist for approved contracts
Reentrancy protection using nonReentrant modifier
Proper validation of contract addresses
Events for tracking whitelist changes and maintaining transparency
Granular control over which functions can be called on which contracts
The whitelisting system allows the DAO to explicitly define which contracts and functions are allowed, significantly reducing the attack surface while maintaining necessary functionality. Consider also implementing:
Timelock for whitelist changes
Multi-signature requirements for whitelist modifications
Additional validation of function parameters
Maximum value limits for payable calls
Emergency pause mechanism for external calls
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.