Skip to content

fix: validate Stellar public keys across DTOs and escrow service (#60) - #66

Open
ghzhost wants to merge 1 commit into
MergeFi:mainfrom
ghzhost:fix/60-stellar-address-validation
Open

fix: validate Stellar public keys across DTOs and escrow service (#60)#66
ghzhost wants to merge 1 commit into
MergeFi:mainfrom
ghzhost:fix/60-stellar-address-validation

Conversation

@ghzhost

@ghzhost ghzhost commented Aug 16, 2026

Copy link
Copy Markdown

Description

This PR resolves #60 by adding cryptographic and format validation for Stellar public keys (StrKey Ed25519 format) across all request DTOs and internal EscrowService methods.

Changes

  1. Reusable Validator (IsStellarAddress & isValidStellarAddress):
    • Implemented in src/common/validators/stellar-address.validator.ts backed by @stellar/stellar-sdk's StrKey.isValidEd25519PublicKey.
    • Validates that addresses start with G, are 56 characters, valid base32, and satisfy CRC16 checksum verification.
  2. DTO Layer Hardening:
    • Applied @IsStellarAddress() to:
      • FundEscrowDto.funderAddress
      • ReleaseEscrowDto.recipientAddress
      • SplitRecipientDto.recipientAddress
      • DepositDto.funderAddress (src/maintenance-pool/maintenance-pool.controller.ts)
      • AssignRewardDto.recipientAddress (src/maintenance-pool/maintenance-pool.controller.ts)
      • FundBountyDto.funderAddress (src/bounties/bounties.controller.ts)
      • FundMilestoneDto.funderAddress & ResolveIssueDto.recipientAddress (src/milestones/milestones.controller.ts)
      • SetStellarAddressDto.stellarAddress (src/users/users.controller.ts)
  3. Service Layer Defense-in-Depth:
    • Updated EscrowService.fund, release, releasePartial, and assertValidSplits to validate Stellar addresses prior to database or Soroban contract invocations.
  4. Test Coverage:
    • Added src/common/validators/stellar-address.validator.spec.ts testing unit validity (good keys, empty string, malformed strings, checksum failures) and HTTP boundary rejection with 400 Bad Request.
    • Updated src/escrow/escrow.service.spec.ts with valid Ed25519 test public keys and added tests for invalid funder and recipient address rejections.
    • Updated test mock in test/mocks/stellar-sdk.mock.js to include StrKey.isValidEd25519PublicKey.

Closes #60

@vercel

vercel Bot commented Aug 16, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant