T09 · Insecure Skill Coding Practices
Warning
- Location
scripts/passgen.py:100- Finding
Entropy Estimates Include Deterministic Characters and Overstate Credential Strength
- Content
View full analysis
0 else 0 ``` ```python if args.entropy: ent = calc_entropy(result, charset) print(f"{result} (entropy: {ent:.1f} bits)") ``` ### Technical Analysis The entropy calculation assumes that every character in the final output is an independent, uniformly random choice from the specified character set. That assumption is valid for ordinary passwords and PINs generated character by character, but it is invalid for several supported output types. For passphrases, randomness comes from each selected word, not from each character in the resulting phrase. Word lengths and separators do not add entropy. The correct estimate is: ```text word_count × log2(number_of_words_in_wordlist) ``` For API keys, the fixed prefix and underscore are deterministic. Only the 32 random bytes generated by `secrets.token_hex(32)` contribute entropy, giving exactly 256 bits. The current calculation includes the fixed prefix and separator and therefore reports more than 256 bits for the default key. For URL-safe base64, 32 random bytes contain exactly 256 bits. The output has 43 unpadded base64 characters, and the current calculation reports `43 × 6 = 258` bits even though encoding cannot increase the source entropy. Consequently, the `--entropy` output can misrepresent the actual security strength of generated credentials. The passphrase entropy claim in `SKILL.md` is affected by the same conceptual issue. ### Attack Path 1. A user or automated system invokes the generator with `--entropy`, such as: ```bash python3 scripts/passgen.py --type passphrase --words 5 --entropy ``` ...[truncated 1259 chars]- Remediation
View remediation
