-
-
Notifications
You must be signed in to change notification settings - Fork 37
Security Fix for RCE on "easy-pdf-merge" - huntr.dev #28
base: master
Are you sure you want to change the base?
Conversation
Fixed RCE on easy-pdf-merge
@Asjidkalam Thanks for this PR. I'm still reading and trying to understand stuff here 😅 The first question I had in my mind was - why is the vulnerability out in the open? I thought Security issues and Security vulnerabilities are first privately informed to maintainers through email or similar platform and the project's security issue is fixed and then the vulnerability and the fix is told to the world. The current way how this is done looks more like mocking all the npm and other package maintainers - putting all the vulnerabilities out in the open. The good part is you raised a PR yes. I need to review and merge it. I'm assuming the same is happening with any repo that is present on https://github.com/418sec/huntr . And sometimes review might take time. Since this open now, I'm just overwhelmed and rushing! I see this more as a bad practice. Correct me if I'm wrong. cc @JamieSlome as you seem to be part of https://github.com/418sec |
I understand that I'll consider this as a rare case in my perspective and take the PR so that the users don't have to think too much about such security issues or have to worry about sanitization of user input before passing it to the library. Note: I'm really not maintaining this small module much. I hope no one is using it in production for some critical thing! This is a very simple small module. Someone could just copy paste the code and use their own function to do it with some customization too probably |
@karuppiah7890 - thanks for your feedback and for getting in touch with us. I have responded to you on Twitter and also partially addressed your point in your GitHub Issue. Cheers! 🍰 |
I should have setup CI/CD for this. Anyways, there's just a very simple single test file for this, which doesn't run as part of this PR. The happy path for the module is not satisfied by this PR
This is because of one existing extra space in the command, which wasn't an issue before, but with this PR, this became an issue |
I have pushed some changes in The happy path still fails
|
I think the behavior of |
@Asjidkalam Do you want to look into this? |
Also, please rebase with master while doing so |
https://huntr.dev/users/Asjidkalam has fixed the RCE on "easy-pdf-merge" vulnerability 🔨. Asjidkalam has been awarded $25 for fixing the vulnerability through the huntr bug bounty program 💵. Think you could fix a vulnerability like this?
Get involved at https://huntr.dev/
Q | A
Version Affected | ALL
Bug Fix | YES
Original Pull Request | 418sec#1
Vulnerability README | https://github.com/418sec/huntr/blob/master/bounties/npm/easy-pdf-merge/1/README.md
User Comments:
📊 Metadata *
Remote code execution vulnerability
Bounty URL: https://www.huntr.dev/bounties/1-npm-easy-pdf-merge
⚙️ Description *
The
easy-pdf-merge module
is vulnerable against RCE since user supplied inputs are formatted inside a command which is executed without prior checks. The argument options can be controlled by users without any sanitization. It was usingexec()
function which is vulnerable to Command Injection if it accepts user input and it goes through any sanitization or escaping.💻 Technical Description *
The use of the
child_process
functionexec()
is highly discouraged if you accept user input and don't sanitize/escape them. I replaced it withexecFile()
which mitigates any possible Command Injections as it accepts input as arrays.🐛 Proof of Concept (PoC) *
Install the package and run the below code:
A file named
HACKED
will be created in the current working directory.🔥 Proof of Fix (PoF) *
After applying the fix, run the PoC again and no files will be created. Hence command injection is mitigated.
👍 User Acceptance Testing (UAT)
Only
execFile
is used, no breaking changes introduced.