Command Injection in nodemailer
Someday, i read some product code and found out that application using nodemailer to send email. After spending some second to audit package-lock file, i saw it had this CVE.
But i read that details and their POC, i still not understand what they want to deliver.
Found their commit to fix their bug and already know where the bug from
https://github.com/nodemailer/nodemailer/commit/ba31c64c910d884579875c52d57ac45acc47aa54
It comes from send function, with arbitrary command flag injection in sendmail transport.
I found they have their test case that
Yeah it just work on Unix-base OS and i test it with my Windows laptop :)))))
But I dig deeper and find some good things
This is their constructor and we can find good things that we can control
path, args variable by passing these property in options
So i craft this one to exploit
It will list all file in directory /
But i see that almost developer don’t use send function to send email, they use sendMail instead
Then i have to read code again and i found we can exploit not just from send function.
In this code in library
It will bind new SendmailTransport if in options contain property sendmail
So i will define sendmail property without falsy value like this one, and tada we can inject command flag
But if we can find in that application have vulnerable with Prototype Pollution, you can RCE it with this one
https://book.hacktricks.xyz/pentesting-web/deserialization/nodejs-proto-prototype-pollution/prototype-pollution-to-rce#spawn-exploitation
Because it use spawn of child_process that i show before
And that application will f* up :)))))))
So, i show you 2 ways to exploit with that CVE, kkkk