Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check if hook installed before emergency uninstall #175

Merged
merged 3 commits into from
Sep 23, 2024

Conversation

livingrockrises
Copy link
Contributor

@livingrockrises livingrockrises commented Sep 20, 2024

Problem:

The emergencyUninstallHook() function is meant to allow the account owner to remove a hook from the account (minus the pre and post checks on the hook).

It is an alternate to the uninstallModule() function which offers hook checks on calls to uninstall any type of modules.

A timelock has been placed to only allow the account to emergency-uninstall the hook after 1 day of placing an uninstall request. But emergencyUninstallHook() fails to check that the hook was actually installed.

This allows the timelock to be bypassed through the following steps :

Call emergencyUninstallHook() to place an uninstall request even before installing the hook => this records a timestamp corresponding to the hook address
After nearly a day has passed, install the hook and use it
Immediately call emergencyUninstallHook() to utilize the request that was placed before
As only a day has passed, the call will go through
The timelock has been effectively bypassed by the account

Solution:

UninstallModule() on Nexus.sol checks that the module they are trying to uninstall through the call is actually installed. Add the same check to emergencyUninstallHook()

Also replaced the event EmergencyHookUninstallRequest in reset case with EmergencyHookUninstallRequestReset (Cantina 59)

Copy link

github-actions bot commented Sep 20, 2024

Changes to gas cost

Generated at commit: 07218814cd50fbff916800c21ab0a618418f5e5f, compared to commit: 63a37aa2849152afd73bbd0d1143942707533d79

🧾 Summary (5% most significant diffs)

Contract Method Avg (+/-) %

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
Nexus 4,850,086 (+10,374)

Copy link

openzeppelin-code bot commented Sep 20, 2024

fix: check if hook installed before emergency uninstall

Generated at commit: c906e0d80a85e92d8af65cb2d65a58e71e10f9ee

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
0
1
0
7
25
33

For more details view the full report in OpenZeppelin Code Inspector

Copy link

codecov bot commented Sep 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.86%. Comparing base (63a37aa) to head (2cfa270).
Report is 4 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #175      +/-   ##
==========================================
+ Coverage   94.58%   94.86%   +0.28%     
==========================================
  Files          14       14              
  Lines         720      721       +1     
  Branches      138      164      +26     
==========================================
+ Hits          681      684       +3     
+ Misses         39       37       -2     
Files with missing lines Coverage Δ
contracts/Nexus.sol 96.09% <100.00%> (+1.60%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 63a37aa...2cfa270. Read the comment docs.

Copy link

🤖 Slither Analysis Report 🔎

Slither report

# Slither report

THIS CHECKLIST IS NOT COMPLETE. Use --show-ignored-findings to show all the results.
Summary
🟡 - unused-return (1 results) (Medium)

unused-return

🟡 Impact: Medium
🟡 Confidence: Medium

base/ERC7739Validator.sol#L176-L206

constable-states

Impact: Optimization
🔴 Confidence: High

base/RegistryAdapter.sol#L10

factory/RegistryFactory.sol#L39

_This comment was automatically generated by the GitHub Actions workflow._

@livingrockrises livingrockrises merged commit 63f76d1 into dev Sep 23, 2024
8 checks passed
@livingrockrises livingrockrises deleted the fix/cantina-56 branch September 23, 2024 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants