Skip to content

Conversation

viktorking7
Copy link
Contributor

Description

Security Issue Fixed: Removed silent fallback to the well-known test mnemonic "test test test test test test test test test test test junk" when invalid word count is provided to --mnemonic-random.

Problem

When users specified an invalid word count (e.g., anvil --mnemonic-random 13), the code would silently fall back to DEFAULT_MNEMONIC, which is a publicly known test phrase. This created a security risk where users might unknowingly use predictable, insecure accounts.

Solution

  • Added warning logging when invalid word count is detected
  • Generate secure random 12-word mnemonic as fallback instead of using the test phrase
  • Preserve user intent of having a random mnemonic while ensuring security

Ok(mnemonic) => mnemonic.to_phrase(),
Err(_) => DEFAULT_MNEMONIC.to_string(),
Err(err) => {
warn!(target: "node", ?count, %err, "invalid mnemonic word count, falling back to 12-word random mnemonic");
Copy link
Contributor

Choose a reason for hiding this comment

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

this error message is not correct, it might also be that the word is not in the dictionary

viktorking7 and others added 2 commits September 15, 2025 14:02
Co-authored-by: onbjerg <onbjerg@users.noreply.github.com>
@viktorking7 viktorking7 requested a review from onbjerg September 15, 2025 12:05
@onbjerg onbjerg self-assigned this Sep 15, 2025
Copy link
Contributor

@onbjerg onbjerg left a comment

Choose a reason for hiding this comment

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

last stretch, please format the code using rustfmt :)

@viktorking7 viktorking7 requested a review from onbjerg September 15, 2025 13:44
@onbjerg onbjerg merged commit 6efb240 into foundry-rs:master Sep 15, 2025
25 checks passed
@github-project-automation github-project-automation bot moved this to Done in Foundry Sep 15, 2025
MerkleBoy pushed a commit to MerkleBoy/foundry that referenced this pull request Sep 17, 2025
…oundry-rs#11644)

* Update cmd.rs

* Update crates/anvil/src/cmd.rs

Co-authored-by: onbjerg <onbjerg@users.noreply.github.com>

* Update cmd.rs

* Update cmd.rs

---------

Co-authored-by: onbjerg <onbjerg@users.noreply.github.com>
@grandizzy grandizzy moved this from Done to Completed in Foundry Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

2 participants