[logkitty] RCE via insecure command formatting
The logkitty command-line tool builds a shell command by inserting a user-supplied app name without sanitising it, so shell metacharacters in that name are interpreted by the shell. An attacker who can influence the argument could run arbitrary commands on the machine running logkitty.
- Triaged in 26 hours
- Fixed in 19 days
- Disclosed after 49 days
I would like to report a RCE issue in the logkitty module.
It allows to execute arbitrary commands remotely inside the victim's PC
Module
module name: logkitty
version: 0.7.0
npm page: https://www.npmjs.com/package/logkitty
Module Description
Display pretty Android and iOS logs without Android Studio or Console.app, with intuitive Command Line Interface.
Module Stats
[170,222] downloads in the last week
Vulnerability Description
The issue occurs because a user input is formatted inside a command that will be executed without any check. The issue arises here: https://github.com/zamotany/logkitty/blob/master/src/android/adb.ts#L55
Steps To Reproduce:
- Check there aren't files called
HACKED - Execute the following commands in another terminal:
npm i logkitty # Install affected module
logkitty android app 'test; touch HACKED' # Note the *touch command* is inside the *'* (single quote), so it's an argument, while it will be executed anyway
- Recheck the files: now
HACKEDhas been created :)
Screenshot_from_2020-03-21_01-46-19.png From the original on HackerOne
Patch
Don't format
commandsusing insecureuser's inputs:)
Supporting Material/References:
- [OPERATING SYSTEM VERSION]: Kali Linux
Wrap up
- I contacted the maintainer to let them know: [N]
- I opened an issue in the related repository: [N]
Impact
RCE via command formatting on logkitty
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
Likely the app name argument is concatenated into a shell command string and passed to a shell, so shell metacharacters are interpreted rather than treated as literal text.
Impact
An attacker able to supply the app name argument could execute arbitrary commands on the victim's machine, though this requires the victim to run logkitty with attacker-influenced input.
What the attacker needed
Logkitty installed; victim runs logkitty with attacker-controlled app name
How it was found
- Confirm no file named HACKED exists in the working directory
- Install the affected logkitty module
- Run logkitty with an app name containing a shell separator and a file-creating command
- Check the directory again and observe the new 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.
This tool runs a system command to fetch logs, and it pastes whatever name you give it straight into that command. Because the shell treats characters like semicolons as separators, a crafted name can add extra commands that the tool then runs for you. That means someone who controls the name could make your computer run their code.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.