Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Approval attack #56

Closed
josojo opened this issue Oct 16, 2017 · 1 comment
Closed

Approval attack #56

josojo opened this issue Oct 16, 2017 · 1 comment

Comments

@josojo
Copy link

josojo commented Oct 16, 2017

https://github.com/gnosis/gnosis-contracts/blob/9285b3e12708b921eecba827161b9295894b406f/contracts/Tokens/StandardToken.sol#L61

Some solidity coders propose to use an approvalIncrease function

    • @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
    • Beware that changing an allowance with this method brings the risk that someone may use both the old
    • and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
    • race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
    • ERC: Token standard ethereum/EIPs#20 (comment)
    • @param _spender The address which will spend the funds.
    • @param _value The amount of tokens to be spent.
      */
      function approve(address _spender, uint256 _value) public returns (bool) {
      allowed[msg.sender][_spender] = _value;
      Approval(msg.sender, _spender, _value);
      return true;
      }

Currently, all our smart contracts are save. But at some point, this might change, hence it would make sense to use an increaseApproval from the start.

An exemplary contract can be found here:
https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/StandardToken.sol

I think it should be done, but it is NOT important currently

@cag
Copy link
Contributor

cag commented Jul 19, 2019

It looks like #170 will switch to OZ's implementation actually.

@cag cag closed this as completed Jul 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants