CVE-2016-3942: Jsrender Template Injection Vulnerability

MODERATE
Advisory Identifier: GHSA-r87w-47m8-22w3
CVSS 6.3
CWE-94
Published
Advisory Summary

CVE-2016-3942 is a MODERATE (CVSS 6.3) template injection vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Jsrender libraries in the npm ecosystem. The issue involves template injection in jsrender. Remediation is available by upgrading affected packages to version 0.9.74.

CVE-2016-3942 at a Glance

CVE Identifier CVE-2016-3942
GHSA Identifier GHSA-r87w-47m8-22w3
Severity MODERATE
CVSS v3.1 Base Score 6.3
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Jsrender
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability Low (A:L)

How to Fix CVE-2016-3942

To remediate this vulnerability, upgrade all affected Jsrender dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

jsrender fixed: 0.9.74
npm install jsrender@0.9.74
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls jsrender

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2016-3942, inspect your project dependencies using npm:

npm ls jsrender

Analyze the terminal output to locate any version of Jsrender in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.9.74), your application is affected.

Note: The npm ls jsrender command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Jsrender, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

Affected versions of `jsrender` are susceptible to a remote code execution vulnerability when used with server delivered client-side tempates which dynamically embed user input. ## Proof of Concept ```js //POC-REQUEST {{for ~x!=1?(constructor.constructor("return arguments.callee.caller")()):~y(10)}} {{:#data}} {{/for}} ``` ```js //POC-RESPONSE function anonymous(data,view,j,u) { // template var v,t=j._tag,ret="" +t("for",view,this,[ {view:view,tmpl:1, params:{args:['~x!=1?(constructor.constructor(\"return arguments.callee.caller\")()):~y(10)']}, args:[view.hlp("x")!=1?(data.constructor.constructor("return arguments.callee.caller")()):view.hlp("y")(10)], props:{}}]); return ret; } ``` ## Recommendation Update to version 0.9.74 or later.

CVE-2016-3942 Affected Jsrender Versions

1 component(s)
Fixed Versions:
0.9.74
Product / Package Ecosystem Affected Versions Fixed Version
jsrender
npm
< 0.9.74
0.9.74

References

Frequently Asked Questions

What is CVE-2016-3942?
CVE-2016-3942 is a security vulnerability in Jsrender involving Template Injection in jsrender under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Jsrender versions are affected?
Affected versions include releases prior to 0.9.74 across affected packages: jsrender.
What version fixes CVE-2016-3942?
Upgrading to 0.9.74 (or the latest patched release for your respective branch) resolves the vulnerability.
Is jsrender affected?
Yes, jsrender is affected in releases prior to 0.9.74. Upgrade your dependency to 0.9.74 or later.
What is the CVSS score of CVE-2016-3942?
CVE-2016-3942 has a CVSS v3.1 base score of 6.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L.
What CWE is associated with CVE-2016-3942?
CVE-2016-3942 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check npm dependencies for CVE-2016-3942?
Run the dependency tree command: 'npm ls jsrender'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-r87w-47m8-22w3",
  "modified" : "2023-09-07T20:41:26Z",
  "published" : "2020-09-01T15:24:24Z",
  "aliases" : [ "CVE-2016-3942" ],
  "summary" : "Template Injection in jsrender",
  "details" : "Affected versions of `jsrender` are susceptible to a remote code execution vulnerability when used with server delivered client-side tempates which dynamically embed user input.\n\n## Proof of Concept\n\n\n```js\n//POC-REQUEST\n{{for ~x!=1?(constructor.constructor(\"return arguments.callee.caller\")()):~y(10)}}\n{{:#data}}\n{{/for}}\n```\n\n```js\n//POC-RESPONSE\nfunction anonymous(data,view,j,u) { // template var v,t=j._tag,ret=\"\" +t(\"for\",view,this,[ {view:view,tmpl:1, params:{args:['~x!=1?(constructor.constructor(\\\"return arguments.callee.caller\\\")()):~y(10)']}, args:[view.hlp(\"x\")!=1?(data.constructor.constructor(\"return arguments.callee.caller\")()):view.hlp(\"y\")(10)], props:{}}]); return ret; } \n```\n\n\n## Recommendation\n\nUpdate to version 0.9.74 or later.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "jsrender"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.9.74"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.9.73"
    }
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2016-3942"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/BorisMoore/jsrender/commit/f984e139deb0a7648d5b543860ec652c21f6dcf6"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/BorisMoore/jsrender"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-DOTNET-JSRENDER-60173"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/advisories/97"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2020-08-31T18:10:44Z",
    "nvd_published_at" : null
  }
}