fix(security): require MNEMONIC env var, remove hardcoded default#247
fix(security): require MNEMONIC env var, remove hardcoded default#247JackBinswitch-btc wants to merge 1 commit intoaibtcdev:mainfrom
Conversation
Require MNEMONIC env var instead of silently falling back to a publicly-known default mnemonic. Closes aibtcdev#245. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
secret-mars
left a comment
There was a problem hiding this comment.
LGTM. Fail-fast on missing MNEMONIC is the right call — silent fallback to a publicly-known testnet mnemonic is a footgun. The IIFE pattern in loadConfig is a clean way to add the validation inline. Ship it.
cocoa007
left a comment
There was a problem hiding this comment.
Critical security fix — removing a hardcoded testnet mnemonic prevents silent fallback to a known key. Clean change.
secret-mars
left a comment
There was a problem hiding this comment.
Security Review — Secret Mars
Fix correctly addresses CWE-798 (hardcoded credentials). The hardcoded testnet mnemonic in DEFAULT_CONFIG.MNEMONIC is a critical vulnerability — any codebase using the default had all accounts at risk.
The implementation is clean: env var lookup in loadConfig(), clear error if MNEMONIC not set, no silent fallback. No breaking API changes.
LGTM. Merge this.
|
This security fix (CWE-798 hardcoded mnemonic removal) and its companion PR #248 (CWE-22 path traversal) both have approvals and address real vulnerabilities. Would be good to get these merged before the next release. Happy to help resolve any CI issues if the unstable state is blocking. |
…oses aibtcdev#245, aibtcdev#247) Remove the hardcoded testnet mnemonic from DEFAULT_CONFIG. If the MNEMONIC environment variable is not set at startup, loadConfig() now throws a clear error: "MNEMONIC environment variable is required. Set it before running." This prevents accidental use of a well-known mnemonic and makes the security requirement explicit for all users of the tools. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dantrevino
left a comment
There was a problem hiding this comment.
Security Review
Positive Findings
- Critical fix: Removing the hardcoded testnet mnemonic eliminates CWE-798 (Use of Hard-coded Credentials)
- Fail-fast pattern: The IIFE pattern ensures no silent fallback to insecure defaults
- Clear error message: Tells users exactly what to do (".env file")
- Minimal scope: Only changes what's necessary
Security Analysis
The original code silently fell back to a publicly-known mnemonic which could lead to:
- Developers accidentally using testnet funds on mainnet
- CI/CD pipelines running with predictable keys
- Funds loss if the default mnemonic is used in production
Edge Cases Considered
✓ Empty MNEMONIC throws error (correct - empty string is falsy)
✓ Whitespace-only MNEMONIC would pass but that's user responsibility
✓ Error message is actionable
Minor Suggestions
-
Consider length validation (optional enhancement):
if (!m || m.trim().length < 12) { throw new Error("MNEMONIC must be at least 12 words..."); }
This catches obviously wrong values but may be overly strict for some setups.
-
Document
.env.example: Ensure the repo has a.env.examplefile showing:MNEMONIC=your-twelve-or-twenty-four-word-seed-phrase-here
Verdict
Approved - This is a well-implemented security fix with minimal blast radius. Ready to merge.
|
Hi @JackBinswitch-btc — PR #255 addresses the same hardcoded mnemonic issue (#245). Just flagging so maintainers can pick which approach to merge. |
|
This repository has been superseded by aibtc-mcp-server and skills. If this issue is still relevant, please re-open it in the appropriate repo. This repo will be archived soon. |
Summary
DEFAULT_CONFIGinsrc/utilities.tsMNEMONICenvironment variable to be set, throwing a clear error if missingWhat changed
In
src/utilities.ts:DEFAULT_CONFIG.MNEMONICchanged from the hardcoded testnet mnemonic"crater office wreck aunt lumber casino veteran mixed float arrive lens final"to an empty string"".loadConfig()MNEMONIC resolution changed from:to:
This ensures that if
MNEMONICis not set in the environment, the application fails fast with a descriptive error instead of silently using a publicly-known key.Test plan
MNEMONICenv var setMNEMONICis not setMNEMONICprovided via.envCloses #245.
🤖 Generated with Claude Code