Skip to content

Instantly share code, notes, and snippets.

@MarkTiedemann
Created April 11, 2022 21:24
Show Gist options
  • Save MarkTiedemann/8a3e32dc74b3f39259c72f3266addd93 to your computer and use it in GitHub Desktop.
Save MarkTiedemann/8a3e32dc74b3f39259c72f3266addd93 to your computer and use it in GitHub Desktop.
// node --experimental-policy=policy.json evil.mjs
import fs from "node:fs";
console.log(fs.readFileSync("./no-secret.txt", "utf-8"));
console.log(fs.readFileSync("./secret.txt", "utf-8"));
{
"resources": {
"./evil.mjs": {
"integrity": "sha384-vQrig6cXCYAM1yBwyPtZbPXQEy2rZ+Ee/Y62ejWGyFHW/aPGsj62WTH3c42fpqKp",
"dependencies": {
"node:fs": "./safe-fs.mjs"
}
},
"./safe-fs.mjs": {
"integrity": "sha384-8RhRmwj65XTzvjg3xZP4GS0FTGSMVRBvbAlzJT9SJhtahMmPMWPb3+PylFTJ9IWq",
"dependencies": {
"node:fs": true
}
}
}
}
import fs from "node:fs";
function readFileSync(filename, encoding) {
if (filename === "./no-secret.txt") {
return fs.readFileSync(filename, encoding);
} else {
return "";
}
}
export default { readFileSync };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment