relayer: AccountTransactions forwards an unvalidated Limit into aptos-go-sdk — Start != nil with a large Limit panics the plugin process
メンテナーはふだん 11 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 76/100
調査の方向性
relayer/aptos_service.go の 142-161 行目付近を読んでください。Limit == 0 のチェックはそこにあり、Start/Limit はそのまま client.AccountTransactions に渡されます。codes.InvalidArgument を返す上限を追加し、capabilities/fakes/aptos_chain.go の 252 行目付近にも同様に反映し、報告されたリグレッションテストをパッケージ relayer に追加して、makeslice のパニックと送信 RPC がゼロであることを検証するようにしてください。go test ./relayer/... を実行してください。完了とは、過大な上限のテストが通り、プロセスのパニックが発生しないことを意味します。
索引モデルが issue の本文から書いたものです。
説明
relayer: AccountTransactions forwards an unvalidated Limit into aptos-go-sdk — Start != nil with a large Limit panics the plugin process
Summary
aptosService.AccountTransactions (relayer/aptos_service.go:142) validates only
*req.Limit == 0 (:156) and forwards the caller-supplied Start/Limit verbatim to
aptos-go-sdk (client.AccountTransactions(sdkAddr, req.Start, req.Limit), :161).
When Start != nil, the SDK's transactionsConcurrent computes
numChannels = limit / 100 and executes
make([]chan ConcResponse[[]*api.CommittedTransaction], numChannels)
(aptos-go-sdk nodeClient.go:719/725) before issuing any RPC. With
Start = 0, Limit = 2^64-1 this is make(..., 184467440737095517) →
runtime error: makeslice: len out of range.
The relayer's LOOP gRPC server has no panic-recovery interceptor (the interceptors
installed by chainlink-common pkg/loop/telem.go are the CRE context pass-through
and Prometheus metrics), so the panic terminates the whole chainlink-aptos plugin
process rather than surfacing as a gRPC error.
Nothing in-tree currently forwards an unbounded Limit (see Current exposure), so
this is hardening ahead of the read capability becoming real — but the entire plumbing
(proto Limit *uint64, LOOP relayer service, aptosServer.AccountTransactions) is
already wired, and the Start != nil path has never been clamped: the
accountTransactionsWindow helper removed in #607 explicitly early-returned for
start != nil, so #607 neither introduced nor fixed this branch.
Repro
In-tree test at c0b9fb2 with aptos-go-sdk v1.14.0 (package relayer; the HTTP stub
only counts outbound requests):
func TestAccountTransactionsLargeLimitPanicsBeforeAnyRPC(t *testing.T) {
var reqs int64
srv := fakeFullnode(t, &reqs) // httptest server counting requests
svc := newService(t, srv.URL) // real aptosService over a real *aptos_sdk.NodeClient
var addr aptos.AccountAddress
addr[31] = 0xEE
start, limit := uint64(0), uint64(math.MaxUint64)
var recovered any
func() {
defer func() { recovered = recover() }()
_, _ = svc.AccountTransactions(context.Background(), aptos.AccountTransactionsRequest{
Address: addr, Start: &start, Limit: &limit,
})
}()
require.Contains(t, fmt.Sprint(recovered), "makeslice: len out of range")
require.Zero(t, atomic.LoadInt64(&reqs)) // zero outbound RPCs
}
End-to-end against the real binary (built with go build ./cmd/chainlink-aptos,
spawned via hashicorp/go-plugin with the standard relayer handshake, real NewRelayer
factory RPC, then one relayer.Aptos().AccountTransactions(start=0, limit=2^64-1) gRPC
call):
[INFO] chainlink-aptos-plugin: AccountTransactions: called: ... hasStart=true hasLimit=true
[ERROR] chainlink-aptos-plugin: panic: runtime error: makeslice: len out of range
[ERROR] plugin process exited: ... error="exit status 2"
[DEBUG] stdio: received EOF ... err="rpc error: code = Unavailable desc = error reading from server: EOF"
PLUGIN_EXITED=true
FULLNODE_REQS=0
Panic stack: grpc.Server.processRPC → _Aptos_AccountTransactions_Handler → aptosServer.AccountTransactions (chainlink-common pkg/loop/internal/relayer/aptos.go:180) → relayer.(*aptosService).AccountTransactions (relayer/aptos_service.go:161) → ratelimit.rateLimitedClient → aptos-go-sdk AccountTransactions → handleTransactions → transactionsConcurrent → make([]chan …) nodeClient.go:725 — no recover() anywhere
on that chain.
Negative control: same harness with Limit = 100 — process stays alive, 1 outbound
RPC, follow-up RPC succeeds. The kill is caused by the Limit value alone.
Sub-panic values are also a fan-out amplifier: Limit = 500_000 from one call spawned
limit/100 = 5_000 goroutines + queued RPCs (measured peak 10,794 goroutines vs a
baseline of 3).
The Start == nil branch is not crash-reachable today: the SDK first issues a probe
request carrying the raw limit, and a stock fullnode declares limit as Option<u16>
(aptos-core/api/src/page.rs), so Limit > 65535 fails fast with a parse error
(verified). Only the Start != nil branch reaches transactionsConcurrent directly.
Current exposure
- In-tree callers of the handler use fixed, bounded page sizes: LogPoller
(relayer/logpoller/tx_poller.go, internalbatchSize) and the forwarder tx-search. - The workflow-facing
aptos.AccountTransactionschain-read capability is currently
unimplementedinsmartcontractkit/capabilities
(chain_capabilities/aptos/actions/actions.go), so no workflow reaches this handler
through the capability path today. - The LOOP plugin gRPC surface is local to the node host process.
So today this is a robustness/hardening gap, not a live crash. The concern is that the
read plumbing is fully wired end-to-end — a future implementation of the aptos
chain-read capability (or any new internal caller that forwards a request-derived
Limit) lights this up immediately.
Suggested fix
Bound Limit in the handler before it reaches the SDK, on both branches, returning
InvalidArgument rather than clamping silently (consistent with the existing View
error handling):
const maxAccountTransactionsLimit = 10_000 // or fullnode max page-size × N
if req.Limit != nil {
if *req.Limit == 0 {
return &commonaptos.AccountTransactionsReply{}, nil
}
if *req.Limit > maxAccountTransactionsLimit {
return nil, status.Errorf(codes.InvalidArgument,
"limit %d exceeds maximum %d", *req.Limit, maxAccountTransactionsLimit)
}
}
The same bound should be applied to the capability-path fake at
capabilities/fakes/aptos_chain.go:252, which forwards input.Limit unbounded and
implements the same interface.
Independently, aptos-go-sdk's transactionsConcurrent derives its channel-slice size
purely from the caller's limit with no ceiling (numChannels = limit / 100 at
nodeClient.go:719, unchanged on current main) — every consumer of the SDK inherits
that; a cap there (plus bounding in-flight fan-out) would be defense-in-depth worth
filing upstream with aptos-labs.
Happy to open a PR for the handler + fake bound with the regression test above.
(Environment: clone at c0b9fb2 (HEAD of develop at time of writing),
aptos-go-sdk v1.14.0, chainlink-common v0.11.2-0.20260923164324-86cd57d9fdbd,
macOS/arm64.)
Disclosure: this report was drafted with AI assistance (Claude Code); the repro,
control run, and panic trace above were executed against a local clone at c0b9fb2.
- 主要言語
- Move
- スター
- 10
- フォーク
- 14
- 平均マージ
- 8日 13時間
- マージ済み PR(30日)
- 9
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
smartcontractkit/chainlink-aptos のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
smartcontractkit/chainlink-aptos#292 · コメント 2 件 ·
メンテナーはふだん 11 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
smartcontractkit/chainlink-aptos#222 ·
メンテナーはふだん 11 日以内に返信
smartcontractkit/chainlink-aptos の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
fedora-infra/anitya#2272 ·
メンテナーはふだん 1 日以内に返信
-
Appearance enhancement
難易度 2/5 1時間未満 初心者へのやさしさ 62/100
novalo-dev/Prestashop-MCP-Server#487 ·
メンテナーはふだん 1 日以内に返信
-
area/config comp/agent P2 type/perf
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
NousResearch/hermes-agent#161039 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
quickwit-oss/tantivy#3299 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信