Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

operate() does not check illegal revenueContract #285

Closed
code423n4 opened this issue Nov 10, 2022 · 4 comments
Closed

operate() does not check illegal revenueContract #285

code423n4 opened this issue Nov 10, 2022 · 4 comments
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate-312 satisfactory Finding meets requirement

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/debtdao/Line-of-Credit/blob/e8aa08b44f6132a5ed901f8daa231700c5afeb3a/contracts/utils/SpigotLib.sol#L61

Vulnerability details

Impact

SpigotLib#operate() has check if the method signature in data is in the whitelist, but not check revenueContract is in settings[].
There is a certain risk that the signatures are the same, and operator can pass revenueContract=claimedToken, which is used to manipulate the claimedToken

Proof of Concept

    function operate(SpigotState storage self, address revenueContract, bytes calldata data) external returns (bool) {
        if(msg.sender != self.operator) { revert CallerAccessDenied(); }
        
        // extract function signature from tx data and check whitelist
        bytes4 func = bytes4(data);

        if(!self.whitelistedFunctions[func]) { revert BadFunction(); }
        
        if(
          func == self.settings[revenueContract].claimFunction ||
          func == self.settings[revenueContract].transferOwnerFunction
        ) { revert BadFunction(); }

        //****@audit don't check revenueContract legal? ****//


        (bool success,) = revenueContract.call(data);
        if(!success) { revert BadFunction(); }

        return true;
    }

Tools Used

Recommended Mitigation Steps

    function operate(SpigotState storage self, address revenueContract, bytes calldata data) external returns (bool) {
        if(msg.sender != self.operator) { revert CallerAccessDenied(); }
        
        // extract function signature from tx data and check whitelist
        bytes4 func = bytes4(data);

        if(!self.whitelistedFunctions[func]) { revert BadFunction(); }
        
+       require(self.settings[revenueContract].transferOwnerFunction != bytes4(0),"invald revenueContract");

    }
@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Nov 10, 2022
code423n4 added a commit that referenced this issue Nov 10, 2022
@c4-judge
Copy link
Contributor

dmvt marked the issue as duplicate of #71

@c4-judge
Copy link
Contributor

c4-judge commented Dec 6, 2022

dmvt marked the issue as satisfactory

@c4-judge c4-judge added the satisfactory Finding meets requirement label Dec 6, 2022
@C4-Staff C4-Staff reopened this Dec 20, 2022
@C4-Staff
Copy link
Contributor

liveactionllama marked the issue as not a duplicate

@C4-Staff
Copy link
Contributor

liveactionllama marked the issue as duplicate of #312

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate-312 satisfactory Finding meets requirement
Projects
None yet
Development

No branches or pull requests

3 participants