T09 · Insecure Skill Coding Practices
- Location
scripts/password-gen.sh:36- Finding
Passphrases Generated from a Severely Undersized Fixed Dictionary
- Content
View full analysis
Vulnerability Details
File Location:
scripts/password-gen.sh, lines 36-40
Vulnerability Type: Weak credential generation
Risk Level: Highbash WORDS="apple banana cherry dragon eagle forest grape honey island jungle kiwi lemon mango night ocean peach queen river silver tiger umbrella violet water yellow zebra" PHRASE=$(echo "$WORDS" | tr ' ' '\n' | shuf -n "$LEN" | tr '\n' '-') echo "🔑 密码短语:${PHRASE%-}" echo "(由 $LEN 个常见单词组成,易记难破)"Technical Analysis
Passphrases are selected from a fixed, publicly visible dictionary containing only 25 words. Because
shuf -nsamples without replacement, a default four-word passphrase has only:log2(25 × 24 × 23 × 22) ≈ 18.6 bitsThis represents approximately 303,600 possible ordered four-word passphrases, which is far below an acceptable security level for passwords intended to resist offline or sustained online guessing.
The implementation also accepts arbitrary numeric values without enforcing a secure minimum. Requests exceeding 25 words silently produce no more than 25 words because the dictionary contains only 25 unique entries. Consequently, the generated output can differ from the requested length.
The script presents these phrases as difficult to crack, and the associated documentation describes the generator as producing high-strength passwords. These claims may cause users to rely on low-entropy credentials for sensitive authentication or encryption.
Attack Path
- An attacker determines or suspects that a target used this Skill's passphrase mode.
- The attacker extracts the 25-word dictionary from the publicly available script.
- The attacker generates all ordered combinations for the likely requested word count. For the documented four-word mode, there are approximately 303,600 candidates.
- The attacker tests the candidates against an authentication endpoint, captured password hash, encrypted archive, or othe ...[truncated 759 chars]
- Remediation
View remediation
Remediation Suggestions
- Replace the embedded 25-word dictionary with a vetted Diceware-style list containing at least 7,776 uniformly selectable entries.
- Generate at least six independently selected words for security-sensitive use. Six selections from a 7,776-word list provide approximately 77.5 bits of entropy.
- Select each word independently from cryptographically secure random bytes obtained from
/dev/urandom; repeated words should be permitted because independent sampling preserves the intended entropy model. - Avoid modulo bias when converting random bytes to dictionary indexes. Use rejection sampling or a well-reviewed password-generation library.
- Enforce a secure minimum word count and a reasonable maximum. Reject invalid or unsupported values with a nonzero exit status rather than silently changing the output.
- Verify that the generated phrase contains exactly the requested number of words.
- Document the approximate entropy associated with each supported word count and remove unsupported claims that the existing short phrases are difficult to crack.
- Add automated tests for minimum length validation, exact word count, dictionary membership, invalid arguments, and behavior at boundary values.
