Open code423n4 opened 2 years ago
Given how many upgrades I'm making on this, I figured a comment on my reasoning was in order. In many contests, this would be considered low risk. While unlikely to occur without warning, it is well-documented and so very well might occur at some point in the foreseeable future. With Golom's implementation, the entire functionality of the protocol would break if the gas price were to rise, resulting in a need to relaunch/redeploy. The extreme nature of this disruption offsets the other factors normally considered and is why I consider it to be a medium risk in this contest.
Lines of code
https://github.com/code-423n4/2022-07-golom/blob/main/contracts/core/GolomTrader.sol#L154
Vulnerability details
Impact
L154 in GolomTrader.sol uses
.transfer()
to send ether to other addresses. There are a number of issues with using.transfer()
, as it can fail for a number of reasons (specified in the Proof of Concept).Proof of Concept
payable
function or it implements apayable
function but that function uses more than 2300 gas units.payable
fallback
function or it implements apayable
fallback
function but that function uses more than 2300 gas units..transfer()
creates a hard dependency on 2300 gas units being appropriate now and into the future.Tools Used
Vim
Recommended Remediation Steps
Instead use the
.call()
function to transfer ether and avoid some of the limitations of.transfer()
. This would be accomplished by changingpayEther()
to something like;Gas units can also be passed to the
.call()
function as a variable to accomodate any uses edge cases. Gas could be a mutable state variable that can be set by the contract owner.