Skip to content

fix: enhance client-side validation for token selector to prevent bypass - #175

Merged
Jaydbrown merged 3 commits into
conduit-protocol:mainfrom
kuse-design:blackboxai/fix-token-selector-validation
Jul 29, 2026
Merged

fix: enhance client-side validation for token selector to prevent bypass#175
Jaydbrown merged 3 commits into
conduit-protocol:mainfrom
kuse-design:blackboxai/fix-token-selector-validation

Conversation

@kuse-design

Copy link
Copy Markdown
Contributor
  • Added StrKey.isValidContract() validation for token (C-address) fields
  • Added StrKey.isValidEd25519PublicKey() validation for sender/recipient (G-address) fields
  • Added amount positivity validation in validatePayload()
  • Updated StreamBuilder._validateAddress() with address format checks
  • Added comprehensive test coverage for validation bypass scenarios

What does this PR do?

Type of change

  • Bug fix
  • New feature / method
  • Refactor
  • Test coverage
  • Documentation
  • Dependency update

Related issue

Changes

File Change

Checklist

  • npm run typecheck — no errors
  • npm run lint — no warnings
  • npm test — all tests pass
  • npm run build — bundle compiles cleanly
  • No any types introduced
  • New public methods documented in docs/api.md
  • All on-chain amounts kept as bigint — no Number() conversion in arithmetic
  • New methods mock-tested in src/tests/
  • CHANGELOG.md updated under [Unreleased]
  • src/index.ts updated if new exports added

Breaking changes?

  • No
  • Yes — describe below and add BREAKING CHANGE: footer to relevant commit

Notes for reviewers

Closes #104

@Jaydbrown

Copy link
Copy Markdown
Contributor

The validation logic itself is solid — real StrKey.isValidContract/isValidEd25519PublicKey checks added to StreamBuilder._validateAddress() and validatePayload(), with test coverage. A few things need fixing before this can merge:

  1. This branch now has real merge conflicts against main (several PRs landed ahead of it) — needs a rebase.
  2. The diff commits a TODO.md with its own checklist claiming steps 2-5 are still unchecked, but the diff itself actually contains that work — please drop that file from this PR (stale/contradictory tracking doc, not real project documentation).
  3. One hunk lost its indentation — const validationErrors = validatePayload(streams); is sitting at column 0. Please fix the formatting there.

Happy to get this in once it's rebased and cleaned up.

kuse-design and others added 3 commits July 29, 2026 09:39
- Added StrKey.isValidContract() validation for token (C-address) fields
- Added StrKey.isValidEd25519PublicKey() validation for sender/recipient (G-address) fields
- Added amount positivity validation in validatePayload()
- Updated StreamBuilder._validateAddress() with address format checks
- Added comprehensive test coverage for validation bypass scenarios
…d addresses

Adding real StrKey validation (this PR's whole point) correctly started
rejecting the placeholder-style addresses ('CD...', 'CD1', and a couple of
malformed 55-char strings) that pre-existing tests across this repo used as
stand-ins for real C-/G-addresses. Replaced them with properly checksummed,
valid addresses so the existing suite passes under real validation instead
of silently relying on validation being a no-op.

Also updated pagination-cursor.test.ts's 'returns a nextCursor' test to mock
a full page of results — it was asserting the old hasNextPage semantics
(compared against the global streamCount()) that conduit-protocol#179/conduit-protocol#183 already replaced
with the correct ids.length === limit check.

Removed a duplicate, unused maxBatchSize declaration in builder.ts (a lint
error introduced by this branch's own diff).
@Jaydbrown
Jaydbrown force-pushed the blackboxai/fix-token-selector-validation branch from 0cd1305 to 6ae5df2 Compare July 29, 2026 09:00
@Jaydbrown
Jaydbrown merged commit e62a9cc into conduit-protocol:main Jul 29, 2026
Jaydbrown added a commit that referenced this pull request Jul 29, 2026
- governor.ts: parseGovernorConfig assigned 'undefined' directly to
  optional GovernorConfig fields, which exactOptionalPropertyTypes (true
  in tsconfig) rejects — a key must be entirely absent, not present with
  value undefined. Switched to conditional spreads. Regression from #231.

- builder-validation-bypass.test.ts: the fixture-address fix from #175
  never actually landed — I'd edited this file locally but forgot to
  stage it before that PR's final commit, so the squash-merge only
  included the earlier (broken-placeholder-address) revision. Reapplying
  the same fix now: replace the invalid 55-character StrKey strings with
  genuinely valid, checksummed addresses.

- walletconnect.test.ts: 'times out a stalled remote disconnect' (#241)
  left its returned promise unobserved for one microtask tick under fake
  timers, producing a 'handled asynchronously' unhandled-rejection
  warning that vitest sometimes misattributes to an unrelated test in the
  same run. Attach a no-op .catch() immediately to keep it always-handled;
  behavior/assertions are unchanged.
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.

Bug: Token Selector bypasses validation

3 participants