Reputation: 3034
I'm prototyping an Electron app that can open provided files in a third party photo editor, using Node's childProcess
API:
const process = childProcess.spawn(
'open',
['-a', 'Polarr Photo Editor', filename],
{shell: false}
);
I'm a little concerned about the security of passing in an unsanitised filename
as a parameter. For context, here's how the app might work:
My concern is that a MITM attack around stage 1 could mean a user downloads a maliciously named file, a filename that can do evil things when passed as a parameter to spawn
, e.g. myCoolFile && doEvilThing ;.jpg
.
I have done a little testing, and haven't found any obvious exploits yet, but I'm worried I might be missing something.
Therefore I'd like to know:
spawn
hijack the command, produce evil side effects - do anything unexpected or undesirable in the hands of a malicious user?Upvotes: 1
Views: 841
Reputation: 2910
I don't see this as a security issue. There is two reasons
First one is the filename is only a parameter that is send to a third party application. So that executable should validate the parameter to check weather it is a file or not. If it doesn't it is out of your scope and you may have to ask them to fix that or alternatively validate it is a filename.
And the second reason is this happens in the client side, So the user will be responsible for passing the filename, even if it's done manually. You have no control over what he might execute on his own system and that is okay. Even though you made it impossible.
You user can always execute open -a Polarr Photo Editor anything_he_want
on his terminal if he want to crack it.
Upvotes: 1