injektio #2
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
const he = require("he") | |
const initial = JSON.parse(he.unescape(window.INITIAL_STATE)) | |
console.log(initial) | |
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
const he = require("he") | |
const {renderToStaticMarkup} = require("react-dom/server"), | |
const page = state => | |
<html> | |
<head> | |
<title>evil</title> | |
</head> | |
<body> | |
<div id="app" /> | |
<script id="state" type="text/javascript" dangerouslySetInnerHTML={{__html: ` | |
window.INITIAL_STATE = ${JSON.stringify(he.escape(JSON.stringify(state)))}; | |
`}}/> | |
<script type="text/javascript" src="/public/bundle.js" /> | |
</body> | |
</html> | |
app.get("/", (req, res) => { | |
const EVIL_MOLLYLLA = { | |
"foo": "<script>alert('lol')</script>", | |
"<script>alert('bal')</script>": "tsers" | |
} | |
res.set("Content-Type", "text/html") | |
res.send(renderToStaticMarkup(page(EVIL_MOLLYLLA))) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment