You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
math/big: ProbablyPrime skips Miller–Rabin rounds when n is MaxInt #81491
(*Int).ProbablyPrime(math.MaxInt) overflows the Miller–Rabin round count and skips that test entirely. As a result, it reports the composite integer 10877 as probably prime, contrary to the documented accuracy for inputs below 2^64.
In src/math/big/prime.go, ProbablyPrime passes n+1 to probablyPrimeMillerRabin. For n == math.MaxInt, this becomes a negative int; the helper’s for i := 0; i < reps; i++ loop executes no rounds and returns true. Only the Lucas test remains after the earlier filters.
This issue was found by zkao and was triaged by @FiloSottile as a valid bug but not a vulnerability. /cc @golang/security
Activity
gabyhelp commentedon Sep 13, 2026
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
math/big: cover ProbablyPrime round-count boundaries
gopherbot commentedon Sep 17, 2026
Change https://go.dev/cl/834124 mentions this issue:
math/big: avoid overflow in ProbablyPrime round countcherrymui commentedon Sep 18, 2026
cc @griesemer @thatnealpatel @golang/security
math/big: cover ProbablyPrime round-count boundaries