Skip to content
Astera Technology

Check attachment size and type before transfer

Apply the receiving contract and inspect content rather than trusting a filename or browser MIME label.

Record byte limits and allowed content

OWASP recommends multiple upload checks; an extension or declared Content-Type alone is insufficient. This sample local contract accepts PDF up to 2,000,000 bytes and requires a content check. That number is not a limit from any provider.

Synthetic attachment checks
FileObservedDecision
A.pdf1,500,000 bytes; verified PDF contentEligible for remaining security checks
B.pdf2,100,000 bytesReject under sample size limit
C.pdfDeclared PDF; actual unsupported contentReject type mismatch
Download editable CSV ↓

Keep scan and transfer state distinct

Record file identity, size, verified type and scan disposition. A hash can detect accidental content change but does not prove a file is safe. Avoid retrying an oversized or disallowed attachment; offer the documented correction path.

A renamed executable has .pdf and application/pdf. Is it eligible because both labels match?

Show the worked answer

No. Check actual content and the security policy. Matching self-declared labels cannot replace server-side validation and scanning.

Related resources