Issue | Contexts | |
---|---|---|
LOW‑1 | Consider checking that transfer to address(this) is disabled |
3 |
LOW‑2 | Constant decimal values | 2 |
LOW‑3 | Draft Import Dependencies | 1 |
LOW‑4 | External calls in an un-bounded for- loop may result in a DOS |
4 |
LOW‑5 | Lack of checks-effects-interactions | 3 |
LOW‑6 | Large transfers may not work with some ERC20 tokens |
25 |
LOW‑7 | Possible rounding issue | 6 |
LOW‑8 | Minting tokens to the zero address should be avoided | 1 |
LOW‑9 | Constructor is missing zero address check | 2 |
LOW‑10 | Missing Checks for Address(0x0) | 1 |
LOW‑11 | Contracts are not using their OZ Upgradeable counterparts | 3 |
LOW‑12 | Solidity version 0.8.20 may not work on other chains due to PUSH0 |
9 |
LOW‑13 | TransferOwnership Should Be Two Step | 1 |
LOW‑14 | Unbounded loop | 1 |
LOW‑15 | Use Ownable2Step rather than Ownable |
9 |
LOW‑16 | Use safeTransferOwnership instead of transferOwnership function |
3 |
LOW‑17 | A year is not always 365 days | 1 |
Total: 75 contexts over 17 issues
address(this)
is disabledFunctions allowing users to specify the receiving address should check whether the referenced address is not address(this)
. This would prevent tokens to remain lock inside the contract. An example of the potential for loss by leaving this open is the EOS token smart contract where more than 90,000 tokens are stuck at the contract address.
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Beedle.sol#L22
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Beedle.sol#L29
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Beedle.sol#L36
The use of fixed decimal values such as 1e18 or 1e8 in Solidity contracts can lead to inaccuracies, bugs, and vulnerabilities, particularly when interacting with tokens having different decimal configurations. Not all ERC20 tokens follow the standard 18 decimal places, and assumptions about decimal places can lead to miscalculations.
Resolution: Always retrieve and use the decimals()
function from the token contract itself when performing calculations involving token amounts. This ensures that your contract correctly handles tokens with any number of decimal places, mitigating the risk of numerical errors or under/overflows that could jeopardize contract integrity and user funds.
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Staking.sol#L68
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Staking.sol#L88
Contracts are importing draft dependencies. These imported contracts are still a draft and are not considered ready for mainnet use and have not received adequate security auditing or are liable to change with future development.
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Beedle.sol#L6
Stop using draft imported contracts and use their release version if it exists.
for-
loop may result in a DOSConsider limiting the number of iterations in for-
loops that make external calls
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L293
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L359
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L438
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L549
It's recommended to execute external calls after state changes, to prevent reentrancy bugs.
Consider moving the external calls after the state changes on the following instances.
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L187
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L203
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Staking.sol#L49
ERC20
tokensSome IERC20
implementations (e.g UNI
, COMP
) may fail if the valued transferred is larger than uint96
. Source
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L152
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L159
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L187
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L203
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L267
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L269
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L271
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L663
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L317
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L323
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L642
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L329
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L563
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L565
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L670
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L403
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L505
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L656
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L403
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L505
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L656
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L563
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L329
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L565
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L670
Division by large numbers may result in the result being zero, due to solidity not supporting fractions. Consider requiring a minimum amount for the numerator to ensure that it is always larger than the denominator
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L246
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L618
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L265
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L475
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L561
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L724
The core function mint
is used by users to mint an option position by providing token1 as collateral and borrowing the max amount of liquidity. Address(0)
check is missing in both this function and the internal function _mint
, which is triggered to mint the tokens to the to address. Consider applying a check in the function to ensure tokens aren't minted to the zero address.
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Beedle.sol#L36
In Solidity, constructors often take address parameters to initialize important components of a contract, such as owner or linked contracts. However, without a check, there's a risk that an address parameter could be mistakenly set to the zero address (0x0). This could occur due to a mistake or oversight during contract deployment. A zero address in a crucial role can cause serious issues, as it cannot perform actions like a normal address, and any funds sent to it are irretrievable. Therefore, it's crucial to include a zero address check in constructors to prevent such potential problems. If a zero address is detected, the constructor should revert the transaction.
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Fees.sol#L19
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/utils/Ownable.sol#L14
Lack of zero-address validation on address parameters may lead to transaction reverts, waste gas, require resubmission of transactions and may even force contract redeployments in certain cases within the protocol.
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L100
Consider adding explicit zero-address validation on input parameters of address type.
The non-upgradeable standard version of OpenZeppelin’s library are inherited / used by the contracts.
It would be safer to use the upgradeable versions of the library contracts to avoid unexpected behaviour.
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Beedle.sol#L5-L7
Where applicable, use the contracts from @openzeppelin/contracts-upgradeable
instead of @openzeppelin/contracts
.
See https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/tree/master/contracts for list of available upgradeable contracts
PUSH0
The compiler for Solidity 0.8.20 switches the default target EVM version to Shanghai, which includes the new PUSH0
op code. This op code may not yet be implemented on all L2s, so deployment on these chains will fail. To work around this issue, use an earlier EVM version. While the project itself may or may not compile with 0.8.20, other projects with which it integrates, or which extend this project may, and those projects will have problems deploying these contracts/libraries.
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Beedle.sol#L2
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Fees.sol#L2
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L2
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Staking.sol#L2
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/interfaces/IERC20.sol#L2
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/interfaces/ISwapRouter.sol#L2
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/utils/Errors.sol#L2
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/utils/Ownable.sol#L2
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/utils/Structs.sol#L2
Recommend considering implementing a two step process where the owner or admin nominates an account and the nominated account needs to call an acceptOwnership() function for the transfer of ownership to fully succeed. This ensures the nominated EOA account is a valid and active account.
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/utils/Ownable.sol#L19
Lack of two-step procedure for critical operations leaves them error-prone. Consider adding two step procedure on the critical functions.
New items are pushed into the following arrays but there is no option to pop
them out. Currently, the array can grow indefinitely. E.g. there's no maximum limit and there's no functionality to remove array values.
If the array grows too large, calling relevant functions might run out of gas and revert. Calling these functions could result in a DOS condition.
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L276
Add a functionality to delete array values or add a maximum size limit for arrays.
Ownable2Step
rather than Ownable
Ownable2Step
and Ownable2StepUpgradeable
prevent the contract ownership from mistakenly being transferred to an address that cannot handle it (e.g. due to a typo in the address), by requiring that the recipient of the owner permissions actively accept via a contract call of its own.
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Beedle.sol#L4
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Beedle.sol#L9
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Beedle.sol#L11
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L8
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L10
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L73
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Staking.sol#L5
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Staking.sol#L11
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Staking.sol#L31
On leap years, the number of days is 366, so calculations during those years will return the wrong value
https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L724
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.