OS Command Injection on Jison [all-parser-ports]
The Jison parser generator's C# and PHP port scripts pass command-line arguments directly to a shell command without sanitisation, allowing an attacker to execute arbitrary OS commands. An attacker who can control the argument to these scripts could run any command on the host.
Originally disclosed on HackerOne
- Triaged in 4 hours
- Fixed in 8 months
- Disclosed after 9 months
I would like to report OS Command Injection vulnerability on Jison in parser ports. (CSharp, PHP)
It allows arbitrary OS shell command execution through a crafted command-line argument.
Basic Information
Module: jison
Version: 0.4.18
NPM Project Page: https://www.npmjs.com/package/jison
Module Description
An API for creating parsers in JavaScript
Jison generates bottom-up parsers in JavaScript. Its API is similar to Bison's, hence the name. It supports many of Bison's major features, plus some of its own. If you are new to parser generators such as Bison, and Context-free Grammars in general, a good introduction is found in the Bison manual. If you already know Bison, Jison should be easy to pickup. Briefly, Jison takes a JSON encoded grammar or Bison style grammar and outputs a JavaScript file capable of parsing the language described by that grammar. You can then use the generated script to parse inputs and accept, reject, or perform actions based on the input.
Module Stats
Downloads in the last week: (https://api.npmjs.org/downloads/point/last-week/jison)
downloads : 138857
start : 2019-08-31
end : 2019-09-06
package : jison
Downloads in the last month: (https://api.npmjs.org/downloads/point/last-month/jison)
downloads : 678197
start : 2019-08-08
end : 2019-09-06
package : jison
Stats by npm-stat: https://npm-stat.com/charts.html?package=jison
Vulnerability
Jison has parsing/lexing template to php, C# which don't sanitize process.argv (command line arguments), before passing it to child_process.exec(), hence allowing arbitrary shell command injection.
The vulnerable code is in /ports/csharp/Jison/Jison/csharp.js at csharp.js#L19
console.log("Executing: " + "jison " + process.argv[2]);
exec("jison " + process.argv[2], function (error) {
if (error) {
console.log(error);
return;
}
Steps To Reproduce:
- Installing Jison command-line tool via
npm install jison -g - Obtaining Jison parsing templates :
git clone https://github.com/zaach/jison cd jison/ports/csharp/Jison/Jison/- Payload :
node csharp.js "echo''>pwned" - Check if the attack was successful or not (dummy payload was executed or not):
ls -la
Similarly, /ports/php/php.js is vulnerable too as it contains the same blob (php.js#L19). "" was added just to isolate the payload.
Patch
Sanitizing the input. Using execFile (this method signatures force developers to separate the command and its arguments)
Supporting Material/References:
- Windows 10 1803 (OS Build 17134.950)
- NodeJS Version: v10.16.3
- NPM Version: 6.9.0
Wrap up
- I contacted the maintainer to let them know: N
- I opened an issue in the related repository: N
Impact
Arbitrary OS command execution.
Attachments

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The scripts build a shell command by concatenating a user-supplied command-line argument and pass it to child_process.exec(), which runs it through a shell without sanitisation.
Impact
An attacker could execute arbitrary OS commands on the host running the vulnerable script.
What the attacker needed
Ability to control the command-line argument; Jison port script is run
The fix
The input should be sanitised, and execFile should be used to separate the command from its arguments.
How it was found
- Install the Jison command-line tool globally using npm.
- Clone the Jison repository to obtain the parsing templates.
- Change into the C# port directory.
- Run the C# script with a crafted argument that includes a shell command.
- List the directory to check whether the command created a file.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Jison is a tool that helps programmers build parsers. Some helper scripts for other languages take a command-line argument and run it as part of a system command without checking it. If an attacker can supply that argument, they can make the computer run any command they want.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.