Blog

Interesting mechanics to limit attack surfaces

I had an interesting talk with my friend @windhustler , we talked about different bug scenarios, the possibility to miss something and how to still be able to avoid attacks if a bug was missed.

How can this be achieved?

I am a pretty big fan of limiting user flexibility, there are different types how this can be achieved. Of course it goes without saying that each limitation will have its downside as well:

1) Limit the possibility for the tx.origin to invoke a function more than two times in the same block:




(Its GPT written and it's too late here to double check it, so bear with me if it contains a bug, but you get the idea)


2) Limit the actual "size" of the transaction: For example a deposit function can be limited to only allow to be a certain size:




Of course, as I said there are certain disadvantages of implementing such safeguards but sometimes protocols are so large and complex that there will always remain a leftover risk even after multiple audits.

Its simply a question of weighing up the arguments.