Skip to content

[Opus 4.6 PR-1] Insecure Randomness in Token/Secret Generation (base.go)#121

Open
arunkoshy wants to merge 1 commit into
opencomputeproject:masterfrom
arunkoshy:claude-1
Open

[Opus 4.6 PR-1] Insecure Randomness in Token/Secret Generation (base.go)#121
arunkoshy wants to merge 1 commit into
opencomputeproject:masterfrom
arunkoshy:claude-1

Conversation

@arunkoshy

Copy link
Copy Markdown
Collaborator

Issue: rand.Seed(time.Now().UnixNano()) + math/rand is cryptographically insecure. Auth tokens, secret keys, and account validation links are all generated with predictable PRNG. An attacker who can approximate server start time can reproduce tokens. Fix: Replace math/rand with crypto/rand for all security-sensitive generation (GenerateAuthToken, GenerateAccountACKLink, randAlpha, randAlphaSlashPlus).
Race condition: randInit is read/written without synchronization across goroutines — itself a data race.
Test: Unit tests proving output entropy (no repeated values across 10k calls), and that crypto/rand is the source.

Issue: rand.Seed(time.Now().UnixNano()) + math/rand is
cryptographically insecure. Auth tokens, secret keys, and account
validation links are all generated with predictable PRNG. An attacker
who can approximate server start time can reproduce tokens.
Fix: Replace math/rand with crypto/rand for all security-sensitive
generation (GenerateAuthToken, GenerateAccountACKLink, randAlpha,
randAlphaSlashPlus).
Race condition: randInit is read/written without synchronization across
goroutines — itself a data race.
Test: Unit tests proving output entropy (no repeated values across 10k
calls), and that crypto/rand is the source.

Signed-off-by: Arun Koshy <arunkoshy@gmail.com>
@arunkoshy arunkoshy requested a review from vejmarie February 13, 2026 02:06
@arunkoshy arunkoshy self-assigned this Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant