Created
December 14, 2019 04:54
-
-
Save mmis1000/1395dd4147fe1093087c09067808e063 to your computer and use it in GitHub Desktop.
Use stack overflow to expose RangeError prototype in other context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
</head> | |
<body> | |
<script> | |
let iframe = document.createElement('iframe') | |
iframe.setAttribute('sandbox', 'allow-same-origin allow-scripts'); | |
iframe.style.display = 'none'; | |
document.body.append(iframe) | |
iframe.contentWindow.eval('window.foo = () => {}') | |
function getLimit (depth = 1) { | |
try { | |
return getLimit(depth + 1) | |
} catch (err) { | |
return depth | |
} | |
} | |
console.log(getLimit()) | |
let err | |
function exhaust(depth, cb) { | |
try { | |
if (depth > 0) { | |
exhaust(depth - 1, cb) | |
} else { | |
cb() | |
} | |
} catch (_err) { | |
err =_err | |
} | |
} | |
exhaust(getLimit(), iframe.contentWindow.foo) | |
console.log(err, err instanceof RangeError) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment