GithubHelp home page GithubHelp logo

Comments (4)

fulldecent avatar fulldecent commented on August 16, 2024 1

I am trying to understand this. Regarding:
https://github.com/erasureprotocol/erasure-protocol/blob/c716c17a080ac7817312ab57ec4b1c60aa867f19/contracts/escrows/CountdownGriefingEscrow.sol

The scenario here is:

  1. Operator creates the CountdownGriefingEscrow contract and initializes with:
    • seller = address(0)
    • operatoraddress(0)
  2. Operator deposits stake using depositStake
    • Documentation states "if seller not already set, make msg.sender the seller"
    • seller is not changed
    • Tokens are attributed to seller which is still address(0)
  3. Nobody can get tokens that are attributed to address(0)

Design issues:

  • If a contract is initialized where the seller is open-ended then the contracts fails if the operator acts as a seller.
  • There is no way for an operator to set the seller for the contract if it was not set at initialization.
  • The contract works properly if the sender on an open-ended contract deposits stake by itself.

Design questions:

  • Is it desired that an operator will be able to set the sender if the contract was initialized without a sender?

Is this a vulnerability?:

  • We need to see the contract implementation for the intended operator contract to decide.
  • If the operator contract wants to set the sender for a contract that was initialized without a sender then then this is a vulnerability.

Remediation:

  1. At a minimum, for safety, prevent operator from acting as seller in the current implementation.
  2. This can be done in below here
  3. OR review the functionality of the operator implementation to make sure it is not used in this way.
  4. If it is desired that operator can set the seller at a time after contract initialization, then this must be added as a new public function.

from erasure-protocol.

thegostep avatar thegostep commented on August 16, 2024

@fulldecent went for remediation num 4.

The rationale is that operator serves as a blanket bypass of all access control to the public functions of the contract. This allows for composability since I can delegate the permissions to a separate contract that only implements the desired functionality.

Hopefully the documentation makes clear that the operator is always a trusted party if used.

from erasure-protocol.

thegostep avatar thegostep commented on August 16, 2024

The fix includes the ability to set an arbitrary seller / buyer instead of inferring it from msg.sender. Do you think this is a good pattern?

from erasure-protocol.

fulldecent avatar fulldecent commented on August 16, 2024

Looks great. Very clear and safe. Good pattern.

from erasure-protocol.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.