I'm modifying an ASPNET MVC 5 web site and a requirement is to allow users to upload an XML and PDF file.

The XML file will be used to layout text on the PDF based on variables coming from within the system.

I have a schema for the XML that can be uploaded - so I can validate against a malformed XML - and that the XML matches the schema.

Where I'm unsure is in worries about DOS and malicious code in the XML. Is checking against the schema enough or can malicious code pass the schema check?

Also, the PDF is just stamped with text content using iText - would I need to worry about something nefarious in the PDF?

Both files are stored as byte[] in a database and never on a file system directly.

Part of the site prepares the PDF with the XML content and displays to the user and another part prepares the PDF to attach to an email. (Just trying to give some context in its use)

There seems to be so many places this could open security vulnerabilities and the client is using a 3rd party IT security vendor for this as well. I have to allow the functionality as I can't get around it.

1 Answer 1


Good moves to check XML for the correct schema, make sure you disable DTD as well and never allow a user input to modify XML schema, for that could result in a deserialization vulnerability. https://docs.microsoft.com/en-us/visualstudio/code-quality/ca3075-insecure-dtd-processing?view=vs-2019

A potential vector could be, that the PDF content itself contains malicious stuff, but it is something you really can't avoid, because it is in the users control.

  • Thanks. The PDF is an issue as the client sets up the initial PDF that is then part of an email response that goes out to their clients. So a malicious PDF could be disastrous. I think we might have to use an interim scanning service like messagelabs to scan the PDF for known vulnerabilities Jul 29, 2019 at 8:58
  • That would definetly be a good move, it would prevent exploits on older PDF versions, but this won't prevent potential phishing attacks with them. Overall preventing a legitimate account which could be compromised, to put a message "Hey visit this link to win 10000$" is difficult. Jul 29, 2019 at 9:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .