relayer: AccountTransactions forwards an unvalidated Limit into aptos-go-sdk — Start != nil with a large Limit panics the plugin process
I maintainer di solito rispondono entro 11 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 76/100
Direzione di ricerca
Leggi relayer/aptos_service.go intorno alle righe 142-161: il controllo Limit == 0 è lì, e Start/Limit vengono poi passati direttamente a client.AccountTransactions. Aggiungi un limite superiore che restituisca codes.InvalidArgument, rispecchialo in capabilities/fakes/aptos_chain.go intorno alla riga 252 e aggiungi il test di regressione segnalato nel pacchetto relayer in modo che verifichi un panic di makeslice e zero RPC in uscita. Esegui go test ./relayer/...; fatto significa che il test sul limite sovradimensionato passa e non si verifica alcun panic del processo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Move
- Stelle
- 10
- Fork
- 14
- Merge medio
- 8g 13h
- PR unite (30g)
- 9
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di smartcontractkit/chainlink-aptos
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
smartcontractkit/chainlink-aptos#292 · 2 commenti ·
I maintainer di solito rispondono entro 11 giorni
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
smartcontractkit/chainlink-aptos#222 ·
I maintainer di solito rispondono entro 11 giorni
Tutte le issue di smartcontractkit/chainlink-aptos
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
fedora-infra/anitya#2272 ·
I maintainer di solito rispondono entro 1 giorno
-
Appearance enhancement
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 62/100
novalo-dev/Prestashop-MCP-Server#487 ·
I maintainer di solito rispondono entro 1 giorno
-
area/config comp/agent P2 type/perf
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
NousResearch/hermes-agent#161039 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
quickwit-oss/tantivy#3299 ·
I maintainer di solito rispondono entro 1 giorno