Bounce internal signed messages to protect relayer against abuse #14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is proposal made by @mr-tron after analysis of risks for Tonkeeper Battery service coupled with signed internal messages in W5 wallet.
In principle, the wallet should not bounce incoming messages as to avoid returning deposits back to the sender due to opcode misinterpretation. However, specifically for "gasless" transactions (signed messages relayed by a 3rd party), there is a risk for the relaying party to be abused: their coins should be bounced back in case of a race condition or delays.
We resolve this dilemma by silently failing during signature check (therefore ordinary deposits with arbitrary opcodes never bounce), but failing with an exception (therefore bouncing) after the signature check.
The downside of this solution is that wallet may emit bounced messages produced on purpose by trolls who reuse old signatures and send malformed, but well-signed messages to trigger bouncing. These bounced messages may clutter history and "recent" addresses in the wallets that do not check the "bounce" flag. Mitigation is simple: such operations should be filtered out as spam, just like the "0 ton" incoming transactions.