[samsung-remote] Command injection
The samsung-remote npm module passed the IP address argument straight into a shell command without sanitising it. An attacker who could influence that value could run arbitrary shell commands on the host running the module.
Originally disclosed on HackerOne
- Triaged in 19 days
- Fixed in 20 days
- Disclosed after 20 days
Summary by the program
vulnerable_version: <1.3.5 patched_version: >=1.3.5
The report
I would like to report a command injection vulnerability in the samsung-remote npm module. It allows arbitrary shell command execution through a maliciously crafted argument.
Module
module name: samsung-remote
version: 1.2.5
npm page: https://www.npmjs.com/package/samsung-remote
Module Description
Module for integration of Samsung SmartTV with your NodeJS application. Tested with Samsung D6000 TV. Inspired by this topic http://forum.samygo.tv/viewtopic.php?f=12&t=1792
Module Stats
24 downloads in the last day 217 downloads in the last week 1024 downloads in the last month
Vulnerability
Vulnerability Description
samsung-remote does not sanitize the IP address argument, and subsequently passes it to child_process.exec(), thus allowing arbitrary shell command injection. It is not unlikely that some systems using this package will pass a user-controlled IP address to the function, thus inadvertently allowing arbitrary code execution by the user.
Steps To Reproduce:
- Install samsung-remote:
npm install samsung-remote --save. - Create the following
index.jsfile:
var remote = new SamsungRemote({
ip: '127.0.0.1; touch /tmp/malicious;'
});
remote.isAlive(function(err) {});
- Execute
node index.js - Check that the injected command was executed:
ls /tmp/
Patch
Command execution happens here:
return exec("ping -c 1 " + config.ip, function (error, stdout, stderr) {
exec could be replaced by execFile, which would force developers to separate the command and its arguments.
Supporting Material/References:
- Operating system: Debian GNU/Linux 9.5 (stretch)
- Node.js v8.11.3
- npm v5.6.0
Wrap up
- I contacted the maintainer to let them know: N
- I opened an issue in the related repository: N
Impact
Arbitrary shell command execution.
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 concatenated an untrusted IP address into a shell command string passed to child_process.exec(), so shell metacharacters in the value were interpreted as commands.
Impact
Arbitrary shell command execution, but only where an application passes a user-controlled IP address into the module.
What the attacker needed
Application passes user input as the IP; attacker can influence that value
The fix
The exec call should be replaced with execFile so the command and its arguments are kept separate; the report notes version 1.3.5 and later are patched.
How it was found
- Install the samsung-remote package into a project.
- Write a small script that creates a remote object with a crafted IP address value.
- Run the script with Node.js.
- Check the temporary directory to confirm the extra command ran.
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 package lets a Node.js program talk to a Samsung TV, and it checks the TV is reachable by running a ping command. It builds that command by gluing the IP address onto the end of a text string, so if the address contains extra shell instructions, the computer runs them too. That means whoever controls the address can run their own commands on the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.