HackBlue

Tools · Email security · 26 / 26

The part filename is not the Content-Type

The filename is a label. Content-Type is the declared media type. Write both, and do not trust the extension.

10 min read · practice only with authorization

The filename is a token

A MIME part can carry a filename token, often on Content-Disposition. That token is a label the message included. The extension on the label is still a label. It is not a type check of the bytes.

This page does not open the part and does not save it into a folder you will double-click. Reading the headers is enough.

Content-Type is a declaration

Content-Type is the media type the part declares, such as text/html or application/pdf. It can disagree with the filename extension. The disagreement belongs in the note. Neither field is a substitute for a later type check on the bytes, and this page does not run that check.

If one of the two fields is missing, say which one. Do not copy the extension into Content-Type, or the media type into the filename.

Before anyone opens the part

Record the filename token and the Content-Type. Write that the byte type was not checked. Hand the part to the attachment process your team already uses when a type check is required. Do not rename the label so the extension matches the declared type.

Lab: a pdf name on a text/html part

A lab part shows filename report.pdf and Content-Type text/html. A draft writes that the attachment is a PDF because of the name, and opens it from the mail client to confirm.

The note lists filename report.pdf and declared type text/html. The extension is not promoted to a type. The part stays unopened. Byte type not checked stays on the note.

Snippet
filename: report.pdf
Content-Type: text/html
byte type: not checked
opened: no
write: label and declared type
not: a PDF because of the name

Diagram

Two fields on one MIME part

The name and the declared type can disagree. Neither one is a byte check.

report.pdftext/html

Filename

filename=report.pdf
A label

Content-Type

text/html
A declaration

Not done here

byte type not checked
Left for the team process

Check yourself

1. A part says filename report.pdf and Content-Type text/html. What is report.pdf?

2. Which field is the declared media type?

3. You have not checked the bytes. What do you write?