Platform: Code4rena
Start Date: 03/11/2022
Pot Size: $115,500 USDC
Total HM: 17
Participants: 120
Period: 7 days
Judge: LSDan
Total Solo HM: 1
Id: 174
League: ETH
Rank: 95/120
Findings: 1
Award: $61.35
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0xNazgul, 0xRoxas, 0xSmartContract, Awesome, Aymen0909, B2, BClabs, Bnke0x0, Deekshith99, Deivitto, Diana, Dinesh11G, Funen, HE1M, HardlyCodeMan, Josiah, Nyx, Rahoz, RaymondFam, RedOneN, ReyAdmirado, Rolezn, Saintcode_, TomJ, Trust, __141345__, a12jmx, adriro, ajtra, aphak5010, apostle0x01, brgltd, btk, bulej93, c3phas, carlitox477, catwhiskeys, ch0bu, chaduke, chrisdior4, cryptonue, cryptostellar5, csanuragjain, ctf_sec, delfin454000, djxploit, durianSausage, erictee, fatherOfBlocks, gogo, i_got_hacked, immeas, joestakey, jumpdest7d, lukris02, martin, mcwildy, merlin, minhquanym, oyc_109, pashov, peanuts, pedr02b2, rbserver, rotcivegaf, rvierdiiev, sakman, saneryee, seyni, shark, slowmoses, tnevler, trustindistrust, w0Lfrum, yurahod, zaskoh
61.3462 USDC - $61.35
payable(receiver).transfer(amount);
transfer() uses a fixed amount of gas, which can result in revert. https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/
Use call instead of transfer(). Example: (bool succeeded, ) = _to.call{value: _amount}(""); require(succeeded, "Transfer failed.");
In LineOfCredit constructor.sol, we should verify if the oracle, arbiter and borrower address are set to address(0)
constructor( address oracle_, address arbiter_, address borrower_, uint256 ttl_ ) { oracle = IOracle(oracle_); arbiter = arbiter_; borrower = borrower_; deadline = block.timestamp + ttl_; //the deadline is the term/maturity/expiry date of the Line of Credit facility interestRate = new InterestRateCredit(); emit DeployLine(oracle_, arbiter_, borrower_); }
In Escrow.sol contract, we should verify if the address oracle, line and borrower are set to address(0)
constructor( uint32 _minimumCollateralRatio, address _oracle, address _line, address _borrower ) { minimumCollateralRatio = _minimumCollateralRatio; oracle = _oracle; borrower = _borrower; state.line = _line; }
In SpigotedLineLib.sol, it is not safe to call approve directly
IERC20(sellToken).approve(swapTarget, amount);
Some tokens (e.g. USDT, KNC) do not allow approving an amount M > 0 when an existing amount N > 0 is already approved.
We recommend the project use Openzepplein SafeApprove library to avoid this issue. We also recommend the project consider use safeIncreaseAllowance to avoid the approve race condition.
the function counts() in LineOfCredit returns amount of active ids and the total ids in list
/** * @notice - getter for amount of active ids + total ids in list * @return - (uint, uint) - active credit lines, total length */ function counts() external view returns (uint256, uint256);
the implementation is
/// see ILineOfCredit.counts function counts() external view returns (uint256, uint256) { return (count, ids.length); }
However, the naming can be better to indicate the returned value is amount of active ids + total ids in list,
we recommend the project change the name to
function creditLineInfo() external view returns (uint256, uint256) { return (numberOfActiveCreditLine, creditLineArray.length); }
require(amount > 0);
require(msg.sender == ILineOfCredit(self.line).arbiter());
require(amount > 0);
require(amount > 0);
require(msg.sender == self.line);
require(revenueContract != address(this));
require(self.settings[revenueContract].transferOwnerFunction == bytes4(0));
require(success);
require(newOwner != address(0));
require(newOperator != address(0));
require(newTreasury != address(0));
require(ISpigot(spigot).updateOwner(newLine));
Descriptive reason strings should be used so that users can troubleshot any reverted calls
pragma solidity ^0.8.9;
pragma solidity ^0.8.9;
pragma solidity ^0.8.9;
Avoid floating pragmas for non-library contracts.
While floating pragmas make sense for libraries to allow them to be included with multiple different versions of applications, it may be a security risk for application implementations.
A known vulnerable compiler version may accidentally be selected or security tools might fall-back to an older compiler version ending up checking a different EVM compilation that is ultimately deployed on the blockchain.
It is recommended to pin to a concrete compiler version.
#0 - c4-judge
2022-12-06T22:54:24Z
dmvt marked the issue as grade-b