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

Remove short address attack checks from tokens #261

Closed
maraoz opened this issue Jun 16, 2017 · 12 comments
Closed

Remove short address attack checks from tokens #261

maraoz opened this issue Jun 16, 2017 · 12 comments

Comments

@maraoz
Copy link
Contributor

maraoz commented Jun 16, 2017

If transfer and transferFrom are used by a subcontract's function with less arguments, the checks will fail.

@maraoz
Copy link
Contributor Author

maraoz commented Jun 16, 2017

@izqui thoughts? This happened to me recently and had to use a horrible workaround

@federicobond
Copy link
Contributor

+1 to removing it. An honorable effort, indeed, but it was done at the wrong layer and in response to a single isolated case of very poor validation in the upper layers.

@izqui
Copy link
Contributor

izqui commented Jun 16, 2017

I agree. I haven't even deployed this in our own token.

@DavidKnott
Copy link
Contributor

@federicobond Just trying to learn, what layer do you think short address attack protection should be built into?

@federicobond
Copy link
Contributor

It should be handled by the libraries that read the contract ABI and let you create transaction payloads out of it (web3.js, truffle-artifactor, etc.)

@federicobond
Copy link
Contributor

Think of this analogy: dynamically-loaded libraries should not (and probably cannot) verify that you have pushed the right arguments into the stack before calling them. They just expose their ABI as header files and (unless you are writing assembly by hand) any high-level language compiler worth its salt will take care of the rest. What the library code SHOULD do is try to make sense of the arguments assuming they were pushed the right way, or bail out if not.

@frangio
Copy link
Contributor

frangio commented Jun 26, 2017

I'd like to add too that the modifier is incredibly error prone because the size argument has to be calculated and kept up-to-date by the programmer.

@frangio
Copy link
Contributor

frangio commented Jun 26, 2017

For reference, here's a demo of the error @maraoz mentions:
https://gist.github.com/anonymous/f5c444b9e087d03438aa990cb91b9e3a

frangio added a commit to frangio/openzeppelin-contracts that referenced this issue Jun 26, 2017
LefterisJP added a commit to LefterisJP/raiden-token that referenced this issue Oct 4, 2017
As also seen here:
OpenZeppelin/openzeppelin-contracts#261 this check
is kind of an overkill and should not be made at the smart contract
layer as it can have undesired consequences.
LefterisJP added a commit to LefterisJP/raiden-token-1 that referenced this issue Oct 4, 2017
Removing isValidPayload as also seen here:
OpenZeppelin/openzeppelin-contracts#261 it's an
overkill check that should be done in a different layer and not at the
smart contracts.
ProphetDaniel pushed a commit to classicdelta/Smart-Contracts that referenced this issue Mar 9, 2018
@rpsnoopy
Copy link

rpsnoopy commented Jun 18, 2018

How can you prevent malicious user to send the short address to your contract if the error is trapped at the user interface level only? The user interface is out of control for any public function: you can write your own and call whatever. And what about "it should be trapper at web3 level"? Is it trapped or not?

@frangio
Copy link
Contributor

frangio commented Jun 18, 2018

Web3.js correctly handles this. I don't remember right now if it pads an address argument to its full length, or it just rejects a short one. This was never a problem with web3.js. The attack was done on a website which used its own handwritten transaction encoder.

@rpsnoopy
Copy link

Given this, definitively I will use short address mitigation in my contracts, simply using >= instead of == in the msg.data.length check. “Should” be managed at another level is not enough safe to me.

@come-maiz
Copy link
Contributor

come-maiz commented Jan 4, 2019

For the record, this was fixed in Solidity 0.5.0: ethereum/solidity#4224

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

7 participants