-
Notifications
You must be signed in to change notification settings - Fork 13
Fix unauthorized access #118
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
pragma solidity >=0.7.0 <0.9.0; | ||
pragma abicoder v2; | ||
|
||
import {HandlerContext} from "safe-contracts/contracts/handler/HandlerContext.sol"; | ||
|
||
import {BaseAccount} from "account-abstraction/contracts/core/BaseAccount.sol"; | ||
import {IEntryPoint, UserOperation} from "account-abstraction/contracts/interfaces/IEntryPoint.sol"; | ||
import {BLS} from "account-abstraction/contracts/samples/bls/lib/hubble-contracts/contracts/libs/BLS.sol"; | ||
|
@@ -19,7 +21,7 @@ interface ISafe { | |
|
||
error IncorrectSignatureLength(uint256 length); | ||
|
||
contract SafeBlsPlugin is BaseAccount { | ||
contract SafeBlsPlugin is BaseAccount, HandlerContext { | ||
// TODO: Use EIP 712 for domain separation | ||
bytes32 public constant BLS_DOMAIN = keccak256("eip4337.bls.domain"); | ||
address public immutable myAddress; | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 I think the original source of using |
||
ISafe safe = ISafe(safeAddress); | ||
require( | ||
|
@@ -124,4 +126,12 @@ contract SafeBlsPlugin is BaseAccount { | |
); | ||
} | ||
} | ||
|
||
modifier fromThisOrEntryPoint() { | ||
require( | ||
_msgSender() == address(this) || | ||
_msgSender() == _entryPoint | ||
); | ||
_; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the virtual function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah probably. I'd suggest we make something like 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? |
||
} |
There was a problem hiding this comment.
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 allowthis
? (The safe can call its functionexecTransactionFromModule
directly if needed)There was a problem hiding this comment.
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.