Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/base/ERC20Base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ contract ERC20Base is ContractMetadata, Multicall, Ownable, ERC20Permit, IMintab
}

/// @notice Returns the sender in the given execution context.
function _msgSender() internal view override(Multicall, Context) returns (address) {
function _msgSender() internal view virtual override(Multicall, Context) returns (address) {
return msg.sender;
}
}
2 changes: 1 addition & 1 deletion contracts/base/ERC20Drop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ contract ERC20Drop is ContractMetadata, Multicall, Ownable, ERC20Permit, Primary
}

/// @notice Returns the sender in the given execution context.
function _msgSender() internal view override(Multicall, Context) returns (address) {
function _msgSender() internal view virtual override(Multicall, Context) returns (address) {
return msg.sender;
}
}
2 changes: 1 addition & 1 deletion contracts/base/ERC20DropVote.sol
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ contract ERC20DropVote is ContractMetadata, Multicall, Ownable, ERC20Votes, Prim
}

/// @notice Returns the sender in the given execution context.
function _msgSender() internal view override(Multicall, Context) returns (address) {
function _msgSender() internal view virtual override(Multicall, Context) returns (address) {
return msg.sender;
}
}
20 changes: 10 additions & 10 deletions contracts/base/ERC20Vote.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ contract ERC20Vote is ContractMetadata, Multicall, Ownable, ERC20Votes, IMintabl
*/
function burn(uint256 _amount) external virtual {
require(balanceOf(_msgSender()) >= _amount, "not enough balance");
_burn(msg.sender, _amount);
_burn(_msgSender(), _amount);
}

/**
Expand All @@ -74,9 +74,9 @@ contract ERC20Vote is ContractMetadata, Multicall, Ownable, ERC20Votes, IMintabl
function burnFrom(address _account, uint256 _amount) external virtual override {
require(_canBurn(), "Not authorized to burn.");
require(balanceOf(_account) >= _amount, "not enough balance");
uint256 decreasedAllowance = allowance(_account, msg.sender) - _amount;
_approve(_account, msg.sender, 0);
_approve(_account, msg.sender, decreasedAllowance);
uint256 decreasedAllowance = allowance(_account, _msgSender()) - _amount;
_approve(_account, _msgSender(), 0);
_approve(_account, _msgSender(), decreasedAllowance);
_burn(_account, _amount);
}

Expand All @@ -86,26 +86,26 @@ contract ERC20Vote is ContractMetadata, Multicall, Ownable, ERC20Votes, IMintabl

/// @dev Returns whether contract metadata can be set in the given execution context.
function _canSetContractURI() internal view virtual override returns (bool) {
return msg.sender == owner();
return _msgSender() == owner();
}

/// @dev Returns whether tokens can be minted in the given execution context.
function _canMint() internal view virtual returns (bool) {
return msg.sender == owner();
return _msgSender() == owner();
}

/// @dev Returns whether tokens can be burned in the given execution context.
function _canBurn() internal view virtual returns (bool) {
return msg.sender == owner();
return _msgSender() == owner();
}

/// @dev Returns whether owner can be set in the given execution context.
function _canSetOwner() internal view virtual override returns (bool) {
return msg.sender == owner();
return _msgSender() == owner();
}

/// @notice Returns the sender in the given execution context.
function _msgSender() internal view override(Multicall, Context) returns (address) {
return msg.sender;
function _msgSender() internal view virtual override(Multicall, Context) returns (address) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Unify sender source in burn now that _msgSender() is overridable.

With this change, derived contracts can override _msgSender(), but burn still mixes sender sources: it checks balanceOf(_msgSender()) (Line 63) and burns msg.sender (Line 64). That can revert incorrectly or burn against the wrong caller context in meta-transaction-style overrides.

Proposed fix
 function burn(uint256 _amount) external virtual {
-    require(balanceOf(_msgSender()) >= _amount, "not enough balance");
-    _burn(msg.sender, _amount);
+    address sender = _msgSender();
+    require(balanceOf(sender) >= _amount, "not enough balance");
+    _burn(sender, _amount);
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@contracts/base/ERC20Vote.sol` at line 108, The burn function mixes raw
msg.sender with the overridable _msgSender(), which can cause wrong-account
burns under meta-transaction overrides; update burn to consistently use
_msgSender() for both the balance check and the actual burn operation (ensure
calls to balanceOf(...) and the internal _burn(...) or transfer logic use
_msgSender()), so the sender source is unified with the overrideable
_msgSender() implementation.

return _msgSender();
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
}
}
2 changes: 1 addition & 1 deletion contracts/base/ERC721Base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ contract ERC721Base is ERC721AQueryable, ContractMetadata, Multicall, Ownable, R
}

/// @notice Returns the sender in the given execution context.
function _msgSender() internal view override(Multicall, Context) returns (address) {
function _msgSender() internal view virtual override(Multicall, Context) returns (address) {
return msg.sender;
}
}
2 changes: 1 addition & 1 deletion contracts/base/ERC721Drop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ contract ERC721Drop is
}

/// @notice Returns the sender in the given execution context.
function _msgSender() internal view override(Multicall, Context) returns (address) {
function _msgSender() internal view virtual override(Multicall, Context) returns (address) {
return msg.sender;
}
}
2 changes: 1 addition & 1 deletion contracts/base/ERC721LazyMint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ contract ERC721LazyMint is
}

/// @notice Returns the sender in the given execution context.
function _msgSender() internal view override(Multicall, Context) returns (address) {
function _msgSender() internal view virtual override(Multicall, Context) returns (address) {
return msg.sender;
}
}
2 changes: 1 addition & 1 deletion contracts/base/ERC721Multiwrap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ contract ERC721Multiwrap is
}

/// @notice Returns the sender in the given execution context.
function _msgSender() internal view override(Multicall, Context) returns (address) {
function _msgSender() internal view virtual override(Multicall, Context) returns (address) {
return msg.sender;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ contract TWMultichainRegistryRouter is PermissionsEnumerableLogic, ERC2771Contex
return hasRole(DEFAULT_ADMIN_ROLE, _msgSender());
}

function _msgSender() internal view override(ERC2771ContextLogic, PermissionsLogic, Multicall) returns (address) {
function _msgSender() internal view virtual override(ERC2771ContextLogic, PermissionsLogic, Multicall) returns (address) {
return ERC2771ContextLogic._msgSender();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ contract DynamicAccountFactory is BaseAccountFactory, ContractMetadata, Permissi
}

/// @notice Returns the sender in the given execution context.
function _msgSender() internal view override(Multicall, Permissions) returns (address) {
function _msgSender() internal view virtual override(Multicall, Permissions) returns (address) {
return msg.sender;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ contract ManagedAccountFactory is BaseAccountFactory, ContractMetadata, Permissi
}

/// @notice Returns the sender in the given execution context.
function _msgSender() internal view override(Multicall, Permissions) returns (address) {
function _msgSender() internal view virtual override(Multicall, Permissions) returns (address) {
return msg.sender;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ contract AccountFactory is BaseAccountFactory, ContractMetadata, PermissionsEnum
}

/// @notice Returns the sender in the given execution context.
function _msgSender() internal view override(Multicall, Permissions) returns (address) {
function _msgSender() internal view virtual override(Multicall, Permissions) returns (address) {
return msg.sender;
}
}