Skip to content

fix: reject integer parameters at or above 2^63 - #3650

Merged
JoannaaKL merged 3 commits into
mainfrom
joannaakl-fix-toint-int64-overflow
Nov 3, 2026
Merged

JoannaaKL merged 3 commits into
mainfrom
joannaakl-fix-toint-int64-overflow

Conversation

@JoannaaKL

Copy link
Copy Markdown
Collaborator

Summary

Integer parameter parsing now rejects values at or above 2^63. Before, they slipped past the range check and came out as MinInt (amd64) or MaxInt (arm64).

Why

math.MaxInt64 can't be represented as a float64 and rounds up to 2^63, so f > math.MaxInt lets 2^63 through. That includes "9223372036854775807". Go doesn't define the result of converting an out-of-range float to an int.
Fixes #3489

What changed

  • pkg/github/params.go: added an inSignedIntRange helper that checks against the exact 2^(n-1) bound before converting. toInt and toInt64 now use it; toInt64's old round-trip check also missed this case on arm64.
  • pkg/github/security_outputs.go, pkg/github/typed_read_normalizers.go: replaced the same broken check with the helper.
  • Boundary tests for the helper, OptionalIntParam, RequiredBigInt and both normalizers. The new rejection cases fail on main.

This covers both #3493 and #3565, and also fixes toInt64.

MCP impact

  • No tool or API changes
    Schemas are unchanged. Values ≥ 2^63 now return the existing range errors instead of being sent to the API.

Prompts tested (tool changes only)

  • N/A

Security / limits

  • No security or limits impact
    Input validation only.

Tool renaming

  • I am renaming tools as part of this PR (e.g. a part of a consolidation effort)
    • I have added the new tool aliases in deprecated_tool_aliases.go
  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with ./script/lint: passed, 0 issues (golangci-lint v2.14.0)
  • Tested locally with ./script/test: passed

Docs

  • Not needed
  • Updated (README / docs / examples)

math.MaxInt64 is not representable as a float64 and rounds up to 2^63, so
range checks against it let 2^63 through to an implementation-defined
float-to-int conversion (MinInt on amd64, MaxInt on arm64).

Add inSignedIntRange, which compares against the exact power-of-two bound
before converting, and use it in toInt, toInt64 and the security and
typed-read argument normalizers.

Fixes #3489
Copilot AI auto review requested due to automatic review settings November 2, 2026 10:24
@JoannaaKL
JoannaaKL requested a review from a team as a code owner November 2, 2026 10:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the integer-overflow validation changes.

No open issues 🎉

What changed in this PR

Fixes integer overflow validation in GitHub MCP Server parameter parsing, addressing #3489 and covering the fixes proposed in #3493 and #3565 without changing tool schemas.

Changes:

  • Adds a shared signed-integer range check using an exact, exclusive upper bound.
  • Applies the check before integer conversion in parameter parsers and both input normalizers.
  • Adds boundary tests for rejected overflow values and accepted limits.
File Description
pkg/​github/​typed_security_outputs_test.go Tests security argument overflow rejection and valid input.
pkg/​github/​typed_search_outputs_test.go Tests out-of-range pagination string rejection.
pkg/​github/​typed_read_normalizers.go Uses the shared range check for pagination string conversion.
pkg/​github/​security_outputs.go Uses the shared range check for security integer arguments.
pkg/​github/​params.go Adds the range helper and checks bounds before int and int64 conversion.
pkg/​github/​params_test.go Adds helper, optional integer, and required big-integer boundary tests.

Review effort: Balanced (auto)

@JoannaaKL
JoannaaKL merged commit 4f250f5 into main Nov 3, 2026
21 checks passed
@JoannaaKL
JoannaaKL deleted the joannaakl-fix-toint-int64-overflow branch November 3, 2026 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integer parameters equal to 2^63 pass the range check in toInt and wrap to a negative number

4 participants