CVE-2016-15005: Cryptographically weak random number generation in github.com/dinever/golf

github.com/dinever/golf Updated 02 Oct 2025

Summary

28/12/2022
Yes i
High
8.8

CVE-2016-15005: Golf may allow attacker to bypass CSRF protections due to weak PRNG. Affects github.com/dinever/golf versions < 0.3.0. Fixed in 0.3.0. How to fix ↓

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

github.com/dinever/golf is a Go package that provides a lightweight web framework for building web applications. It includes functionalities such as rendering templates, handling HTTP requests, and generating CSRF tokens for protection against cross-site request forgery (CSRF) attacks. However, the package uses the math/rand random number generator, which is not cryptographically secure.

Vulnerability Detail

The vulnerability (CVE-2016-15005) in github.com/dinever/golf arises from the use of the math/rand random number generator for generating CSRF tokens. This generator is not suitable for cryptographic purposes as it produces predictable and easily guessable values. An attacker can exploit this weakness by predicting the CSRF token values and bypassing the CSRF protection mechanism with a relatively small number of requests. This can lead to unauthorized actions being performed on behalf of the victim user, potentially compromising the security and integrity of the application.

How To Fix

Latest published version: v0.3.0 as of 23 Oct 2026

go get github.com/dinever/golf@v0.3.0

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

If you need the minimum change

0.3.0

This is the first release that contains the fix.

go get github.com/dinever/golf@v0.3.0

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

Workaround

As a temporary workaround, developers can manually replace the usage of the vulnerable random number generator in the codebase with a cryptographically secure alternative, such as crypto/rand. Here is an example of how the randomBytes function in github.com/dinever/golf can be modified:

Before:

github.com/dinever/golf.randomBytes = func(n int) []byte {
  b := make([]byte, n)
  for i := 0; i < n; i++ {
    b[i] = byte(rand.Int())
  }
  return b
}

After:

github.com/dinever/golf.randomBytes = func(n int) []byte {
  b := make([]byte, n)
  _, err := rand.Read(b)
  if err != nil {
    // Handle error
  }
  return b
}

Conclusion

In conclusion, the use of a cryptographically weak random number generator in github.com/dinever/golf for generating CSRF tokens poses a security risk. It is crucial to update the package to use a secure random number generator, such as crypto/rand, to mitigate the vulnerability. Developers should update to version 0.3.0 or higher of the package and follow the recommended steps to fix the vulnerability. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for github.com/dinever/golf →

Share this vulnerability

FAQ

The vulnerability allows an attacker to predict CSRF token values and bypass CSRF protections. This can lead to unauthorized actions being performed on behalf of users, potentially compromising the security and integrity of the application.

You can use the Vulert Playground at Vulert Scanner to check if your application is affected by this vulnerability. It analyzes your Gopkg.lock file and provides real-time alerts for open-source vulnerabilities, including this one.

Yes, a fix has been released in version 0.3.0 of github.com/dinever/golf. It is recommended to update to this version or higher to address the vulnerability.

Yes, a temporary workaround is to manually replace the usage of the vulnerable random number generator in the codebase with a cryptographically secure alternative, such as crypto/rand. Please refer to the 'workaround' section for more details.

This vulnerability was discovered by @elithrar.

How To Fix

Latest published version: v0.3.0 as of 23 Oct 2026

go get github.com/dinever/golf@v0.3.0

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

If you need the minimum change

0.3.0

This is the first release that contains the fix.

go get github.com/dinever/golf@v0.3.0

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