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

TOB-WORM-4: Panicking on invalid inputs in Solana contracts #1532

Open
tbjump opened this issue Sep 6, 2022 · 16 comments
Open

TOB-WORM-4: Panicking on invalid inputs in Solana contracts #1532

tbjump opened this issue Sep 6, 2022 · 16 comments

Comments

@tbjump
Copy link
Contributor

tbjump commented Sep 6, 2022

Severity: Informational

Description

In several places within the solana smart contracts, the code panics when an arithmetic overflow/underflow occurs. Panics should be reserved for programer errors, e.g., assertion violations. Panicking on user errors dilutes panics’ utility.

Exploit Scenario

Alice, a Wormhole developer, observes a panic in the Wormhole codebase. Alice ignores the panic believing it is caused by user error, but it is actually caused by a bug she introduced.

Recommendations

Short term, reserve panics for programmer errors. Return Result::Err for user errors. Adopting such a policy will help to distinguish the two types of errors when they occur.

Long term, consider denying the following Clippy lints:
● clippy::expect_used
● clippy::unwrap_used
● clippy::panic
Doing so will not prevent all panics, but it will prevent many of them.

@kii-dot
Copy link
Contributor

kii-dot commented Sep 23, 2022

Are there repro steps? Interested to take this on.

@tbjump
Copy link
Contributor Author

tbjump commented Sep 25, 2022

Hi, for more details please see the audit report from ToB, item TOB-WORM-4 https://storage.googleapis.com/wormhole-audits/Wormhole_Audit_Report_TrailOfBits_2022-09.pdf

@kii-dot
Copy link
Contributor

kii-dot commented Oct 2, 2022

When I'm building the solana package, I'm getting

error: environment variable `BRIDGE_ADDRESS` not defined
   --> bridge/program/src/accounts/posted_vaa.rs:102:46
    |
102 |         AccountOwner::Other(Pubkey::from_str(env!("BRIDGE_ADDRESS")).unwrap())
    |                                              ^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)

error: environment variable `EMITTER_ADDRESS` not defined
  --> bridge/program/src/api/governance.rs:47:28
   |
47 |     let expected_emitter = std::env!("EMITTER_ADDRESS");

Are there dummy address that I can use?

@kii-dot
Copy link
Contributor

kii-dot commented Oct 2, 2022

#1672

@kii-dot
Copy link
Contributor

kii-dot commented Oct 30, 2022

I believe this can be closed now since #1672 has been merged

@evan-gray
Copy link
Contributor

I think some of the cases in the cosmwasm token bridge may have been missed due to changes that occurred after you started your PR. Leaving this open until someone confirms. Feel free to take a look as well @kii-dot 🙂

@kii-dot
Copy link
Contributor

kii-dot commented Oct 30, 2022

sounds good. I'll work on that. If there are more rust work do tag me :) @evan-gray

@aadam-10 aadam-10 added temp and removed temp labels Nov 21, 2022
@tbjump
Copy link
Contributor Author

tbjump commented Nov 29, 2022

Hey @kii-dot @evan-gray,
are you still working on it?

For this issue to be considered fixed, the clippy lints should be enabled in CI. Anyone want to take a stab at that?

@kii-dot
Copy link
Contributor

kii-dot commented Nov 30, 2022

Since I've been working on it, let me take it up.

@kii-dot
Copy link
Contributor

kii-dot commented Dec 18, 2022

hey @tbjump @evan-gray Due to my schedule, I wont be able to attack this for the current time being. :(

@ameya-deshmukh
Copy link

@aadam-10 is this open to take up?

@aadam-10
Copy link
Contributor

aadam-10 commented May 2, 2023

hi @ameya-deshmukh, please feel free to take a shot at this.

@aadam-10
Copy link
Contributor

hi @ameya-deshmukh, do you have any updates on this?

@ameya-deshmukh
Copy link

Hey @aadam-10! Give me till the weekend to open a PR for this?

@aadam-10
Copy link
Contributor

hi @ameya-deshmukh, wondering if you'd had a chance to look into this. it's not urgent or anything, but someone else may want to pick it up.

@ameya-deshmukh
Copy link

hi @aadam-10 yes. I'm actually working on a related project being built on Wormhole and this is actually one of the few issues which seemed relevant to be solved. I'll be opening a PR soon. Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants