Skip to content

Latest commit

 

History

History
208 lines (126 loc) · 6.58 KB

report.md

File metadata and controls

208 lines (126 loc) · 6.58 KB

Aderyn Analysis Report

This report was generated by Aderyn, a static analysis tool built by Cyfrin, a blockchain security company. This report is not a substitute for manual audit or security review. It should not be relied upon for any purpose other than to assist in the identification of potential security vulnerabilities.

Table of Contents

Summary

Files Summary

Key Value
.sol Files 3
Total nSLOC 321

Files Details

Filepath nSLOC
src/DSCEngine.sol 269
src/DecentralizedStableCoin.sol 29
src/libraries/OracleLib.sol 23
Total 321

Issue Summary

Category No. of Issues
High 1
Low 6

High Issues

H-1: Arbitrary from passed to transferFrom (or safeTransferFrom)

Passing an arbitrary from address to transferFrom (or safeTransferFrom) can lead to loss of funds, because anyone can transfer tokens from the from address if an approval is made.

  • Found in src/DSCEngine.sol Line: 308

             bool success = i_dsc.transferFrom(dscFrom, address(this), amountDscToBurn);

Low Issues

L-1: Centralization Risk for trusted owners

Contracts have owners with privileged rights to perform admin tasks and need to be trusted to not perform malicious updates or drain funds.

  • Found in src/DecentralizedStableCoin.sol Line: 42

     contract DecentralizedStableCoin is ERC20Burnable, Ownable {
  • Found in src/DecentralizedStableCoin.sol Line: 57

         function burn(uint256 _amount) public override onlyOwner {
  • Found in src/DecentralizedStableCoin.sol Line: 68

         function mint(address _to, uint256 _amount) external onlyOwner returns (bool) {

L-2: Unsafe ERC20 Operations should not be used

ERC20 functions may not behave as expected. For example: return values are not always meaningful. It is recommended to use OpenZeppelin's SafeERC20 library.

  • Found in src/DSCEngine.sol Line: 280

             bool success = IERC20(tokenCollateralAddress).transferFrom(msg.sender, address(this), amountCollateral);
  • Found in src/DSCEngine.sol Line: 299

             bool success = IERC20(tokenCollateralAddress).transfer(to, amountCollateral);
  • Found in src/DSCEngine.sol Line: 308

             bool success = i_dsc.transferFrom(dscFrom, address(this), amountDscToBurn);

L-3: Missing checks for address(0) when assigning values to address state variables

Check for address(0) when assigning values to address state variables.

  • Found in src/DSCEngine.sol Line: 256

             s_DSCMinted[msg.sender] += amountDscToMint;
  • Found in src/DSCEngine.sol Line: 278

             s_collateralDeposited[msg.sender][tokenCollateralAddress] += amountCollateral;
  • Found in src/DSCEngine.sol Line: 297

             s_collateralDeposited[from][tokenCollateralAddress] -= amountCollateral;
  • Found in src/DSCEngine.sol Line: 306

             s_DSCMinted[onBehalfOf] -= amountDscToBurn;

L-4: public functions not used internally could be marked external

Instead of marking a function as public, consider marking it as external if it is not used internally.

  • Found in src/DecentralizedStableCoin.sol Line: 57

         function burn(uint256 _amount) public override onlyOwner {
  • Found in src/libraries/OracleLib.sol Line: 20

         function staleCheckLatestRoundData(AggregatorV3Interface chainlinkFeed)
  • Found in src/libraries/OracleLib.sol Line: 37

         function getTimeout(AggregatorV3Interface /* chainlinkFeed */ ) public pure returns (uint256) {

L-5: Event is missing indexed fields

Index event fields make the field more quickly accessible to off-chain tools that parse events. However, note that each index field costs extra gas during emission, so it's not necessarily best to index the maximum allowed per event (three fields). Each event should use three indexed fields if there are three or more fields, and gas usage is not particularly of concern for the events in question. If there are fewer than three fields, all of the fields should be indexed.

  • Found in src/DSCEngine.sol Line: 95

         event CollateralRedeemed(address indexed redeemFrom, address indexed redeemTo, address token, uint256 amount); // if

L-6: The nonReentrant modifier should occur before all other modifiers

This is a best-practice to protect against reentrancy in other modifiers.

  • Found in src/DSCEngine.sol Line: 183

             nonReentrant
  • Found in src/DSCEngine.sol Line: 222

             nonReentrant
  • Found in src/DSCEngine.sol Line: 255

         function mintDsc(uint256 amountDscToMint) public moreThanZero(amountDscToMint) nonReentrant {
  • Found in src/DSCEngine.sol Line: 275

             nonReentrant