Skip to content

fix(workbench): avoid narrowing uint32 conversion in log index lookups - #1182

Merged
kyasbal merged 1 commit into
GoogleCloudPlatform:mainfrom
kyasbal:push-zyszwrozzozk
Oct 26, 2026
Merged

kyasbal merged 1 commit into
GoogleCloudPlatform:mainfrom
kyasbal:push-zyszwrozzozk

Conversation

@kyasbal

@kyasbal kyasbal commented Oct 26, 2026

Copy link
Copy Markdown
Member

Summary

Resolves the CodeQL go/incorrect-integer-conversion security alert introduced in #1177 when looking up workbench log entries by 1-based uint32 log IDs parsed from external tool inputs.

Converting a uint32 log ID directly to signed int before bounds-checking against slice lengths (int(id) > len(...) and int(logID)+1 >= len(...)) narrows the unsigned 32-bit range on 32-bit int platforms, allowing values above math.MaxInt32 to wrap negative and bypass the upper-bound check. Performing the slice-length bounds comparisons in uint64 width eliminates the narrowing conversion and prevents signed overflow.

@kyasbal kyasbal added type:bug Something isn't working as expected area:backend-core Core backend frameworks, DAG task runner, and server API labels Oct 26, 2026

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request prevents potential signed integer overflow issues when querying logs and timeline IDs with large uint32 values. Specifically, in GetLog and GetTimelineIDs, index bounds checks are updated to cast values to uint64 instead of int. Additionally, unit tests are added and updated to verify correct behavior with boundary values such as MaxInt32 + 1 and MaxUint32. I have no feedback to provide.

@kyasbal
kyasbal enabled auto-merge October 26, 2026 04:22
@kyasbal
kyasbal added this pull request to the merge queue Oct 26, 2026
Merged via the queue into GoogleCloudPlatform:main with commit 66d5a5d Oct 26, 2026
17 checks passed
@kyasbal
kyasbal deleted the push-zyszwrozzozk branch October 26, 2026 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend-core Core backend frameworks, DAG task runner, and server API type:bug Something isn't working as expected

1 participant