Skip to content

fix(aptos): range-check generic type index in proto conversion [PLEX-2890]#2016

Open
Fletch153 wants to merge 1 commit intomainfrom
fletch/PLEX-2890-aptos-generic-index-overflow
Open

fix(aptos): range-check generic type index in proto conversion [PLEX-2890]#2016
Fletch153 wants to merge 1 commit intomainfrom
fletch/PLEX-2890-aptos-generic-index-overflow

Conversation

@Fletch153
Copy link
Copy Markdown
Contributor

@Fletch153 Fletch153 commented Apr 30, 2026

Summary

  • ConvertTypeTagFromProto cast genericValue.Index (uint32) directly to uint16, silently truncating values above math.MaxUint16 and causing a request to be interpreted as a different type parameter.
  • Add an explicit range check that returns an error on overflow, matching the existing guard in typeTagFromCapability on the public Aptos View capability path.
  • Adds tests for the boundary value (math.MaxUint16 accepted), overflow rejection, and missing generic value.

Jira: PLEX-2890

Test plan

  • go test ./pkg/chains/aptos/...
  • go vet ./pkg/chains/aptos/...
  • New tests cover boundary, overflow, and nil-generic cases

…2890]

The proto schema defines `GenericTag.index` as `uint32` but the Go domain
type stores it as `uint16`. `ConvertTypeTagFromProto` previously cast
directly with `uint16(genericValue.Index)`, silently truncating any
value above `math.MaxUint16` and causing a request to be interpreted
as a different type parameter than the one supplied.

Reject indices greater than `math.MaxUint16` at the proto-helper
boundary, matching the existing check in `typeTagFromCapability` on
the public Aptos View capability path.
@Fletch153 Fletch153 requested a review from a team as a code owner April 30, 2026 10:54
@github-actions
Copy link
Copy Markdown

👋 Fletch153, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

@github-actions
Copy link
Copy Markdown

⚠️ API Diff Results - github.com/smartcontractkit/chainlink-common

⚠️ Breaking Changes (1)

pkg/settings/cresettings.Workflows (1)
  • FeatureEVMWriteReportL1FeeActivePeriod — 🗑️ Removed

📄 View full apidiff report

@Fletch153 Fletch153 changed the base branch from main to bugfix/audit_db April 30, 2026 11:15
@Fletch153 Fletch153 requested review from a team as code owners April 30, 2026 11:15
@Fletch153 Fletch153 requested review from asoliman92, b-gopalswami, carte7000, makramkd, matYang, ogtownsend and winder and removed request for a team April 30, 2026 11:15
@yashnevatia yashnevatia changed the base branch from bugfix/audit_db to main May 1, 2026 07:59
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.

2 participants