DSS can force operator to pay much more for gas than necessary when calling DSS's hooks #18
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
grade-a
primary issue
Highest quality submission among a set of duplicates
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
🤖_09_group
AI based duplicate group recommendation
sponsor disputed
Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-07-karak/blob/d19a4de35bcaf31ccec8bccd36e2d26594d05aad/src/entities/CoreLib.sol#L56-L65
https://github.com/code-423n4/2024-07-karak/blob/d19a4de35bcaf31ccec8bccd36e2d26594d05aad/src/entities/HookLib.sol#L78-L103
https://github.com/code-423n4/2024-07-karak/blob/d19a4de35bcaf31ccec8bccd36e2d26594d05aad/src/entities/HookLib.sol#L48-L64
https://github.com/code-423n4/2024-07-karak/blob/d19a4de35bcaf31ccec8bccd36e2d26594d05aad/src/entities/Operator.sol#L181-L203
Vulnerability details
Impact
Different DSSes can have different logics in their hooks. The hooks with complex necessary logics would require high
hookCallGasLimit
to be called while the hooks with simple necessary logics should only require lowhookCallGasLimit
to be called. To accommodate all DSSes' hooks, the followingCoreLib.updateGasValues
function would be called to setself.hookCallGasLimit
to a value that is high enough for executing the most gas-intensive hook among all DSSes because everyHookLib.callHookIfInterfaceImplemented
function call usesself.hookCallGasLimit
as thehookCallGasLimit
input in this protocol.https://github.com/code-423n4/2024-07-karak/blob/d19a4de35bcaf31ccec8bccd36e2d26594d05aad/src/entities/CoreLib.sol#L56-L65
https://github.com/code-423n4/2024-07-karak/blob/d19a4de35bcaf31ccec8bccd36e2d26594d05aad/src/entities/HookLib.sol#L78-L103
https://github.com/code-423n4/2024-07-karak/blob/d19a4de35bcaf31ccec8bccd36e2d26594d05aad/src/entities/HookLib.sol#L48-L64
When
self.hookCallGasLimit
is high, an operator might feel safe to call a DSS's hook if such hook should have simple necessary logics since the unspent gas can be refunded to the operator. However, such DSS can conditionally execute unnecessary logics through its hook to spend gas up to the highself.hookCallGasLimit
. This forces the operator to spend much more gas than necessary. For example, although theOperator.unregisterOperatorFromDSS
function calls theHookLib.callHookIfInterfaceImplemented
function withignoreFailure
beingtrue
so the DSS cannot prevent the operator from unregistering, this does not prevent the unnecessary logics through the DSS's hook from consuming gas up to the highself.hookCallGasLimit
that is higher than the gas amount for only executing the hook's necessary logics. As a result, especially when the gas price is high, the DSS can force the operator to pay much more for gas than necessary.https://github.com/code-423n4/2024-07-karak/blob/d19a4de35bcaf31ccec8bccd36e2d26594d05aad/src/entities/Operator.sol#L181-L203
Proof of Concept
The following steps can occur for the described scenario.
unregistrationHook
function's necessary logics are complex while DSS B'sunregistrationHook
function's necessary logics should be simple.self.hookCallGasLimit
in the protocol is set to a high value to ensure sufficient gas for calling DSS A'sunregistrationHook
function.Operator.unregisterOperatorFromDSS
function to unregister from DSS B.Operator.unregisterOperatorFromDSS
function, which calls theHookLib.callHookIfInterfaceImplemented
function withignoreFailure
beingtrue
, does not allow DSS B to prevent Operator B from unregistering, DSS B can conditionally execute unnecessary logics through itsunregistrationHook
function to consume gas up to the highself.hookCallGasLimit
that is higher than the gas amount for only executing DSS B'sunregistrationHook
function's necessary logics.Tools Used
Manual Review
Recommended Mitigation Steps
When a DSS registers in the
Core
contract, it can provide immutable gas limit values for each hook. Then, when an operator registers to a DSS, the operator can provide expected gas limit values for each of the DSS's hook; if at least one of the operator's expected hook gas limit values is lower than the corresponding hook gas limit value set by the DSS, then the operator's registration to the DSS reverts.Assessed type
Other
The text was updated successfully, but these errors were encountered: