Prevent huge timeout literals from stalling reliability scans - #150
Merged
alxxjohn merged 1 commit intoAug 19, 2026
Merged
Conversation
alxxjohn
deleted the
alexj/propose-fix-for-denial-of-service-vulnerability
branch
August 19, 2026 22:39
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.
Motivation
math/big.Intparsing of repository-controlled integer literals used to detect zerohttp.Client.Timeout, which can be maliciously large and cause CPU denial-of-service during scanning.Description
big.Intparse inisZeroDurationwith a lexical check via a new helperisZeroIntegerLiteral, and remove themath/bigdependency frominternal/codeguard/checks/reliability/reliability_go_helpers.go.isZeroIntegerLiteralhandles Go integer literal formats (decimal, binary0b, octal0o, hex0x, and underscores) by scanning characters for any nonzero digit and returnstrueonly for literals that are lexically zero.internal/codeguard/checks/reliability/reliability_go_helpers_test.gowith unit tests covering zero/nonzero literals across bases and a regression test exercising a multi-million-digit untrusted literal to ensure the function completes quickly.gofmtto the modified files.Testing
go test ./internal/codeguard/checks/reliabilityand the package tests passed.go test ./tests/checksand the integration tests passed.go test ./...and the full test suite completed successfully.Codex Task