Skip to content

sidecar: harden /tx?hash= discriminator and lock ctx-plumbing audit#173

Merged
bdchatham merged 1 commit into
mainfrom
feat/sign-tx-hardening
May 12, 2026
Merged

sidecar: harden /tx?hash= discriminator and lock ctx-plumbing audit#173
bdchatham merged 1 commit into
mainfrom
feat/sign-tx-hardening

Conversation

@bdchatham
Copy link
Copy Markdown
Contributor

@bdchatham bdchatham commented May 12, 2026

Closes #172 items 1 and 2. Item 3 (fee_payer/granter integration assertion) ships with the gov-vote handler PR — it makes more sense alongside a handler that actually signs a tx end-to-end.

Summary

  • Replace strings.Contains(strings.ToLower(err.Error()), \"not found\") with a typed *rpctypes.RPCError discriminator (isTxNotFound). Transport errors are wrapped Go errors, not *RPCError, so errors.As fences them out — DNS "host not found" can no longer be confused with a missing tx.
  • Lock the ctx-plumbing audit (item 2) in a code comment. The vendored sei-tendermint jsonrpc client uses http.NewRequestWithContext, so the 30s tmRPCTimeout from feat(sidecar): sign-tx foundation (PR-A of #163, foundation-only) #170 is a redundant upper bound, not the only stop.

Test plan

  • Unit test TestIsTxNotFound covers: server-side tx-not-found, other server internal error, wrapped RPCError, transport error containing "not found" as decoy substring, nil
  • `go build ./...` clean
  • `go test ./...` clean
  • `go test -race ./sidecar/tasks/...` clean
  • `golangci-lint run --new-from-rev=origin/main ./...` reports 0 issues
  • Coral trio cross-review (platform / kubernetes / security) — all clean, k8s independently verified the ctx-plumbing claim

🤖 Generated with Claude Code


Note

Low Risk
Low risk: small, well-tested change to error classification in QueryTx plus a clarifying comment about context cancellation; main impact is how missing-tx vs real transport errors are handled.

Overview
Tightens QueryTx error handling by replacing the substring-based "not found" check with a typed *rpctypes.RPCError discriminator (isTxNotFound), preventing transport/DNS errors from being misclassified as missing transactions.

Adds a unit test suite for isTxNotFound (including wrapped RPC errors and decoy "not found" transport messages) and documents that ctx cancellation propagates into the underlying Tendermint JSON-RPC HTTP request (making the existing 30s timeout a secondary bound).

Reviewed by Cursor Bugbot for commit 8ec8d48. Bugbot is set up for automated code reviews on this repo. Configure here.

Closes seictl#172 items 1 and 2. Item 3 (fee_payer/granter integration
assertion) ships with the gov-vote handler PR.

Replace the free-form err.Error() substring match with a typed
*rpctypes.RPCError assertion. Transport errors (DNS lookup failures,
connection-refused, http transport timeouts) are wrapped Go errors —
NOT *RPCError — so errors.As fences them out at the gate. A DNS "host
not found" can no longer be confused with a missing tx.

Server-side, sei-tendermint converts every handler error to
RPCError{Code: CodeInternalError, Data: err.Error()} via MakeError
(rpc/jsonrpc/types/types.go), so the discriminator must look at the
Data substring — Code alone catches every internal error indiscriminately.

The ctx-plumbing audit (item 2) confirmed http.NewRequestWithContext
is used in the vendored jsonrpc client. The 30s tmRPCTimeout from #170
is a redundant upper bound, not the only stop. A code comment locks
that finding so future readers don't re-derive it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bdchatham bdchatham merged commit bb505a8 into main May 12, 2026
3 checks passed
@bdchatham bdchatham deleted the feat/sign-tx-hardening branch May 12, 2026 20:43
bdchatham added a commit that referenced this pull request May 12, 2026
First user-facing gov sign-tx handler. Composes on the sign-tx
foundation (#170) and hardening (#173).

## Summary
- New \`TaskGovVote\` task type + \`sidecar/tasks/gov_vote.go\` handler
that builds Cosmos gov v1beta1 \`MsgVote\` and delegates to
\`SignAndBroadcast\`.
- \`GovVoteTask\` Go client SDK helper.
- No chain-query idempotency — chain handles last-write-wins on
\`(proposalID, voter)\`; caller's request is authoritative.
- Also closes #172 item 3 (deferred from #173):
\`TestSignedTxHasNoFeePayerOrGranter\` decodes the signed proto Tx and
asserts \`AuthInfo.Fee.Payer\` / \`Granter\` are empty strings.
- Exported \`ParseVoteOption\` so client and server share one canonical
option set (no drift).
- Two follow-ups tracked in #174: per-handler idempotency review
template (load-bearing once a non-idempotent sign-tx handler ships),
\`TaskResult.Output\` engine extension.

## Test plan
- [x] \`TestParseVoteOption\` table — case-insensitivity, kebab alias,
empty/unknown rejection
- [x] \`TestBuildVoteMsg\` subtests — happy path (incl.
\`ValidateBasic\` assertion), zero proposalID, invalid option, nil
keyring, empty keyName, missing key — all Terminal
- [x] \`TestSignedTxHasNoFeePayerOrGranter\` — proto-level
fee-payer/granter empty assertion
- [x] \`go build ./...\` clean
- [x] \`go test ./... -count=1\` clean (all packages)
- [x] \`go test -race ./sidecar/tasks/\` clean
- [x] \`golangci-lint run --new-from-rev=origin/main ./...\` reports 0
issues
- [x] Coral trio cross-review (platform / kubernetes / security) —
synthesized findings applied; remaining deferred to #174

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **High Risk**
> Adds a new sign-and-broadcast task that can submit on-chain governance
votes using the validator’s keyring, which is security-sensitive
(especially given the sidecar API exposure). Also introduces new
invariants around tx fee payer/granter enforced by tests, but mistakes
could still result in unintended transactions/fees.
> 
> **Overview**
> Adds a new `gov-vote` task end-to-end: registers `engine.TaskGovVote`
in `serve.go`, defines the task type in `engine/types.go`, and
implements `sidecar/tasks/gov_vote.go` to build a gov v1beta1 `MsgVote`
and delegate signing/broadcasting to `SignAndBroadcast`.
> 
> Extends the Go client SDK (`sidecar/client/tasks.go`) with a typed
`GovVoteTask` (validation + wire params) and shares vote-option parsing
via exported `tasks.ParseVoteOption`.
> 
> Hardens tx signing tests by capturing broadcast tx bytes and
asserting, at the protobuf level, that `AuthInfo.Fee.Payer` and
`AuthInfo.Fee.Granter` are empty, preventing accidental fee delegation
regressions.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
b1061c3. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

sign-tx hardening: typed RPCError discriminator, ctx-plumbing audit, fee_payer/granter assertion

1 participant