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

(Snyk Security Code Tool) Arbitrary Code Injection affecting package pdfjs-dist #1102

Open
Panagiotis-Vasiloglou opened this issue May 30, 2024 · 5 comments

Comments

@Panagiotis-Vasiloglou
Copy link

Panagiotis-Vasiloglou commented May 30, 2024

Bug Report or Feature Request (mark with an x)
- [ ] Regression (a behavior that used to work and stopped working in a new release)
- [X] Bug report -> please search issues before submitting
- [ ] Feature request
- [ ] Documentation issue or request

Don't know if is "Bug report", but a few days ago, a kind of a popular tool called "Snyk Security" (also a VScode extension), occured an error about ng2-pdf-viewer library.

When I hovered, it displayed this message "Arbitrary Code Injection affecting package pdfjs-dist". I checked the generated report and suggested to 'Upgrade pdfjs-dist to version 4.2.67 or higher.'

This is the URL of the full report
https://security.snyk.io/vuln/SNYK-JS-PDFJSDIST-6810403

@antonio-santos-zact
Copy link

I also found that same vulnerability when running npm audit

pdfjs-dist <=4.1.392
Severity: high
PDF.js vulnerable to arbitrary JavaScript execution upon opening a malicious PDF - [GHSA-wgrm-67xf-hhpq](https://github.com/advisories/GHSA-wgrm-67xf-hhpq)
No fix available
node_modules/pdfjs-dist
ng2-pdf-viewer *
Depends on vulnerable versions of pdfjs-dist
node_modules/ng2-pdf-viewer

@arielpetri
Copy link

Hello! Any solution to this?

@RobJacobs
Copy link

RobJacobs commented Jun 11, 2024

To get around this, I added the following to my package.json:

  "overrides": {
    "ng2-pdf-viewer": {
      "pdfjs-dist": "^4.3.136"
    }
  }

then in the consuming component I had to override the pdfWorkerSrc variable:

constructor() {
  (window as any).pdfWorkerSrc = 'https://cdn.jsdelivr.net/npm/pdfjs-dist@4.3.136/legacy/build/pdf.worker.min.mjs';
}

@arielpetri
Copy link

Thank you! But it doesn't compile when I do that.
It gives me the following error:
Error: node_modules/ng2-pdf-viewer/src/app/pdf-viewer/pdf-viewer.component.d.ts:7:37 - error TS2307: Cannot find module 'pdfjs-dist/web/pdf_viewer' or its corresponding type declarations.

I have the version:
"ng2-pdf-viewer": "^10.2.2",

and
"overrides": {
"ng2-pdf-viewer": {
"pdfjs-dist": "^4.3.136"
}
}

Any suggestions or something I'm missing?

Thanks again!

@shamoon
Copy link
Contributor

shamoon commented Jun 11, 2024

I suggest folks here read the release notes and relevant PRs, the security issue was closed but the pdfjs package itself wasn’t updated all the way so automated alerts like this won’t go away (perhaps they can be dismissed another way, I don’t know). This project is not currently compatible with pdfjs 4.x to my knowledge so the security issue was closed by another valid published means

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

5 participants