views:

101

answers:

2

I've implemented a PDF generation function in my flex app using alivePDF, and I'm wondering if the process I've used to get the file to the user creates an XSS vulnerability.

This is the process I'm currently using:

  1. Create the PDF in the flex application.
  2. Send the binary PDF file to the server using a POST, along with the filename to deliver it as.
  3. An ASP.NET script on the server checks the filename to make sure it's valid, and then sends it back to the user as an HTTP attachment.

Given that, what steps should I take to prevent XSS?

A: 

Are there any other GET or POST parameters other than the filename?

In preventing XSS, there are three main strategies: validation, escaping, and filtering.

Validation: Upon detecting nvalid characters, reject the POST request (and issue an error to the user).

Escaping: Likely not applicable when saving the file, as your OS will have restrictions on valid file names.

Filtering: Automatically strip the POST filename parameter of any invalid characters. This is what I'd recommend for your situation.

Within the ASP.NET script, immediately grab the POST string and remove the following characters: < > & ' " ? % # ; +

Ben Walther
This doesn't apply. Dan isn't sending any output directly to the client; just via the response stream.
Jan Jongboom
In the "Content-Disposition" header, you'll want to avoid any HTML special characters in order to prevent the user from breaking out of the header and into the raw message body.You are correct that this is not an XSS attack, but rather HTTP response splitting.http://en.wikipedia.org/wiki/HTTP_response_splitting
Ben Walther
A: 

How is this going to be XSS exploitable? You aren't outputting something directly to the user. The filesystem will just reject strange characters, and when putting the file on the output stream, the name nor the content does matter.

Jan Jongboom