Skip to content

crypto/rand.Read error silently suppressed (serversInfo.go) #3212

Description

@hklcf

Bug Description

In serversInfo.go, the error from crypto/rand.Read is silently discarded when generating random padding for test probe packets. If crypto/rand.Read fails (possible on certain platforms like containers with limited entropy), paddingData remains all zeros, weakening the DNS query size obfuscation.

Affected Code

serversInfo.go:867 and serversInfo.go:888:

paddingData := make([]byte, 16)
_, _ = crypto_rand.Read(paddingData)  // error silently ignored

Impact

Weakens EDNS0 padding protection. While crypto/rand.Read rarely fails on typical systems, silently suppressing errors in a security-critical DNS proxy violates defense-in-depth principles.

Fix

Log the error:

if _, err := crypto_rand.Read(paddingData); err != nil {
    dlog.Warnf("Failed to read random padding: %v", err)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions