Summary
IPFSService.getMetadata casts an arbitrary gateway JSON response straight to TokenMetadata with no runtime shape validation.
Evidence
frontend/src/services/ipfs.ts:97-101
try {
return (await response.json()) as TokenMetadata
} catch {
throw new IPFSUploadError('Metadata response is not valid JSON.')
}
The content behind an ipfs:// URI is user/third-party controlled. The returned name/description/image are then consumed by UI components. A missing/malformed image field (or unexpected types) flows downstream untyped, and the as cast gives a false sense of safety.
Suggested fix
Validate the parsed object against the TokenMetadata shape (e.g. a small guard or zod schema) before returning; reject or sanitize unexpected fields. Ensure consumers treat image defensively.
Summary
IPFSService.getMetadatacasts an arbitrary gateway JSON response straight toTokenMetadatawith no runtime shape validation.Evidence
frontend/src/services/ipfs.ts:97-101The content behind an
ipfs://URI is user/third-party controlled. The returnedname/description/imageare then consumed by UI components. A missing/malformedimagefield (or unexpected types) flows downstream untyped, and theascast gives a false sense of safety.Suggested fix
Validate the parsed object against the
TokenMetadatashape (e.g. a small guard or zod schema) before returning; reject or sanitize unexpected fields. Ensure consumers treatimagedefensively.