How to fix: File Upload Without accept Attribute
File input without accept attribute. The accept attribute is only a client-side UX hint and is trivially bypassed, so its absence does not by itself confirm a server-side validation gap.
Why it matters
Low on its own. The accept attribute cannot be relied on for security either way; the real risk depends on whether the server validates uploaded file type/content, which this check cannot observe.
Accept attribute provides a client-side hint only, with no enforcement value. Add it for UX, but rely on server-side validation for security.
How to fix it
- 1Set the accept attribute for UX.
- 2Validate file type, size, and content on the server; this is the control that actually matters.
Code examples
Validate file type, size, and content on upload
const ALLOWED_TYPES = new Set(["image/jpeg", "image/png", "image/webp"]);
const MAX_SIZE = 5 * 1024 * 1024; // 5 MB
export async function POST(req: Request) {
const formData = await req.formData();
const file = formData.get("file") as File;
if (!file) return Response.json({ error: "No file" }, { status: 400 });
if (!ALLOWED_TYPES.has(file.type)) return Response.json({ error: "Invalid file type" }, { status: 400 });
if (file.size > MAX_SIZE) return Response.json({ error: "File too large" }, { status: 400 });
// Also verify content with a magic-bytes check (file type can be spoofed)
const buffer = await file.arrayBuffer();
const header = new Uint8Array(buffer.slice(0, 4));
const isJpeg = header[0] === 0xFF && header[1] === 0xD8;
// ...
}References
Detected automatically by VulnRadar. The check id is file-upload-no-restrictions, stable across every scan so you can filter or diff on it.
More content checks
- MediumPotential Open Redirect Parameters
- HighDirectory Listing Appears Enabled
- MediumSensitive File References Detected
- HighPotentially Outdated JavaScript Libraries
- Inforobots.txt Present - Review Manually
- InfoCMS / Technology Fingerprinting
- MediumPotentially Dangerous Inline JavaScript
- LowServer version disclosed in response header
Questions
- How severe is File Upload Without accept Attribute?
- VulnRadar rates this low severity in the content category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id file-upload-no-restrictions, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does File Upload Without accept Attribute map to?
- It maps to CWE-434. In the OWASP Top 10 it falls under A08:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.