intermediateFile Upload

Why is trusting a file's Content-Type header or extension as proof of what it actually is a security risk?

Both the Content-Type header and the file extension are entirely client-controlled and trivially spoofed — a client can rename a malicious executable to `.jpg` and set any Content-Type it wants. Real validation checks the file's actual byte signature (magic numbers), not just claimed metadata.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to Why doesn't saving uploaded files to the application server's local disk work in a real production deployment?← Back to all Spring Boot questions