Skip to content

[MEDIUM] — parseAcceptedAssets silently drops malformed entries instead of rejecting the create/update request #9

@Alqku

Description

@Alqku

Severity: Medium
Type: Bug
Scope: Campaigns
Labels: bug, good first issue

Description

parseAcceptedAssets (src/campaigns/campaigns.service.ts, lines ~451–470) splits accepted asset strings on : and constructs { assetType: 'credit', code, issuer } only when both code and issuer are present. For inputs like "XLM:", "USDC:", or empty strings, parseAcceptedAssets returns null and the entry is .filter(Boolean)-dropped. If every entry is malformed, the function returns an empty array; the surrounding createCampaign logic then leaves Campaign.acceptedAssets unset, which downstream code treats as "native XLM only" (coerceAcceptedAssets in donations.service.ts).

A creator who types USDC:G...issuer... is fine, but USDC: (typo), USDC (missing issuer), XLM:badissuer (empty issuer) silently produce incorrect acceptance lists with no validation error.

Recommendation

  • In the CreateCampaignDto, use a @ValidateNested class with @IsString on both code and issuer, throwing BadRequestException for malformed inputs.
  • Validate at the service boundary too: if any input has a colon and the right-hand side is empty (or vice versa), return 400.
  • Cover with unit tests for the malformed-input matrix.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignAudit finding under the Official CampaignbugSomething isn't workinggood first issueGood for newcomers

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions