{"answers":{"affected":"2 open source packages ship an affected version, including ejs. It affects 1 product.","exploited":"It is not confirmed as exploited in the wild, but public exploit code for CVE-2022-29078 exists.","fix":"Upgrade ejs to 3.1.7 or later.","what":"CVE-2022-29078 is a critical code injection vulnerability in n/a, published on 25 Apr 2022. An attacker can exploit it over the internet without logging in, with no action from the victim."},"fix_prompt":"Check this codebase for CVE-2022-29078 and fix it if it is affected.\n\nWhat it is: CVE-2022-29078 is a critical code injection vulnerability in n/a, published on 25 Apr 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.\nExploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2022-29078 exists.\n\nAffected packages and fixed versions:\n- ejs (npm): affected all versions; fixed in 3.1.7\n- ejs (npm): affected all versions; fixed in 3.1.7\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/CVE-2022-29078/ (Markdown: https://insights.sbomify.com/CVE-2022-29078/index.md)","id":"CVE-2022-29078","markdown":"https://insights.sbomify.com/CVE-2022-29078/index.md","name":"CVE-2022-29078","record":{"aliases":["DEBIAN-CVE-2022-29078","GHSA-phwq-j96m-2c2q","ROOT-APP-NPM-CVE-2022-29078","UBUNTU-CVE-2022-29078"],"analysis":{"component_type":"library","fix_type":"upgrade","impacts":["code_execution"],"network_reachable":"yes","non_default_config":false,"product_category":"Node.js EJS library","requires_auth":"none","summary":"Attackers can execute arbitrary OS commands via server-side template injection in the EJS library, requiring immediate upgrades.","user_interaction":"not_required","vuln_class":"code_injection"},"analysis_generated_by":"qwen3.8-flash-next","assigner":"mitre","cpe":[{"product":"ejs","vendor":"ejs"}],"cvss":{"score":9.8,"severity":"critical","source":"nvd","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","version":"3.1"},"cwes":[{"id":"CWE-94","name":"Improper Control of Generation of Code"}],"description":"The ejs (aka Embedded JavaScript templates) package 3.1.6 for Node.js allows server-side template injection in settings[view options][outputFunctionName]. This is parsed as an internal option, and overwrites the outputFunctionName option with an arbitrary OS command (which is executed upon template compilation).","ecosystems":["npm"],"exploits":{"exploitdb":0,"first_seen":"2022-07-20","github_poc":9,"max_poc_stars":8,"metasploit":0,"nuclei":1,"refs":[{"date":"2022-07-20T10:10:01Z","kind":"github_poc","ref":"https://github.com/miko550/CVE-2022-29078","stars":8,"title":"vuln ejs 3.1.6 docker"},{"date":"2024-11-05T06:15:45Z","kind":"github_poc","ref":"https://github.com/l0n3m4n/CVE-2022-29078","stars":3,"title":"Serverside Template Injection (SSTI) RCE - THM challenge \"whiterose\"    "},{"date":"2023-07-26T18:42:09Z","kind":"github_poc","ref":"https://github.com/shurochka1396/expluatation_CVE-2022-29078","stars":0,"title":null},{"date":"2025-01-07T22:07:52Z","kind":"github_poc","ref":"https://github.com/chuckdu21/CVE-2022-29078","stars":0,"title":"PoC for CVE-2022-29078"},{"date":"2026-02-15T20:49:37Z","kind":"github_poc","ref":"https://github.com/AlonNavon/npm-demo","stars":0,"title":"Browser demo: EJS template injection (CVE-2022-29078) with Seal Security remediation"},{"date":"2026-04-12T13:24:50Z","kind":"github_poc","ref":"https://github.com/amusedx/CVE-2022-29078","stars":0,"title":null},{"date":"2026-06-24T21:17:19Z","kind":"github_poc","ref":"https://github.com/test-avm-714877d2df585126/vuln-ejs-critical","stars":0,"title":"npm repo with ejs CVE-2022-29078 (CVSS 9.8, EPSS 32%) for Dependabot automerge testing"},{"date":"2026-06-24T22:42:24Z","kind":"github_poc","ref":"https://github.com/test-avm-714877d2df585126/C-test-2","stars":0,"title":"Dependabot security automerge test - ejs CVE-2022-29078"}],"tier":"weaponised"},"has_fix":true,"headline":"ejs template injection vulnerability","id":"CVE-2022-29078","indexable":true,"kev":null,"kind":"cve","links":{"ecosystem":"npm","product":null,"products":[],"type":"code_injection","year":"2022"},"n_packages":2,"n_references":3,"next":{"headline":"Command injection in npm-dependency-versions","id":"CVE-2022-29080"},"packages":[{"ecosystem":"npm","fixed":["3.1.7"],"introduced":["0"],"last_affected":[],"package":"ejs","purl":null,"source":"GHSA-phwq-j96m-2c2q"},{"ecosystem":"npm","fixed":["3.1.7"],"introduced":["0"],"last_affected":[],"package":"ejs","purl":"pkg:npm/ejs","source":"GHSA-phwq-j96m-2c2q"}],"prev":{"headline":"Memory corruption in n/a","id":"CVE-2022-29077"},"products":["n/a"],"published":"2022-04-25","related":[{"cvss_score":9.8,"headline":"Code injection in n/a","id":"CVE-2023-29827","kev_date_added":null,"published":"2023-05-04"},{"cvss_score":9.8,"headline":"ejs is vulnerable to remote code execution due to weak input validation","id":"CVE-2017-1000228","kev_date_added":null,"published":"2017-11-17"},{"cvss_score":7.5,"headline":"ejs vulnerable to DoS due to weak input validation","id":"CVE-2017-1000189","kev_date_added":null,"published":"2017-11-17"},{"cvss_score":6.1,"headline":"mde ejs vulnerable to XSS","id":"CVE-2017-1000188","kev_date_added":null,"published":"2017-11-17"}],"sources":[{"class":"attribution","licence":"CVE Terms of Use (MITRE)","name":"CVE List","prefix":"CVE"},{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"},{"class":"attribution","licence":"US public information, NVD API terms","name":"NVD"},{"class":"attribution","licence":"CWE Terms of Use","name":"CWE (MITRE)"},{"class":"attribution","licence":"FIRST CVSS licence","name":"CVSS (FIRST)"},{"class":"open","licence":"CC0","name":"PoC-in-GitHub"}],"ssvc":{"automatable":null,"exploitation":null,"technical_impact":null},"state":"PUBLISHED","updated":"2024-08-03","vendors":["n/a"]},"summary":"Attackers can execute arbitrary OS commands via server-side template injection in the EJS library, requiring immediate upgrades.","url":"https://insights.sbomify.com/CVE-2022-29078/"}