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

Use of unchecked low level calls #388

Closed
c4-bot-9 opened this issue Jan 22, 2024 · 4 comments
Closed

Use of unchecked low level calls #388

c4-bot-9 opened this issue Jan 22, 2024 · 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-25 insufficient quality report This report is not of sufficient quality unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@c4-bot-9
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2024-01-decent/blob/main/src/UTBExecutor.sol#L41

Vulnerability details

In the UTBExecutor contract, the execute function performs external calls using the low-level call method, which can be unsafe, especially if return values are not checked:

function execute(
    // ...
) public onlyOwner {
    if (token == address(0)) {
        (success, ) = target.call{value: amount}(payload);
        // ...
    }
    // ...
    if (extraNative > 0) {
        (success, ) = target.call{value: extraNative}(payload);
        // ...
    }
}

Impact

  • The lack of return value checks for the call method means that the contract cannot ascertain whether the external call was successful. This could lead to unhandled failures in execution.

  • The call method can also expose the contract to reentrancy attacks, as it allows the called contract to execute arbitrary code.

  • If the external call fails but the contract does not handle this failure, funds sent with the call may be lost or locked.

Mitigation

To address these risks, consider the following modifications:

  • Always check the return value of the call method to ensure the external call was successful.
     function execute(
         // ... existing parameters ...
     ) public onlyOwner {
         bool success;
         if (token == address(0)) {
             (success, ) = target.call{value: amount}(payload);
             require(success, "External call failed");
         }
         // ...
         if (extraNative > 0) {
             (success, ) = target.call{value: extraNative}(payload);
             require(success, "External call with extraNative failed");
         }
         // ...
     }
  • Implement a reentrancy guard to prevent reentrancy attacks.
     bool private locked;

     modifier nonReentrant() {
         require(!locked, "ReentrancyGuard: reentrant call");
         locked = true;
         _;
         locked = false;
     }

     function execute( ... ) public payable onlyOwner nonReentrant {
         // ...
     }
  • Instead of using the low-level call, consider using higher-level abstractions provided by Solidity (like transfer or send for Ether transfers, or directly calling known functions on the target contract).

Assessed type

call/delegatecall

@c4-bot-9 c4-bot-9 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 Jan 22, 2024
c4-bot-1 added a commit that referenced this issue Jan 22, 2024
@c4-pre-sort c4-pre-sort added the insufficient quality report This report is not of sufficient quality label Jan 24, 2024
@c4-pre-sort
Copy link

raymondfam marked the issue as insufficient quality report

@c4-pre-sort
Copy link

raymondfam marked the issue as duplicate of #25

@raymondfam
Copy link

Non-specific addressing of the unchecked return impact.

@c4-judge
Copy link

c4-judge commented Feb 2, 2024

alex-ppg marked the issue as unsatisfactory:
Invalid

@c4-judge c4-judge added the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Feb 2, 2024
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-25 insufficient quality report This report is not of sufficient quality unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

4 participants