Skip to content

[Bug] SubmitRequestSchema has no max length, unlike api-local's body limit #481

Description

@collinsezedike

Description

SubmitRequestSchema in packages/shared/src/schemas.ts is z.object({ xdr: z.string().min(1) }), with no maximum length. apps/api-local/src/index.ts:20 already sets a deliberate bodyLimit: 10 * 1024 (10 KB) on the Fastify server "to block oversized payload attacks," but the Vercel functions (api/v1/tx/submit) have no equivalent bound, since they validate against this shared schema rather than a body-limit middleware.

Steps to Reproduce

  1. Send POST /api/v1/tx/submit with a xdr string far larger than any real transaction envelope could be (e.g. several MB).
  2. Compare against the same request sent to the Fastify dev server, which rejects it at the body-limit layer before it reaches validation.

Expected Behavior

The Vercel path should reject oversized xdr payloads the same way the Fastify path does.

Actual Behavior

No length bound exists on the Vercel path; an oversized payload passes schema validation and proceeds to XDR parsing.

Environment

Field Value
Network N/A
Wallet N/A
Protocol affected API
Browser (if frontend) N/A
Node.js version N/A
pnpm version N/A

Possible Cause / Fix

Add a .max() to SubmitRequestSchema's xdr field, consistent with the existing 10 KB precedent in apps/api-local/src/index.ts:

export const SubmitRequestSchema = z.object({
  xdr: z.string().min(1).max(10_000),
});

10,000 characters is generously above any real signed Stellar transaction envelope's base64 size while staying bounded, matching the same order of magnitude as the existing apps/api-local body limit.

Activity

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

Metadata

Metadata

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignapiAdds or modifies a REST endpoint in apps/apibugSomething isn't workingtrivialSelf-contained task, completable in < 2 hours with no deep protocol knowledge required

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions