Skip to content

fix(validation): reject invalid Stellar keys and inconsistent vault c… - #1766

Merged
1nonlypiece merged 2 commits into
Disciplr-Org:mainfrom
Viccodes11:fix/validate-stellar-keys-and-vault-config
Oct 24, 2026
Merged

1nonlypiece merged 2 commits into
Disciplr-Org:mainfrom
Viccodes11:fix/validate-stellar-keys-and-vault-config

Conversation

@Viccodes11

Copy link
Copy Markdown
Contributor

Closes #1684

Summary

Replaces regex-only address validation and loose date/milestone rules on POST /vaults with a schema in apilib/validation.mjs (using zod and @stellar/stellar-sdk) that matches the contract invariants and prevents invalid vaults from being accepted by the API.

Changes

  • Address Validation: Enforced StrKey CRC16 checksum verification via StrKey.isValidEd25519PublicKey on creator, verifier, successDestination, and failureDestination. Explicitly rejects muxed M... addresses.
  • Destination & Role Constraints: Enforces verifier !== creator and failureDestination !== creator. Invalid optional destinations reject with 400 rather than silently falling back.
  • Date Windows: Enforces startDate >= now - 5min (clock skew), endDate > startDate, and endDate - now <= 5 years. Date strings without timezone offsets are treated as UTC.
  • Milestone Rules: Enforces non-empty trimmed titles $\le 128$ bytes (UTF-8 byte length), startDate < dueDate <= endDate, and non-decreasing due dates.
  • Strict Payload: Rejects unrecognized fields on the payload and milestones.
  • Error Format: Returns 400 { error: 'Validation failed', details: [{ field, code, message }] } without echoing raw inputs.
  • OpenAPI: Updated apilib/openapi.mjs to reflect constraints and structured error details.
  • Tests:
    • Added unit test suite apilib/__tests__/validation.test.mjs covering all positive and negative constraints, including checksum corruption.
    • Added HTTP-level test suite api/__tests__/vaults.create.test.mjs asserting response envelope shape and status codes.

Viccodes11 and others added 2 commits October 24, 2026 19:56
@1nonlypiece
1nonlypiece merged commit 1ac2f1d into Disciplr-Org:main Oct 24, 2026
2 of 5 checks passed
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.

[validation] Reject invalid Stellar keys and inconsistent vault configurations on POST /vaults

2 participants