Network Transaction DOS Attacks #1303
Replies: 3 comments 4 replies
-
Do we know how this could translate to real world numbers? I think this would depend on the strategy used by the NTB to try to execute and include network transactions as well (which I'm not sure is fully defined yet) but it'd be nice to get a sense of how bad an attack could be.
Overall it feels like the note sender could cause problems in most scenarios - could you not penalize sender account IDs as well/instead? eg if a note stalls execution, its sender account is put into an LRU cache that provides some info to the NTB about what to prioritize next. |
Beta Was this translation helpful? Give feedback.
-
We probably don't want to do this (even if we could). The main reason is that the sender should always have the ability to reclaim a network note. For example, if I created a note for a trade against an AMM, if my trade doesn't go through, I should be able to reclaim the assets.
I think imposing fees for failed execution (even if we could impose them), could be problematic. This basically gives an incentive to the NTB to fail some notes. For example, if NTB knows that a note could result in some action in a couple of blocks, and this action is somehow undesirable for NTB, it could fail the note "prematurely". This is a concern only when the network is decentralized, but a concern nevertheless. So, overall, in my mind are a couple of guidelines:
Now, this doesn't mean that an NTB needs to keep trying to execute some notes forever - but I think this could be a part of a specific block producer's strategy, rather than protocol-wide setting. Some more general thoughts: The attack described here is not free. The attacker has the following costs:
The first point means that the attacker needs to spend computational resources which are quite high as compared to what the node would spend for a small number of execution attempts. This is because proving a transaction would be 10000x (or maybe even more) expensive than just executing it. So, even if a node tries to execute a note 100 times, the attacker would still need to spend more resources. This doesn't mean that the attack is not profitable: the attacker could be willing to spend these resources (especially for a short duration of time). The second point should be much bigger of a deterrent, assuming the same transaction cannot be used for something else. Basically, if the attacker creates these notes solely for the purpose of attacking the network, they'd need to pay a pretty significant cost. The fact that the attacker needs to pay a fee for creating the note in the first place, may be something we can play around with. For example, the cost for creating network notes could be higher than for regular public notes. Or maybe even it could very on per-account basis. That is, the fee for creating a network note for a given note tag could depend on how many unconsumed network notes with the same tag already exist in the system. Though, how to implement this efficiently is not clear to me yet.
I think this is a good idea and should drastically increase the cost of the attack because it would eliminate potential alternate uses of a malicious network note. I wonder, however, if this should be a feature for all accounts (rather than just network accounts). That is, all accounts should be able to specify scripts of notes that they are able to accept. Though, this would be optional for non-network accounts. One question is how this info should be specified. |
Beta Was this translation helpful? Give feedback.
-
|
To summarize some of my thinking on this:
One other thing I was thinking about: could there be a way for the users to send "hints" to the node to say "try executing this note now". This could be a way to "rehydrate" notes that the NTB decided to "give up" on. How to do this in an incentive-compatible way is not clear to me though. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
We call notes targeted at network accounts network notes. These notes have some potential for DOS-ing the network transaction builder (NTB), which in the centralized setting is the node operator.
If I understand correctly, the idea is that the node tries to execute any network note against the account it is targeted at a number of times to see if it will succeed. There will be an upper limit to this, but it must be a few times. For example, in a DEX scenario where my note sets the slippage conditions, it might only succeed after a few attempts, which is a valid scenario.
Note execution cycles
A maliciously designed note could take the max number of cycles the NTB is willing to execute. So the NTB will waste
max cycles * number of note execution attemptscycles in total, which could be significant.Lack of fee for failed execution
The problem here is that the note does not pay any fee to the network transaction builder if it does not succeed.
An attacker can exploit this by sending a note to a network account that the attacker knows will never be able to be consumed. For example, this could be a custom P2ID-like note targeted at network account X according to the note tag, but the actual note inputs target account Y. (I say custom note, because the regular P2ID note is well-known and can be statically checked in Rust code, which doesn't prevent the DOS-ing per se, but makes this example generally applicable. Realistically, for the maximum DOS effect, this would be a note which uses the slowest available Miden VM API.)
Now the NTB will see the target of the note in the note tag and try to execute the note against that account a bunch of times.
One idea to prevent this in-protocol is to make network notes pay a penalty if they're consumed by an account whose account ID does not partially match the one from the note tag. This is the case if the attacker tries to reclaim their own note after the NTB has executed it a few times. But reclaiming might not even be necessary for the attack to work for example if the note does not contain a valuable enough asset. That makes the penalty useless. Additionally, since we only put 30 bits of the account ID in the note tag, creating an account with a match in that 30 bit part of the prefix is not too computationally difficult and then the note could be reclaimed by that account and the penalty is bypassed. Only one such partial match of target network account ID and attacker account ID is needed to run this attack against the NTB repeatedly without penalty.
Reducing attack surface
To reduce the attack surface, each network account should expose the set of note script roots it is willing to accept. It may be good enough if this is by convention. For example storage slot 0 of the account is expected to contain a storage map of script roots which represents that set. (See also #1275 (comment)).
This helps with both problems insofar as a maliciously crafted note cannot be sent to every network account. So not every network account will be spammed with useless notes. But, an attacker just wanting to slow down the NTB can create a network account themselves and put the malicious note script root into the allowed note set.
NTB deny strategy
An NTB could apply a "deny strategy" to network accounts. For example, if an NTB executes a few transactions and notes against some network account and most or all of them fail, then it might ignore this account for a while. Figuring out the acceptable failure ratio here might be tricky though without penalizing valid use cases (e.g. notes with slippage conditions in a DEX could fail a lot).
The best metric for the NTB might ultimately be whether the average fees from a network transaction against a certain network account are high enough for the NTB not to make a loss over some period of time. If the NTB makes a loss consistently, the network account is put on the deny list for some time or even indefinitely - these could be individually set strategies if network transaction building becomes decentralized.
This strategy to evaluate the profit of a network account together with the set of notes that a network account is willing to accept might be a reasonably good enough defense.
If anyone can think of other DOS attacks with network notes (or non-DOS attacks too) as well as mitigation strategies, feel free to add those in the discussion.
Beta Was this translation helpful? Give feedback.
All reactions