Skip to content

Commit 260295b

Browse files
committed
Force isEvalSupported to true
Fixes [GHSA-wgrm-67xf-hhpq](GHSA-wgrm-67xf-hhpq)
1 parent 93b09c3 commit 260295b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/react-pdf/src/Document.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ export type DocumentProps = {
196196
*
197197
* **Note**: Make sure to define options object outside of your React component, and use `useMemo` if you can't.
198198
*
199+
* **Note**: `isEvalSupported` is forced to `false` to prevent [arbitrary JavaScript execution upon opening a malicious PDF file](https://github.com/mozilla/pdf.js/security/advisories/GHSA-wgrm-67xf-hhpq).
200+
*
199201
* @example { cMapUrl: '/cmaps/' }
200202
*/
201203
options?: Options;
@@ -516,12 +518,12 @@ const Document = forwardRef(function Document(
516518
return;
517519
}
518520

519-
const documentInitParams = options
520-
? {
521-
...source,
522-
...options,
523-
}
524-
: source;
521+
const optionsWithModifiedIsEvalSupported: Options = { ...options, isEvalSupported: true };
522+
523+
const documentInitParams: Source = {
524+
...source,
525+
...optionsWithModifiedIsEvalSupported,
526+
};
525527

526528
const destroyable = pdfjs.getDocument(documentInitParams);
527529
if (onLoadProgress) {

0 commit comments

Comments
 (0)