Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Fix unauthorized access #118

Merged
merged 4 commits into from
Oct 12, 2023
Merged

Fix unauthorized access #118

merged 4 commits into from
Oct 12, 2023

Conversation

voltrevo
Copy link
Contributor

Resolves #89 by using HandlerContext to access _msgSender() and check that it's this or the entry point.

@voltrevo voltrevo mentioned this pull request Oct 11, 2023
_msgSender() == _entryPoint
);
_;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the virtual function _requireFromEntryPoint(...) in BaseAccount be overridden (to use _msgSender())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah probably. I'd suggest we make something like Safe4337Base we can inherit from, which uses BaseAccount and HandlerContext and implement this override.

I'm wary of inheritance in general though. I've always avoided it. However, it seems popular in the smart contracts we're working with, so I'm inclined to lean into it for now. Wdyt?

@@ -50,7 +52,7 @@ contract SafeBlsPlugin is BaseAccount {
address to,
uint256 value,
bytes calldata data
) external payable {
) external payable fromThisOrEntryPoint {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does execTransaction need to allow this? (The safe can call its function execTransactionFromModule directly if needed)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I think I was just a bit hazy on that when I originally wrote this code. Will update.

@@ -50,7 +52,7 @@ contract SafeBlsPlugin is BaseAccount {
address to,
uint256 value,
bytes calldata data
) external payable {
) external payable fromThisOrEntryPoint {
address payable safeAddress = payable(msg.sender);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is msg.sender always going to be the safe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I'm not sure. I think yes if the function is always executed via safe's module system. The msg.sender here is not part of the changes in this PR, but it looks wrong to me too.

I think the original source of using msg.sender here is safe's 4337 example. I opened a PR over there to change it to use this, curious to see what they say: safe-global/safe-smart-account#682.

@voltrevo voltrevo merged commit 45c815d into main Oct 12, 2023
2 checks passed
@voltrevo voltrevo deleted the wax-89-fix-unauthorized-access branch October 12, 2023 23:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix unauthorized access
2 participants