fix(web): fail-fast on crypto/rand + drop bare auth-token log line#66
Merged
Merged
Conversation
Two web-server security hardening fixes from the 2026-06-11 audit,
bundled because they sit two lines apart and share one Start path.
- crypto/rand failure used to fall back to `time.Now().UnixNano()` for
the 16-byte session token. A nanosecond timestamp has ~30 bits of
entropy in the low-order bits and is bruteforceable in milliseconds
if an attacker knows roughly when the server started. Replace the
fallback with log.Fatalf so OS entropy starvation surfaces instead of
silently degrading to insecure tokens.
- The `log.Printf("[web] auth token: %s", token)` line duplicated the
token into log aggregators (Datadog/Splunk/syslog) at INFO level —
far wider read surface than the operator console. The URL line
immediately above already carries the token for operator discovery.
Drop the bare line.
New TestServer_Start_DoesNotLogBareAuthToken captures log output
during a Start/Shutdown cycle and asserts the `[web] auth token:`
prefix never appears.
Surfaced by the 2026-06-11 security audit (SEC-M1, SEC-M2).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two web-server security hardening fixes from the 2026-06-11 audit, bundled because they sit two lines apart in the same Start path.
rand.Readfell back totime.Now().UnixNano()for the 16-byte session token. A nanosecond timestamp has ~30 bits of entropy in the low-order bits and is bruteforceable in milliseconds if an attacker knows roughly when the server started. Replace withlog.Fatalfso OS entropy starvation surfaces instead of silently degrading.log.Printf("[web] auth token: %s", token)duplicated the token into any log aggregator (Datadog/Splunk/syslog) at INFO level — far wider read surface than the operator console. The URL line immediately above already carries the token for discovery. Drop the bare line.Test plan
TestServer_Start_DoesNotLogBareAuthTokencaptures log output during a Start/Shutdown cycle and asserts the[web] auth token:prefix never appears.go build ./...,go vet ./...,go test ./... -count=1 -timeout 240sall green locally.Audit traceability
Security findings SEC-M1, SEC-M2 (2026-06-11 sweep).