Skip to content

Security audit fixes (2026-04): TRON rawData verify, feedback @-mentions, RPC URL redaction, vitest 4 - #30

Merged
szhygulin merged 1 commit into
mainfrom
security/audit-fixes-2026-04
Apr 14, 2026
Merged

Security audit fixes (2026-04): TRON rawData verify, feedback @-mentions, RPC URL redaction, vitest 4#30
szhygulin merged 1 commit into
mainfrom
security/audit-fixes-2026-04

Conversation

@szhygulin

Copy link
Copy Markdown
Collaborator

Summary

  • M1 — TRON rawDataHex verification before signing. Every TronGrid builder now decodes the returned Transaction.raw protobuf and asserts the inner contract matches caller intent byte-for-byte before the signing handle is issued. Closes the MITM window where a compromised TronGrid response could swap destination/amount/contract between the JSON preview shown to the user and the hex the Ledger actually signs.
  • M2 — Neutralize @-mentions in feedback issue titles. GitHub parses @-mentions in titles, not just bodies; prompt-injected summaries could have pinged arbitrary users.
  • L1 — Redact RPC URLs from RpcConfigError. Provider API keys commonly live in the URL path; no longer interpolated into error messages that end up in logs.
  • I1 — vitest ^2.1.0^4.1.4. Pulls a vite/esbuild chain that resolves GHSA-67mh-4wv8-2f99 (dev-only). All 341 tests pass unchanged. npm audit → 0 vulns.

TRON verifier details

New src/modules/tron/verify-raw-data.ts (~250 LOC) decodes Transaction.rawContractgoogle.protobuf.Any → the inner contract using a minimal wire-format parser (no new deps), then matches against a discriminated-union TronRawDataExpectation for all seven contract kinds:

  • TransferContract (native TRX send)
  • TriggerSmartContract (TRC-20)
  • VoteWitnessContract
  • FreezeBalanceV2Contract / UnfreezeBalanceV2Contract
  • WithdrawExpireUnfreezeContract
  • WithdrawBalanceContract

Covered by test/tron-raw-data-verify.test.ts: 5 happy-path + 10 tamper-detection cases (swapped to_address / amount / owner_address / contract-type / TRC-20 contract / TRC-20 calldata / vote_count / resource, invalid hex, truncated protobuf).

Socket.dev triage (no code change)

Alert Package Assessment
Potential vuln (ReDoS) picomatch@2.3.2 Not reachable. Pulled via @walletconnect/keyvaluestorage → unstorage → anymatch@3. Patterns are WC-internal storage keys, never user-controlled. picomatch@4 is ESM-only and breaks anymatch@3's CJS usage.
Network access @0no-co/graphqlsp@1.15.3 Dev-only GraphQL LSP via @lifi/sdk → @mysten/sui → gql.tada. Not invoked at runtime.
Shell access @gql.tada/cli-utils@1.7.3 Same path. CLI tool, never invoked by our code.
Typosquat node-mock-http / parseurl False positives — legitimate UnJS / jshttp packages.
Unstable ownership content-disposition@1.1.0 Legitimate maintainer on transitive express dep.

Test plan

  • npx vitest run — 341/341 pass
  • npx tsc --noEmit — clean
  • npm audit — 0 vulnerabilities
  • Manual smoke: prepare a TRON native send via the MCP and confirm the verifier passes on a real TronGrid response
  • Manual smoke: tampered TronGrid response (patch raw_data_hex locally) → verifier should throw before handle is issued

🤖 Generated with Claude Code

Addresses findings from the 2026-04 internal audit plus Socket.dev
supply-chain triage.

M1 — TRON rawDataHex verification before signing
  Every TronGrid builder now decodes the returned Transaction.raw
  protobuf and asserts the inner contract matches the caller's intent
  (owner_address / to_address / amount / contract_address / calldata /
  vote_count / resource / fee_limit) byte-for-byte before the handle is
  issued. Closes the MITM window where a compromised TronGrid response
  could swap destination or amount between the JSON preview we show the
  user and the hex the Ledger actually signs.

  New: src/modules/tron/verify-raw-data.ts (minimal protobuf decoder +
  per-contract-type expectation matcher; no new deps).
  Wired into all seven builders in src/modules/tron/actions.ts.
  Covered by test/tron-raw-data-verify.test.ts (15 cases: 5 happy-path
  + 10 tamper-detection including swapped to_address/amount/owner/
  contract-type/TRC20-contract/TRC20-calldata/vote-count/resource,
  invalid hex, truncated protobuf).

M2 — Neutralize @-mentions in feedback issue titles
  GitHub parses @-mentions in issue titles, not just bodies. A prompt-
  injected summary string containing '@someuser' would ping arbitrary
  users when opening the issue. Title is now run through the same
  neutralizeMentions() helper as the body.

L1 — Redact RPC URLs from config-error messages
  Configured RPC URLs commonly embed a provider API key in the path
  (e.g. .../v3/<key>). RpcConfigError no longer interpolates the URL
  into its message, so malformed URLs don't leak the key into logs/
  stderr.

I1 — npm audit clean
  Bumped vitest ^2.1.0 → ^4.1.4, pulling in a vite/esbuild chain that
  resolves GHSA-67mh-4wv8-2f99 (dev-only). All 341 tests pass unchanged
  on the new major. npm audit now reports 0 vulnerabilities.

Socket.dev supply-chain triage (no code change):
  - picomatch@2.3.2 ReDoS (transitive via
    @walletconnect/keyvaluestorage → unstorage → anymatch@3): not
    reachable in our deployment — glob patterns are WC-internal storage
    keys, never user-controlled input. Upgrading requires an npm
    override to picomatch@4 which is ESM-only and breaks anymatch@3's
    CJS usage. Leaving as-is.
  - @0no-co/graphqlsp / @gql.tada/cli-utils (network + shell access):
    dev-only GraphQL LSP + CLI pulled transitively via @lifi/sdk →
    @mysten/sui → gql.tada. Not invoked at runtime.
  - node-mock-http / parseurl "typosquat" flags: false positives;
    both are legitimate UnJS / jshttp packages pinned in lockfile.
  - content-disposition unstable-ownership: legit maintainer transition
    on a transitive express dep; not actionable.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@szhygulin
szhygulin merged commit 78445c3 into main Apr 14, 2026
3 checks passed
szhygulin added a commit that referenced this pull request Apr 14, 2026
Security patch release — no API changes, no breaking behaviour.

Contains:
 - TRON rawDataHex verification before Ledger signing (MITM defence)
 - Feedback issue titles now neutralize @-mentions
 - RPC config errors no longer echo URLs (prevents API-key leak in logs)
 - vitest 2.x → 4.x (resolves GHSA-67mh-4wv8-2f99, dev-only)

See PR #30 for full details and Socket.dev triage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@szhygulin szhygulin mentioned this pull request Apr 14, 2026
5 tasks
@szhygulin
szhygulin deleted the security/audit-fixes-2026-04 branch April 25, 2026 02:15
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.

1 participant