Skip to content

fix: bump vendored pdf.js to 5.7.284 - #82

Merged
andrey-canon merged 1 commit into
open-release/teak.nelpfrom
and/backport-bump-vendored-pdf
Jul 24, 2026
Merged

fix: bump vendored pdf.js to 5.7.284#82
andrey-canon merged 1 commit into
open-release/teak.nelpfrom
and/backport-bump-vendored-pdf

Conversation

@andrey-canon

Copy link
Copy Markdown
Collaborator

Description

This is a backport that fixes the Vendored pdf.js library Contains a remote Code Execution Vulnerability issue.

Reference commit

The previous vendored pdf.js was 1.0.907 (May 2013), four major versions
behind upstream and within the range covered by Mozilla's
GHSA-wgrm-67xf-hhpq (arbitrary JavaScript execution upon opening a
malicious PDF). 5.7.284 is well past the >= 4.2.67 fix line.

The replacement comes from Mozilla's prebuilt
`pdfjs-5.7.284-legacy-dist.zip` GitHub Release artifact rather than the
`pdfjs-dist` npm package because the npm package is library-only -- it
ships `pdf.mjs` plus a bare `PDFViewer` component class, but no
`viewer.html` / `viewer.mjs` / `viewer.css` / locale files. A full npm
integration would mean rewriting the viewer page against the bare
component, which is appropriate as a non-security follow-up but not as
the fix here.

The viewer page (`lms/templates/pdf_viewer.html`) is rewritten as a Mako
adaptation of upstream `web/viewer.html`. A `<base href>` makes the
viewer's relative asset URLs resolve against the vendored copy.

The analytics shim (`lms/static/js/pdf-analytics.js`) is rewritten in
vanilla JS against `PDFViewerApplication.eventBus`. Four analytics
events (`textbook.pdf.thumbnails.toggled`,
`textbook.pdf.thumbnail.navigated`, `textbook.pdf.outline.toggled`,
`textbook.pdf.page.scrolled`) no longer fire because the corresponding
UI elements were refactored away in pdf.js 4.x's Views Manager
redesign.

A new `scripts/refresh-pdfjs-vendor.sh` is the tool for future bumps:
update PDFJS_VERSION + PDFJS_LEGACY_ZIP_SHA256, re-run, commit.

Closes GHSA-mj74-gfq3-2v9f.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@andrey-canon
andrey-canon requested a review from johanseto July 23, 2026 21:13

@johanseto johanseto left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vuln understood. Lets build a image to view it.

@andrey-canon
andrey-canon merged commit df5ebfc into open-release/teak.nelp Jul 24, 2026
46 of 48 checks passed
@andrey-canon
andrey-canon temporarily deployed to open-release/teak.nelp July 24, 2026 16:14 — with GitHub Actions Inactive
@andrey-canon
andrey-canon deployed to open-release/teak.nelp July 24, 2026 16:14 — with GitHub Actions Active
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

Successfully merging this pull request may close these issues.

3 participants