I have PDFs sent in from an external source that I want users to be able to view via a web service.
The PDFs are retrieved via a .NET Core service that gets them from the DB and outputs them as PDF files.
The problem is that malicious users can put JS in PDFs. Because they appear to the browser to some from the same origin the JS can execute XSS attacks on the rest of the application.
I don't need to retain any of the JS functionality, but I also want to keep as much of the PDFs as unchanged as possible.
Is there a way, using .NET Core, to strip JS out of PDFs and leave them otherwise unchanged?
Alternatively is there any way to specify not to execute any JS when opening PDF files embedded in webpages (for instance using <iframe src="file.pdf" or <object type="application/pdf" data="file.pdf"). I can't rely on users having additional PDF extensions, it would need to work with the vanilla browser.