Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show warning if using msg.sender or tx.origin in script without CLI flags being set #4317

Open
devanoneth opened this issue Feb 9, 2023 · 3 comments
Labels
C-forge Command: forge Cmd-forge-script Command: forge script P-normal Priority: normal T-feature Type: feature

Comments

@devanoneth
Copy link
Contributor

Component

Forge

Describe the feature you would like

Issue created after this discussion with @mds1 in the TG group: https://t.me/foundry_support/32128

If msg.sender and/or tx.origin are the defaults AND we find the CALLER or ORIGIN opcodes in the script's method being executed THEN log a warning and require the developer to confirm they want the script to run anyway.

If the sender and/or origin are not specified in the CLI but are used in the script, unintended addresses may be passed to other contracts resulting in unwanted outcomes e.g. a Uniswap output going to the wrong address.

In the warning they should instead be advised to use an address that they know e.g. the same address they are broadcasting with.

Additional context

No response

@devanoneth devanoneth added the T-feature Type: feature label Feb 9, 2023
@gakonst gakonst added this to Foundry Feb 9, 2023
@github-project-automation github-project-automation bot moved this to Todo in Foundry Feb 9, 2023
@zerosnacks zerosnacks added Cmd-forge-script Command: forge script C-forge Command: forge labels Jun 28, 2024
@zerosnacks
Copy link
Member

Ran into this before myself, in favor of adding this!

@zerosnacks zerosnacks added this to the v1.0.0 milestone Jul 26, 2024
@grandizzy
Copy link
Collaborator

@devanoneth there's a check added with #7141

if required_addresses.contains(&Config::DEFAULT_SENDER) {
eyre::bail!(
"You seem to be using Foundry's default sender. Be sure to set your own --sender."
);
}

Could you please check if the scenarios (tx.origin) you're using are covered? thank you!

@grandizzy
Copy link
Collaborator

@klkvr I think this one is already implemented, maybe missing for tx.origin, can you pls chime in? thanks!

@grandizzy grandizzy added the P-normal Priority: normal label Nov 21, 2024
@grandizzy grandizzy removed this from the v1.0.0 milestone Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-script Command: forge script P-normal Priority: normal T-feature Type: feature
Projects
Archived in project
Development

No branches or pull requests

3 participants