-
Notifications
You must be signed in to change notification settings - Fork 15
Vulnerability in StandardToken.sol's implementation of transferFrom() #8
Description
Hi,
Per Roman's request, I'm submitting this vulnerability report here.
StandardToken.sol (https://github.com/ether-camp/virtual-accelerator/blob/master/contracts/StandardToken.sol) has a vulnerability in the transferFrom() function:
// do the actual transfer
balances[from] -= value;
balances[to] =+ value;
The =+ should be +=.
The vulnerable code is used in the deployed HackerGold token (https://etherscan.io/token/HackerGold).
By using approve() followed by transferFrom(), it is possible to essentially reset the balance of any account.
For example, see these two transactions:
https://etherscan.io/tx/0x8cbc0975efe91a53777211968870a4a62eea2c27dda4e69fa1a1ff3c6cb43dcb
https://etherscan.io/tx/0xfb0b85b5cb46d427933952a4d839d6f4b0bcad9f71ba9696fc7fb6ad5d359a38
The effect is that 0x2ccc5a059a1bda4c3c3c594516e812a0b15799c9's balance has been reduced from 5,000,000 HKG to 0.001 HKG.
Recommended fix:
- Create a new HKG contract that fixes the bug and initializes all balances to what they were before the above transactions.
- Any dapps that keep track of HKG balances internally (i.e., EtherDelta) need to be taken into account so that people who were holding balances inside such smart contracts get their tokens back.
- Exchanges and token users will need to be notified about the transition to a new token contract.
Thanks,
Zack