Giter Site home page Giter Site logo

Comments (5)

pipwerks avatar pipwerks commented on August 16, 2024

Thanks, but JS utilities like PDFObject can't validate URLs for safety. This is the responsibility of the developer using PDFObject.

from pdfobject.

maple3142 avatar maple3142 commented on August 16, 2024

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.

pipwerks avatar pipwerks commented on August 16, 2024

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.

maple3142 avatar maple3142 commented on August 16, 2024

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.

pipwerks avatar pipwerks commented on August 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.