Skip to content

Commit

Permalink
🔒 Amend Security Note in Multicall Contract (#193)
Browse files Browse the repository at this point in the history
Signed-off-by: Pascal Marco Caversaccio <[email protected]>
  • Loading branch information
pcaversaccio authored Dec 19, 2023
1 parent ad6a2ba commit 2294f90
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 113 deletions.
206 changes: 103 additions & 103 deletions .gas-snapshot

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ jobs:
test/**/*.sol test/**/interfaces/*.sol test/**/mocks/*.sol \
test/**/scripts/*.js scripts/*.py --allow-dupe --allow-redirect \
--request-delay 0.4 \
--white-list https://www.wagmi.xyz,https://twitter.com/0xDACA/status/1669846430528286722,https://github.com/pcaversaccio/snekmate/releases/tag/v0.0.5,https://github.com/pcaversaccio/snekmate/blob/v0.0.5,https://github.com/pcaversaccio/snekmate/compare/v0.0.4...v0.0.5
--white-list https://www.wagmi.xyz,https://twitter.com,https://github.com/pcaversaccio/snekmate/releases/tag/v0.0.5,https://github.com/pcaversaccio/snekmate/blob/v0.0.5,https://github.com/pcaversaccio/snekmate/compare/v0.0.4...v0.0.5
2 changes: 1 addition & 1 deletion lib/create-util
2 changes: 1 addition & 1 deletion lib/openzeppelin-contracts
2 changes: 1 addition & 1 deletion lib/solady
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions src/utils/Multicall.vy
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@
https://github.com/pcaversaccio/snekmate/discussions/82.
The implementation is inspired by Matt Solomon's implementation here:
https://github.com/mds1/multicall/blob/main/src/Multicall3.sol.
@custom:security Make sure you understand how `msg.sender` works in `CALL` vs
`DELEGATECALL` to the multicall contract, as well as the risks
of using `msg.value` in a multicall. To learn more about the latter, see:
@custom:security You must ensure that any contract that integrates the `CALL`-based
`multicall` and `multicall_value` functions never holds funds after
the end of a transaction. Otherwise, any ETH, tokens, or other funds
held by this contract can be stolen. Also, never approve a contract
that integrates the `CALL`-based functions `multicall` and `multicall_value`
to spend your tokens. If you do, anyone can steal your tokens! Eventually,
please make sure you understand how `msg.sender` works in `CALL` vs
`DELEGATECALL` to the multicall contract, as well as the risks of
using `msg.value` in a multicall. To learn more about the latter, see:
- https://github.com/runtimeverification/verified-smart-contracts/wiki/List-of-Security-Vulnerabilities#payable-multicall,
- https://samczsun.com/two-rights-might-make-a-wrong.
"""
Expand Down Expand Up @@ -108,6 +114,11 @@ def multicall_value(data: DynArray[BatchValue, max_value(uint8)]) -> DynArray[Re
success: bool = empty(bool)
for batch in data:
msg_value: uint256 = batch.value
# WARNING: If you expect to hold any funds in a contract that integrates
# this function, you must ensure that the next line uses checked arithmetic!
# Please read the contract-level security notice carefully. For further
# insights also, see the following Twitter thread:
# https://twitter.com/Guhu95/status/1736983530343981307.
value_accumulator = unsafe_add(value_accumulator, msg_value)
if (batch.allow_failure == False):
return_data = raw_call(batch.target, batch.call_data, max_outsize=255, value=msg_value)
Expand Down

0 comments on commit 2294f90

Please sign in to comment.