Urgent.News

What's breaking now, across thousands of outlets.

Tech

`Content-Disposition` decides a filename, and the filename is where a download becomes a write

Content-Disposition decides a filename, and the filename is where a download becomes a write Every browser download ends with a decision about what to call the file and what to do with it. The server communicates that decision in a response header, and the client acts on it without further prompting. Content-Disposition is a small header with a surprisingly long reach: it names the file, it can…

Content-Disposition is a small header that decides both the filename and the download behavior. It communicates this decision in the HTTP response header, and the client follows it without further prompting. This header is crucial because it names the file and can force a download instead of rendering the content. The specifications define two dispositions: inline (suggesting display) and attachment (suggesting saving), both accepting a filename parameter.

RFC 5987 and its successor outline how to encode non-ASCII characters in these parameters. Implementations must handle two parameter forms, an encoding declaration, and a quoting rule, managing cases where clients understand one form but not the other. When a browser downloads a file, it saves it based on the provided filename. This process can become a vulnerability if the application, not the user, writes the file.

Two cases arise: server-side export jobs, where a server derives a filename from a request parameter, and file imports, where uploaded files use the header to derive stored names. An absence of Content-Disposition on download responses can also lead to vulnerabilities. Browsers might render certain content types as HTML, leading to script execution if the filename contains dangerous characters.

To mitigate these risks, servers should sanitize filenames using an allowlist, generate server-generated identifiers for file storage, serve user content from separate origins, and explicitly set Content-Disposition on every download route. Logging the generated filenames alongside request identities aids in tracking and reviewing potential security incidents.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

One company, one 75,500 dollar gap between role families

The company is one company. The pay is not one number. I keep a public dataset of job postings that actually state a salary range — right now 8,049 of them, deduplicated, from 266 employers' own…

  • $75,500 median pay gap between top and bottom role family salaries
  • Dataset from 8,049 job postings across 266 employers
  • Role family, not specific titles, determines salary significantly

You're not scared of failing. You're scared of being watched while you try.

I coach people who are changing professions. Almost every one of them opens with the same sentence in different words: "I'm not good enough yet." The sentence is true and useless at the same time.

  • Fear stems from being watched while trying, not from failing itself.
  • Concerns revolve around audience and perceived social cost of failure.

My RAG tool refused to answer a question my notes clearly answered

I built a retrieval-augmented generation tool over my own notes — no LangChain, no LlamaIndex, every stage by hand. Then I asked it a question my notes definitely answer, and it said: I can't find the…

  • Retrieval-augmented tool cut off answer mid-word
  • Chunk size caused partial answers and context loss
  • Solution: scan backwards to find sensible cut point

More from Sunday 25 October →