Skip to content
RCE Disclosed report Beginner CVE-2018-16462

[apex-publish-static-files] Command Injection on connectString

The apex-publish-static-files npm module passes the connectString argument directly to execSync without sanitisation, allowing an attacker to inject shell commands. An attacker who controls the connectString value can execute arbitrary shell commands on the host.

abdilahrf_ Follow

Originally disclosed on HackerOne

Critical 10.0 View original
  • Triaged in 2 days
  • Fixed in 44 days
  • Disclosed after 44 days

Summary by the program

vulnerable_versions <= 2.0.0 patched versions >= 2.0.1

The report

I would like to report a command injection vulnerability in the apex-publish-static-files npm module. It allows arbitrary shell command execution through a maliciously crafted argument.

Module

module name: apex-publish-static-files version: 2.0.0 npm page: https://www.npmjs.com/package/apex-publish-static-files

Module Description

Uploads all files from a local directory to Oracle APEX

Module Stats

15 downloads in the last day ~170 downloads in the last month

Vulnerability

Vulnerability Description

apex-publish-static-files does not sanitize the connectionString argument, and subsequently passes it to execSync(), thus allowing arbitrary shell command injection.

Vulnerability Code : https://github.com/vincentmorneau/apex-publish-static-files/blob/master/index.js#54-66

			const childProcess = execSync(
				'"' + opts.sqlclPath + '"' + // Sqlcl path
				' ' + opts.connectString + // Connect string (user/pass@server:port/sid)
				' @"' + path.resolve(__dirname, 'lib/script') + '"' + // Sql to execute
				' "' + path.resolve(__dirname, 'lib/distUpload.js') + '"' + // Param &1 (js to execute)
				' "' + path.resolve(opts.directory) + '"' + // Param &2
				' ' + opts.appID + // Param &3
				' "' + opts.destination + '"' + // Param &4
				' "' + opts.pluginName + '"' // Param &5
				, {
					encoding: 'utf8'
				}
			);

Steps To Reproduce:

  • npm i apex-publish-static-files
  • create index.js file like this :
var publisher = require('apex-publish-static-files');
 
publisher.publish({
connectString: ";cat /etc/passwd ;",
    directory: "public",
    appID: 111
});
  • execute node index.js

F342500

Supporting Material/References:

OS: WSL Ubuntu 16.04 NODE: v10.8.0 NPM : 6.2.0

Wrap up

  • I contacted the maintainer to let them know: N
  • I opened an issue in the related repository: N

Impact

It allows arbitrary shell command execution through a maliciously crafted argument.

Attachments

apex_rce.png
apex_rce.png From the original on HackerOne

The original report as published on HackerOne, by abdilahrf_. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 module concatenates the user-supplied connectString into a shell command passed to execSync without any sanitisation or escaping.

Impact

An attacker could execute arbitrary shell commands on the machine running the module.

What the attacker needed

Attacker controls connectString value; victim runs the module with that value

How it was found

  1. Install the apex-publish-static-files npm package.
  2. Create a script that calls the publish function with a connectString containing shell metacharacters.
  3. Run the script with node, which triggers the injected command.

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.

This is a command injection bug. The module takes a string from the user and runs it as part of a shell command without checking it. If the string contains special shell characters, the attacker can make the computer run extra commands of their choosing.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by abdilahrf_

View all

5 more disclosed reports, best first.

More from Node.js third-party modules

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.