Skip to content

Re-entrancy error swallowed #980

Description

@rackstar

Context

Most of the nonReentrant functions currently swallow all ETH transfer errors (including non-reentrancy) and replace it with a generic error (e.g. "Pool: ETH transfer failed")

This is problematic as we cannot correctly verify if the function indeed reverted with non-reentrancy error or something else. Due to this, the tests will pass if the functions revert for ANY reason (including re-entrancy) which is not ideal

Options

  • upgrade the Pool.sol contract to make sure the re-entrancy error bubbles up
  • use hardhat-tracer or a similar tool that will let us validate if the trace contains the re-entrancy error

Call validation that does NOT swallow errors

this should probably be in a lib so that we can re-use it and make it a pattern when doing a call (internal/external)

      (bool ok, bytes memory result) = target.call(data);

      if (!ok) {

        uint length = result.length;

        // 0 length returned from empty revert() / require(false)
        if (length == 0) {
          revert RevertedWithoutReason();
        }

        assembly {
          revert(add(result, 0x20), length)
        }
      }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    choreMaintenance/refactor; no user-facing change

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions