I will start with two problems with default responsible.
Problem #1, default responsible has flag: 0 and he send value depend on pragma msgValue? 7_500_000 or 9_500_000.
Simple contract:
contract SimpleContract {
address static owner;
constructor() public {
tvm.accept();
}
function get_owner() external pure responsible returns (address) {
return owner;
}
}
Get owner will be compiled to
function get_owner() external pure responsible returns (address) {
return {flag: 0, value: 7_500_00, bounce: true} owner;
}
Also it can be used to make money. If attacker find contract with such responsible he can pay for call responsible < 7_500_00 evers and get back 7_500_00 evers. So he can drain balance. This will getting worse if gas price will be lower in future.
Problem #2, default responsible has bounce: true, and it is really bad.
Attacker can call get_balance with answerID = tvm.functionId(VulnerableContract.transfer) and throw exception in callback. In this case VulnerableContract will receive unexpected onBounce and will double their tokens.
To solve this problems my suggestion is to force users to set ALL three params explicitly. Just throw compile time error if one of (value, flag, bounce) is not set.
Hi there,
I will start with two problems with default responsible.
Problem #1, default responsible has flag: 0 and he send value depend on pragma msgValue? 7_500_000 or 9_500_000.
Simple contract:
Get owner will be compiled to
Also it can be used to make money. If attacker find contract with such responsible he can pay for call responsible < 7_500_00 evers and get back 7_500_00 evers. So he can drain balance. This will getting worse if gas price will be lower in future.
Problem #2, default responsible has bounce: true, and it is really bad.
Example of vulnerable contract (pseudocode):
Attacker can call get_balance with answerID = tvm.functionId(VulnerableContract.transfer) and throw exception in callback. In this case VulnerableContract will receive unexpected onBounce and will double their tokens.
To solve this problems my suggestion is to force users to set ALL three params explicitly. Just throw compile time error if one of (value, flag, bounce) is not set.