DSS 2026 — Guarding the Guard: Engineering a Deny-by-Default Policy Engine for Safe Shebin John Source video: https://www.youtube.com/watch?v=Gj5hq8fhJtM Automatic captions — not human-reviewed. Complete spoken-audio coverage is unverified. Source language tag: en (English). Source export SHA256: 742cb12a3f3566eaeda4f55e74a4d2c256974f816f1cfb400cc7da2a74325737 [0:00] Okay, better. [0:02] So, what I was saying, so every safe can [0:04] install a guard and [0:07] that is one of the best defense [0:09] contracts out there for a safe. [0:11] At the same time, that is one of the [0:13] most dangerous contract because it can [0:15] basically refuse any transaction even [0:17] with an owner signature. [0:19] So, [0:21] if that is the case [0:23] and any transaction which is being [0:25] executed is checked by a guard, who [0:28] checks the transaction which removes a [0:30] guard? [0:31] Is it the owners? Is it something else? [0:34] And that is the paradox we are trying to [0:36] figure out for the next few minutes. [0:39] So, before [0:41] want to make sure that everyone [0:43] understands how a safe works. So, there [0:46] is a set of owners, usually an of M is [0:49] the configuration and N signers has to [0:52] sign for a transaction to be executed [0:55] and I usually mention it as the front [0:57] door for the safe. Then we have the [0:59] modules who have its own configuration. [1:02] It has its own logic and that is [1:04] basically the side door. Now, to protect [1:07] these two doors, we have the guard which [1:10] basically can be considered as the [1:12] bouncer for the safe. [1:16] From say 1.3.0, we have the transaction [1:19] guard and from [1:21] say 1.5.0, we have also the module [1:23] guard. [1:25] So, these are the three guards which we [1:28] built over the last year and basically [1:31] the guard rail is just a deny for a [1:34] delegate call transactions. Then we have [1:36] the fiducia which is [1:39] some allow list as well as the co-signer [1:41] and then we have the holy grail of [1:43] guards which is the policy engine. [1:46] So, as an analogy, you can think that [1:48] guard rail is just a single tool, let's [1:50] say a screwdriver. Fiducia is like the [1:52] Swiss Army knife. It can do a lot but [1:54] not everything and then we have the [1:57] policy engine which is a toolbox for a [2:00] and the limits are just the imagination [2:03] of the developer. [2:05] So [2:06] there are two ways through which we can [2:08] use the policy engine. The first one is [2:11] fail open and the second one is the fail [2:13] close. So what are those? So fail open [2:16] is when you only deny certain [2:19] transaction in the policy engine and the [2:21] rest is allowed. [2:22] And the fail closed is when any [2:25] transaction which you want to be [2:26] executed is approved specifically and [2:29] then the rest is denied by default. [2:32] And based on the coloring you can see [2:34] that I align a bit to more towards on [2:37] the fail close because this provides the [2:39] highest amount of security for a safe. [2:45] So before we move forward, how a [2:47] transaction moves through safe? Let's [2:50] look at that. So if it's a normal [2:52] transaction, the owner signs it, then [2:55] the safe [2:56] goes through the execution through the [2:57] exit transaction. [2:59] The policy guard checks if that is an [3:02] allowed policy or within the allowed [3:04] policy or not and then the execution is [3:06] allowed. [3:07] Same goes for the module. If [3:10] based on the logic of the module, if the [3:12] transaction is allowed, [3:13] then it goes through the safe, then it [3:16] goes to the guard and the policy guard [3:18] checks if any policies allows these [3:20] module, then the execution is allowed. [3:24] How do we select each transaction? How [3:27] do we select each policies? Is based on [3:29] something we called as the access [3:31] selector. [3:32] Right now it is based on three things, [3:34] two [3:35] selector and the operation. [3:37] Two is the target address where the [3:39] transaction is being called. [3:41] Selector is the function which we are [3:43] going to call and the OP is the [3:45] operation whether it is called or a [3:47] delegate call. [3:48] There are some zero bytes which we have [3:50] reserved for future developments. [3:53] So how do we select the policies based [3:55] on this access selector? So let's say [3:57] that we have a USDC transferred to say [4:00] XYZ account. So we look at the token [4:03] address, the selector that is transfer, [4:05] and the operation that is called, and [4:07] then we execute the transaction if there [4:09] is a policy for that. [4:11] If not, we fall back to the fallback [4:13] policy, which [4:15] may allow or may not allow based on its [4:18] own particular logic. And even [4:21] these two policies are not allowing this [4:23] transaction, then the access is denied. [4:27] So, policies are basically small [4:28] contracts. So, there are like gated [4:31] policies like allow policy, deny policy, [4:33] and one-time allow policies. Shape of [4:36] the call is another big factor, that is [4:38] whether it is a transfer call, whether [4:40] it's an approve, or it is something [4:42] else. Then we have the extra approval [4:45] policies like co-signer policies or [4:48] increase threshold policy, and one of [4:50] the best things is Safe Net policies, [4:52] which we will talk further. [4:54] And of all these things, there are [4:57] sometimes batch transaction which is [5:00] which Safe is known for. And that is [5:02] where we use the multi-send policy, [5:04] which basically distributes it to its [5:06] own particular policies. Let's say that [5:09] multi-send policies have multiple [5:11] approve and transfer, then it goes to [5:12] the shape of the call policies. [5:15] So, let's look at the Safe Net as a [5:17] policy. So, why this is important, [5:20] especially in the context of policy [5:21] engine, is that [5:22] policy engine is much more static, [5:24] on-chain. It's much more rigid, and that [5:27] is by design. It is not a bug. [5:29] And this is where Safe Net comes in. And [5:32] Safe Net allows the flexibility which [5:35] the policy engine requires. So, how the [5:37] Safe Net works is mainly depending on [5:40] three factors or three parts. The first [5:43] one is the sentinel, which basically [5:46] checks the transaction which needs to be [5:48] executed, whether it is malicious or [5:50] not, whether it should be allowed or [5:51] not. [5:52] If there is a unanimous approve, then it [5:55] goes to the validators, which does a [5:57] frost attestation. We use frost [5:59] threshold signature scheme. [6:00] And once that attestation is [6:03] received, we can use that same [6:06] in the guard which is within the policy [6:08] engine as a policy. We call that as a [6:10] safe net policy. [6:13] So let's look at an example. So you have [6:16] a treasury which you own and you usually [6:19] do a USDC transfer or a stable coin [6:21] transfer and by human mistake or you [6:24] were lazy at that day or something else [6:26] happened, you approved a transaction [6:29] which was malicious [6:30] and you didn't knew that until the safe [6:33] net [6:34] or the policy engine guard [6:36] caught it. So there are two [6:39] different scenarios here. One, you [6:41] allowed a transaction which was not [6:43] supposed to be allowed and that gets [6:45] executed which can basically drain your [6:47] wallet and the another one is with the [6:50] policy engine and that basically caught [6:53] it and you were saved by the tree. [6:56] So now until now we looked at how the [6:59] guard can actually save you. [7:01] Now we also want to look at how the [7:03] guard can hurt you because that is one [7:05] important step we need to consider. [7:08] So [7:09] first thing is that you installed a [7:11] guard which was only on the transaction [7:13] side of things, not on the module side [7:15] of things. So basically you open [7:18] you have a bouncer on the front gate but [7:20] not on the side gate. So you need to [7:22] make sure that when you install a guard [7:24] you need to install it both on the [7:26] transaction path as well as on the [7:27] module path. [7:28] Then the second one is not on the most [7:31] dangerous side but also a bit on the [7:34] annoying side is [7:36] on the configuration part. So before you [7:39] install the guard in install the policy [7:41] engine guard, you need to also configure [7:43] it and you need to configure based on [7:45] all the transaction which you do and if [7:48] you do that that's much more easier when [7:50] you install the guard those transactions [7:52] are already allowed and the rest of it [7:54] is denied. If not it's a bit annoying, [7:57] not the worst case scenario. It's just [7:59] that you need to now configure it [8:01] and wait for the delay. [8:04] So how does changing the rule happens? [8:06] You request a configuration, you need to [8:08] wait for a delay. This is the public and [8:11] the slow period where you as an owner [8:14] can take action if it's not a [8:18] required configuration or if it is a [8:20] malicious configuration and things like [8:22] that. [8:23] Once the delay passes, you have a [8:25] certain window which you can [8:29] implement or apply this configuration. [8:31] And why this certain window is there is [8:34] because so that you added a [8:36] configuration and the delay happened and [8:40] now you wait for another year for that [8:42] application to be [8:43] configured. So this is why we have this [8:46] expiry added. [8:48] And once this [8:49] application is done within this expiry [8:52] period, the policy is alive on the [8:56] policy is alive on the [8:57] policy engine. [8:58] So [9:00] where what you have to look at it here [9:02] is that that when you do a [9:05] when you [9:06] apply a configuration, [9:08] you can have that particular delay [9:10] period where you can basically remove [9:13] this configuration if it is let's say a [9:16] malicious one or if it is something [9:17] non-intended or the circumstance has [9:20] changed. [9:21] But once these policies are alive in [9:24] safe and through the policy engine, [9:27] it takes a delay for these to be [9:29] changed. [9:31] So now what the delay buys? We need to [9:34] make sure that we understand what it [9:36] does and what it does not. So first [9:38] thing is time. [9:40] It basically gives you the particular [9:42] delay period to react. [9:44] It is visible in public blockchain. So [9:47] any change you make it is [9:49] online on chain. So you have the time to [9:52] react to these things. [9:54] And [9:55] also if let's say that the configuration [9:57] was the malicious transaction, [9:59] it is not one step draining of account. [10:02] You have more steps. You have to wait [10:05] out for these things to happen. [10:07] Now what is [10:08] not promised? [10:10] So this is [10:11] the part where you need to focus when in [10:14] terms of the policy engine, what it does [10:16] and what it does not. [10:18] So [10:19] immunity is one thing. If let's say that [10:21] all the owners are compromised, [10:24] then in that case those owners or the [10:26] malicious owners now can wait out the [10:28] delay. [10:29] The second is judgment and [10:32] this is based on human judgment. Let's [10:34] say that you approved a configuration [10:36] after a particular delay and that was a [10:38] malicious recipient or something like [10:40] that. This is something which you cannot [10:42] avoid through policy engine. [10:44] The third is rescue. So the guard cannot [10:48] refuse a transaction. It can only let [10:51] say that block it for certain time or [10:53] certain degree. [10:55] And then [10:56] the most important thing is monitoring. [10:58] If let's say that you don't monitor your [10:59] safe through this configuration, then [11:02] any policy change is basically something [11:05] which you didn't notice and it can get [11:07] executed. [11:09] So [11:10] where the checks and the execution [11:12] diverge in terms of even policy engine. [11:13] So there are things which we can improve [11:16] on the policy engine. Some of these are [11:18] mentioned in the screen. [11:19] One thing which I want to [11:21] stress is about the multisend which was [11:24] I think found by Certora itself during [11:27] an audit is that a pre-state within the [11:30] multisend [11:31] cannot [11:32] be checked after the pre- after the [11:34] post-state. So let's say that you in a [11:36] multisend change the owners on the first [11:38] transaction. [11:40] The rest of the transaction is checked [11:41] still on the pre-state, not on the [11:43] post-state of that owner change, which [11:44] is a known thing which we may improve in [11:47] the future. [11:50] So [11:51] today after you are going home from this [11:54] talk, I want to ask these five I want [11:57] you to ask these five questions to [11:59] yourself, to your own setup. [12:02] Where does your safe fail? Is it open or [12:04] is it closed? [12:06] What are the lockout paths? [12:08] Half installed states and things like [12:09] that. [12:10] How fast you can change something in [12:12] your own safe? [12:14] What joins as a trusted thing in your [12:17] safe and what is actually promised and [12:19] what is only implied in your safe? [12:24] So [12:25] we started with the paradox saying that [12:28] a guard [12:31] is checking its own transaction to be [12:33] removed. [12:34] Who checks the guard? And the answer is [12:36] not let's say a clever transaction or a [12:40] clever contract. It is basically some [12:42] habits. [12:43] One of it is deny by default. So [12:46] anything which you haven't specified [12:49] gets refused in the safe. [12:52] One policy per call so that all the [12:55] rules which you have mentioned [12:57] is abided by within the safe. [12:59] And the last one is any change in the [13:02] configuration [13:04] it is public [13:05] and it is loud. So anything which you [13:09] haven't configured you get the time to [13:11] change it. You you get the time to react [13:13] to it and that is the monitoring [13:15] ability. [13:16] All the code which I have spoken today [13:19] is audited and it is public. I would [13:22] love you to take a part and get back to [13:24] me with some feedbacks. And to conclude [13:27] I want to say that a guard you can [13:29] quietly loosen is not a guard. Thank [13:32] you.