superfluid-finance / protocol-monorepo

Superfluid Protocol Monorepo: the specification, implementations, peripherals and development kits.
https://www.superfluid.finance
Other
875 stars 236 forks source link

Don't jail SuperApps #1861

Open d10r opened 2 years ago

d10r commented 2 years ago

The jailing mechanism makes it difficult to write contracts implementing the SuperApp interface which don't risk getting bricked.

Assumption:
SuperApps get jailed if reverting in order to avoid them causing harm to the protocol.

Way in which this could happen:

  1. a malicious SuperApp may be able to exploit an unknown protocol vulnerability
  2. a faulty SuperApp may harm users

Rebuttals:

  1. While SuperApps may have a larger attack surface into the protocol than other interfacing contracts, this isn't a very compelling argument because:
    • jailing is only a weak (if any) defense here: a) a vulnerability may be exploitable without even triggering a jailing event, b) by the time the jailing event is triggered, the exploit may already have happened.
    • SuperApp whitelisting is the mechanism for this
  2. Jailing will in many cases not just not prevent this from happening, but even make it worse. It cannot prevent the first instance of misbehavior and the damage which may arise from the missed callback execution. Additionally it has the effect of making all future callback executions fail too (by not even attempting them). While the first miss may already have irreparably damaged the SuperApp state, one can also easily imagine cases where the damage is confined to the user making the tx, not affecting other users. In such cases, the jailing does make the situation worse by breaking the contract for everybody.

Suggestion:

If we find good reasons for keeping the jailing mechanism, we could also consider making it non-automated, e.g. by having a blacklist of SuperApps curated by governance.

d10r commented 2 years ago

observations from the latest Ricochet incident:

d10r commented 2 years ago

update after another conversation about it:

Instead of removing the jailing mechanism, it could also be redefined to work in a different way:

Option A

We only keep the Jailed event and bool, but jailing doesn't have any other effect.

Rationale:
The event makes it easy to have monitoring and alerting for failing callbacks.
The bool allows SuperApps to activate special functionality (e.g. emergency stop or recovery).
Callbacks aren't blocked, because they're try/catch-wrapped anyway and blocking them may not help (or even harm).

Option B

Rationale: If a goal of the mechanism is to protect app users, the most effective way to do so is likely blocking creation of new agreements to a potentially misbehaving app.
Deleting existing agreements needs to always work - not so clear though if blocking the callbacks after a revert is helpful, since it can't block the transaction anyway.
The option of governance un-jailing would allow apps with non-fatal bugs to keep operating once there's reason to believe that no harm will be done. There could e.g. be cases where a simple frontend adaptation could prevent "bad" txs from happening, allowing the app to continue operation.

d10r commented 1 year ago

Option A.1

d10r commented 1 year ago

An important aspect was overlooked here: jailing is also about limiting the damage a SuperApp not properly returning borrowed deposits can cause.