Skip to content

XSS vulnerability in html method #2795

Closed
@HackbrettXXX

Description

@HackbrettXXX

When using the html method, it is possible to inject code that is executed in the user context. E.g. like this:

const doc = new jsPDF();
window.html2canvas = html2canvas;
const html = `
<p id='test'>a</p>
<img src=x onerror=eval("document.getElementById('test').innerHTML=window.location") />
`;
doc.html(html, {
  callback: function (doc) {
    doc.save();
  }
});

E.g., this line seems to be suspicious: https://github.com/MrRio/jsPDF/blob/master/src/modules/html.js#L52.

We need to analyze how to fix this and if there is other vulnerable code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions