Skip to content

Brief audit of 'l2mp_staking.ride` #426

Description

@deemru
  • CRITICAL: negative values in list can bypass check
    amountListSum <= i.payments[0].amount || "payment amount is less than sum of amountList".throwErr()
  • HIGH: duplicated addresses rewrites itself
    func airdrop(addressList: List[String], amountList: List[Int]) = {
    (result :+ IntegerEntry(userLockedLpKey, oldLpAmount + addedLpAmount), index + 1, totalLp + addedLpAmount)
  • MEDIUM: address can be any string value
    let userLockedLpKey = keyUserLockedLpAmount(addressList[index])
  • MEDIUM: can be proxied by third-party apps to set their nodeAddress unnoticed by user
    i.originCaller.toString() == userAddress || "i.originCaller should be equal to userAddress".throwErr()
  • MEDIUM: address is more than 26 any bytes
    userAddress.fromBase58String().size() == ADDRESS_BYTES_SIZE || "user address is not valid".throwErr()
    userAddress.fromBase58String().size() == ADDRESS_BYTES_SIZE || "user address is not valid".throwErr(),
    nodeAddress.fromBase58String().size() == ADDRESS_BYTES_SIZE || "node address is not valid".throwErr()
  • MEDIUM: masking of negative values (can save from CRITICAL by throw instead of bypass)
    func calcAssetFromLp(lpAmount: Int) = {
    max([0, fraction(lpAmount.toBigInt(), getCurrentPrice(), scale18BigInt).toInt()])
    }
    func calcLpFromAsset(assetAmount: Int) = {
    max([0, fraction(assetAmount.toBigInt(), scale18BigInt, getCurrentPrice()).toInt()])
    }
  • LOW: too much complexity for every getCurrentPrice() recalculation, you can use let currentPrice = getCurrentPrice() and use it as global variable once calculated (drops 7773 -> 3904 complexity for example https://waves-ide.com/s/6571a30ea0bc9700314de3c8)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions