Higher Order

Become the owner of a contract that uses delegatecall to interact with a library or logic contract.

Vulnerable Code
Analyze the Solidity code below to find the vulnerability.
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // Assume LibraryContract contains the logic, including setOwner interface ILibraryContract { function setOwner(address _owner) external; // Other functions... } contract HigherOrderContract { address public owner; address public libraryAddress; // Address of the logic/library contract constructor(address _library) { libraryAddress = _library; } // Fallback function uses delegatecall fallback() external payable { (bool success, ) = libraryAddress.delegatecall(msg.data); require(success, "Delegatecall failed"); } function setOwner(address _newOwner) public { // This function likely doesn't exist directly on HigherOrderContract // It must be called via the fallback -> delegatecall -> libraryAddress.setOwner revert("Function not implemented directly"); } }
Submit Explanation
Explain the vulnerability and how to exploit it.
Hints (4)
Just a little peak
Hint 1
Hint 2
Hint 3
Hint 4
Explanation
Discomfort = Learning