Skip to content

fix: bump @stellar/stellar-sdk to 17.1.0, drop vulnerable toml dependency - #7

Closed
pselle wants to merge 1 commit into
mainfrom
fix/bump-stellar-sdk-drop-toml
Closed

pselle wants to merge 1 commit into
mainfrom
fix/bump-stellar-sdk-drop-toml

Conversation

@pselle

@pselle pselle commented Sep 21, 2026

Copy link
Copy Markdown
Member

Summary

  • @stellar/stellar-sdk@^14.2.0 -> ^17.1.0. The old version pulled in the unmaintained toml npm package (GHSA-82x6-q7mm-w9cf: uncontrolled recursion; GHSA-v5mp-jgw5-2x6j: prototype pollution — no patch was ever released for toml). The SDK dropped toml entirely at v16.0.0.
  • This is flagged from stellar-registry/ui's Dependabot alerts — ui depends on this package and inherits the toml transitive dependency through it.

Why v17, not a smaller bump

v16.2.0 (the minimum that drops toml) still required fixing 8 type errors in sorobanUtils.ts alone; v17.1.0 adds ~13 more across 4 other files, but they're independent breaking changes, not compounding ones. Since both versions require real code changes, doing the full v17 jump now avoids a second migration+review pass later.

What changed

The generated xdr wrapper classes switched from getter methods to readonly properties (e.g. ContractDataDurability.persistent() -> .persistent, ScSpecFunctionV0.name() -> .name), and several now return Uint8Array where they returned Buffer before (Transaction.hash(), Signature, StrKey.decodeSha256Hash). Where a single class with an arm-getter method became a proper discriminated union (LedgerEntryData, ScVal, ContractExecutable), I added explicit .type narrowing checks with descriptive errors in loadContractMetada.ts instead of casting — getLedgerEntries for a contract ID should always return a contractData entry backed by a Wasm executable, so a mismatch there is a real error worth surfacing, not something to paper over.

nativeToScVal's type option is now strictly typed (ScValType union) instead of accepting arbitrary strings. This codebase builds those type hints dynamically from a contract's on-chain spec (arbitrary strings from JSON), which is fundamentally incompatible with compile-time literal checking — cast to Parameters<typeof nativeToScVal>[1] at each call site rather than widening the SDK's public type.

The tests/fixtures/counter.ts test fixture also needed a change: it built XDR spec entries via Buffer.from("..."), which throws XdrString: expected string, Uint8Array, or XdrString in the vitest/jsdom test environment (a cross-realm instanceof Uint8Array mismatch between Node's Buffer and jsdom's global). Passing plain strings instead sidesteps it and is simpler regardless.

Test plan

  • npm run typecheck passes
  • npm run build passes
  • npm run lint passes (0 errors; 1 pre-existing unrelated warning)
  • npm test — all 8 suites / 69 tests pass
  • npm audit confirms toml and @stellar/stellar-sdk no longer appear in the vulnerability list

I don't have deep context on this codebase's Soroban/XDR handling beyond what the SDK's own type definitions and doc comments describe, so please review the loadContractMetada.ts narrowing logic and the sorobanUtils.ts ScVal type-hint casts carefully before merging.

🤖 Generated with Claude Code

…ency

stellar-sdk <=15.1.0 depended on the unmaintained `toml` npm package
(GHSA-82x6-q7mm-w9cf, GHSA-v5mp-jgw5-2x6j — uncontrolled recursion and
prototype pollution, no upstream fix available). The SDK dropped that
dependency entirely at v16.0.0.

Jumping 14.2.0 -> 17.1.0 crosses several xdr API changes: the generated
xdr wrapper classes (ContractDataDurability, ScSpecFunctionV0.name,
Price, Signature, Hash, LedgerEntryData, ScVal, ContractExecutable)
switched from getter *methods* to readonly *properties*, and several
now return Uint8Array where they used to return Buffer. Updated each
call site accordingly, and added explicit type-guard checks where a
union type replaced what used to be a single class with an arm-getter
method (contractData/instance/executable in loadContractMetada.ts).

Verified: typecheck, build, lint, and the full test suite (69 tests)
all pass. `npm audit` confirms `toml` and `@stellar/stellar-sdk` are
gone from the vulnerability list.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​stellar/​stellar-sdk@​14.6.1 ⏵ 17.1.099100100 +199 +2100

View full report

@pselle

pselle commented Sep 21, 2026

Copy link
Copy Markdown
Member Author

This is failing tests now, and also doesn't work when I tried to test this PR manually in the Registry UI. Closing this PR and opening an issue instead!

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