Comments (5)
Thanks, but JS utilities like PDFObject can't validate URLs for safety. This is the responsibility of the developer using PDFObject.
from pdfobject.
But the problem is that it is dangerous by default as the XSS is on the default fallbackHTML_default
, and there is no way to wrap a html sanitizer (e.g. DOMPurify) around that currently as it just insert the HTML to the target element. I don't think this can be easily fixed without changing the API though.
from pdfobject.
I see, you're referring to an attacker rewriting the fallback URL in PDFObject. I initially thought you were referring to the destination site being malicious/compromised.
In the scenario you describe, PDFObject is not a point of entry into the DOM. The only way an attacker can modify the PDFObject fallback URL (or HTML) is if they already have the ability to control JS on the page. If this is the case, they can already do whatever they want, regardless of PDFObject.
If you disagree and can provide a demonstration/POC I'd be happy to review.
Thanks
from pdfobject.
Try this on a mobile device (or use devtools to enable mobile mode):
https://gh.maple3142.workers.dev/maple3142/c6e29fd852c0774fb622493710beda4a/raw/ea3c64992d6b18a8f8acbaf2416e4c7df114a1c6/test.html?url=%27%3E%3Cimg%20src=x:%20onerror=alert(document.domain)%3E
HTML code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.2.12/pdfobject.min.js" integrity="sha512-lDL6DD6x4foKuSTkRUKIMQJAoisDeojVPXknggl4fZWMr2/M/hMiKLs6sqUvxP/T2zXdrDMbLJ0/ru8QSZrnoQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<div id="pdf-display"></div>
<script>
const url = new URL(location.href).searchParams.get('url')
PDFObject.embed(url, "#pdf-display");
</script>
I think it is reasonable to not have XSS in a simple, obvious PDF viewer usecase. Even pdf.js have a similar pdf viewer here.
from pdfobject.
Your example creates the vulnerability by utilizing a querystring parameter to populate PDFObject's options. This is not a XSS vulnerability on the part of PDFObject.
from pdfobject.
Related Issues (20)
- PDFObject Not Show and Only show Root File HOT 2
- Eraser HOT 1
- PDFObject save button option HOT 1
- Disabled download and print button HOT 1
- Use google docs PDF conversion for mobile devices? HOT 5
- [Documentation] Standalone examples of .html files + PDFObject? HOT 3
- Remove some buttons and only show one page at a time HOT 1
- Render html elements within "the full-browser embed" HOT 1
- Fails to load in IE11 HOT 8
- Is there a way to track button clicks? HOT 2
- Navigator.pdfViewerEnabled support? HOT 8
- PDFObject: Page option not working in Microsoft Edge HOT 2
- The problem occurred when using PDFObject in React: Page A embedded with duplicate Page A. HOT 3
- Cannot set properties of undefined HOT 1
- Prevent download pdf automatically HOT 1
- PDFObject is vulnerable to PDFInjection HOT 4
- base64 PDF how to set title? HOT 1
- Sign PDF with digital certificate HOT 1
- change default download file name HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdfobject.