Skip to content

Commit 48189cb

Browse files
committed
🔒 Add Warning for delegatecalls
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
1 parent dd4e383 commit 48189cb

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

safe_hashes.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,21 @@ validate_nonce() {
425425
fi
426426
}
427427

428+
# Utility function to warn the user if the transaction includes a delegate call.
429+
warn_if_delegate_call() {
430+
local operation="$1"
431+
# Warn the user if `operation` equals `1`, implying a `delegatecall`.
432+
# See: https://github.com/safe-global/safe-smart-account/blob/34359e8305d618b7d74e39ed370a6b59ab14f827/contracts/libraries/Enum.sol.
433+
if [[ "$operation" -eq 1 ]]; then
434+
echo
435+
cat <<EOF
436+
${BOLD}${RED}WARNING: The transaction includes a delegate call!
437+
This may lead to unexpected behaviour or vulnerabilities.
438+
Please review it carefully before you sign!${RESET}
439+
EOF
440+
fi
441+
}
442+
428443
# Utility function to validate the message file.
429444
validate_message_file() {
430445
local message_file="$1"
@@ -606,6 +621,9 @@ EOF
606621
local nonce=$(echo "$response" | jq -r ".results[$idx].nonce // \"0\"")
607622
local data_decoded=$(echo "$response" | jq -r ".results[$idx].dataDecoded // \"0x\"")
608623

624+
# Warn the user if the transaction includes a delegate call.
625+
warn_if_delegate_call "$operation"
626+
609627
# Calculate and display the hashes.
610628
echo "==================================="
611629
echo "= Selected Network Configurations ="

0 commit comments

Comments
 (0)