CVE-2019-19794: Insecure generation of random numbers in github.com/miekg/dns

github.com/miekg/dns Updated 02 Oct 2025

Summary

14/04/2021
Yes i
Moderate
5.9

CVE-2019-19794: Insecure generation of random numbers in github.com/miekg/dns. Affects github.com/miekg/dns versions < 1.1.25-0.20191211073109-8ebf2e419df7. Fixed in 1.1.25-0.20191211073109-8ebf2e419df7. How to fix ↓

Also tracked for

The same CVE-2019-19794 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

The github.com/miekg/dns package is a Go library that provides DNS message handling functionality. It allows developers to create, parse, and manipulate DNS messages. The package is widely used in various Go applications for DNS-related tasks.

Vulnerability Detail

The vulnerability (CVE-2019-19794) in github.com/miekg/dns arises from the insecure generation of random numbers for DNS message transaction IDs. The package uses the math/rand library, which makes the transaction IDs relatively predictable. This weakness reduces the complexity of response spoofing attacks against DNS clients. An attacker could potentially exploit this vulnerability to manipulate DNS responses and deceive DNS clients.

How To Fix

Latest published version: v1.1.73 as of 23 Oct 2026

go get github.com/miekg/dns@v1.1.73

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

1.1.25-0.20191211073109-8ebf2e419df7

This is the first release that contains the fix.

go get github.com/miekg/dns@v1.1.25-0.20191211073109-8ebf2e419df7

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a workaround, developers can manually implement a secure random number generator using the crypto/rand library and replace the insecure random number generation in the affected code. Here's an example of how to generate a secure random number in Go:

import (
	"crypto/rand"
	"math/big"
)

func generateRandomNumber() (int, error) {
	randomNumber, err := rand.Int(rand.Reader, big.NewInt(65536))
	if err != nil {
		return 0, err
	}
	return int(randomNumber.Int64()), nil
}

Conclusion

In summary, the github.com/miekg/dns package is vulnerable to an insecure generation of random numbers for DNS message transaction IDs. This vulnerability reduces the complexity of response spoofing attacks against DNS clients. To mitigate the risk, developers should update their applications to use a secure random number generator, such as the one provided by the crypto/rand library in Go. For further support and assistance in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for github.com/miekg/dns →

Share this vulnerability

FAQ

This vulnerability reduces the complexity of response spoofing attacks against DNS clients. An attacker could potentially manipulate DNS responses and deceive DNS clients.

Versions 0.0.1 through 1.1.24 of github.com/miekg/dns are affected by this vulnerability.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability. Simply provide your Gopkg.lock file, and Vulert will analyze it for open-source vulnerabilities in real-time.

Yes, a fix is available for this vulnerability. Developers should update their applications to use a secure random number generator, such as the one provided by the crypto/rand library in Go.

You can find more information about this vulnerability, including its technical details and affected versions, in the vulnerability database entry at https://pkg.go.dev/vuln/GO-2020-0008.

Related vulnerabilities

Recent vulnerabilities recorded for github.com/miekg/dns.

How To Fix

Latest published version: v1.1.73 as of 23 Oct 2026

go get github.com/miekg/dns@v1.1.73

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

1.1.25-0.20191211073109-8ebf2e419df7

This is the first release that contains the fix.

go get github.com/miekg/dns@v1.1.25-0.20191211073109-8ebf2e419df7

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback