CVE-2021-37694: Spring Framework Code Injection Issue For Java-spring-cloud-stream-template Vulnerability

HIGH
Advisory Identifier: GHSA-xj6r-2jpm-qvxp
CVSS 8.7
CWE-94
Published
Advisory Summary

CVE-2021-37694 is a HIGH (CVSS 8.7) code injection issue for java-spring-cloud-stream-template vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Spring Framework libraries in the npm ecosystem. The issue involves code injection issue for java-spring-cloud-stream-template. Remediation is available by upgrading affected packages to version 0.7.0.

CVE-2021-37694 at a Glance

CVE Identifier CVE-2021-37694
GHSA Identifier GHSA-xj6r-2jpm-qvxp
Severity HIGH
CVSS v3.1 Base Score 8.7
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Spring Framework
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 8.7

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

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

How to Fix CVE-2021-37694

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

@asyncapi/java-spring-cloud-stream-template fixed: 0.7.0
npm install @asyncapi/java-spring-cloud-stream-template@0.7.0
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 @asyncapi/java-spring-cloud-stream-template

How to Check if You Are Affected

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

npm ls @asyncapi/java-spring-cloud-stream-template

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

Note: The npm ls @asyncapi/java-spring-cloud-stream-template 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 Spring Framework, 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

The following was initially reported by @jonaslagoni: Given the following command: `ag ./dummy.json @asyncapi/java-spring-cloud-stream-template --force-write --output ./output` With the following AsyncAPI document: ```json { "asyncapi": "2.0.0", "info": { "title": "Streetlight", "version": "1.0.0" }, "defaultContentType": "json", "channels": { "security/audit/channel": { "description": "Channel for the turn on command which should turn on the streetlight", "parameters": { "streetlight_id": { "description": "The ID of the streetlight", "schema": { "type": "string" } } }, "publish": { "operationId": "test() { System.out.println(\"injected\"); return test(0); }\n public Consumer<CustomClass> someothername", "message": { "name": "TurnonCommand", "payload": { "$ref": "#/components/schemas/CustomClass" } } } } }, "components": { "schemas" : { "CustomClass": { "type": "object", "properties": { "prop": { "type": "string" } } } } } } ``` Which changes the following output: ```java ... @Bean public Consumer<CustomClass> test() { // Add business logic here. return null; } ... ``` To ```java ... @Bean public Consumer<CustomClass> test() { System.out.println("injected"); return someothername(); } public Consumer<CustomClass> someothername() { // Add business logic here. return null; } ... ```

CVE-2021-37694 Affected Spring Framework Versions

1 component(s)
Fixed Versions:
0.7.0
Product / Package Ecosystem Affected Versions Fixed Version
@asyncapi/java-spring-cloud-stream-template
npm
< 0.7.0
0.7.0

References

Frequently Asked Questions

What is CVE-2021-37694?
CVE-2021-37694 is a security vulnerability in Spring Framework involving Code injection issue for java-spring-cloud-stream-template under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Spring Framework versions are affected?
Affected versions include releases prior to 0.7.0 across affected packages: @asyncapi/java-spring-cloud-stream-template.
What version fixes CVE-2021-37694?
Upgrading to 0.7.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @asyncapi/java-spring-cloud-stream-template affected?
Yes, @asyncapi/java-spring-cloud-stream-template is affected in releases prior to 0.7.0. Upgrade your dependency to 0.7.0 or later.
What is the CVSS score of CVE-2021-37694?
CVE-2021-37694 has a CVSS v3.1 base score of 8.7 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:N.
What CWE is associated with CVE-2021-37694?
CVE-2021-37694 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-2021-37694?
Run the dependency tree command: 'npm ls @asyncapi/java-spring-cloud-stream-template'. 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-xj6r-2jpm-qvxp",
  "modified" : "2021-08-24T18:50:59Z",
  "published" : "2021-08-25T14:45:52Z",
  "aliases" : [ "CVE-2021-37694" ],
  "summary" : "Code injection issue for java-spring-cloud-stream-template",
  "details" : "The following was initially reported by @jonaslagoni:\n\nGiven the following command:\n`ag ./dummy.json @asyncapi/java-spring-cloud-stream-template --force-write --output ./output`\n\nWith the following AsyncAPI document:\n```json\n{\n  \"asyncapi\": \"2.0.0\",\n  \"info\": {\n    \"title\": \"Streetlight\",\n    \"version\": \"1.0.0\"\n  },\n  \"defaultContentType\": \"json\",\n  \"channels\": {\n    \"security/audit/channel\": {\n      \"description\": \"Channel for the turn on command which should turn on the streetlight\",\n      \"parameters\": {\n        \"streetlight_id\": {\n          \"description\": \"The ID of the streetlight\",\n          \"schema\": {\n            \"type\": \"string\"\n          }\n        }\n      },\n      \"publish\": {\n        \"operationId\": \"test() { System.out.println(\\\"injected\\\"); return test(0); }\\n public Consumer<CustomClass> someothername\",\n        \"message\": {\n          \"name\": \"TurnonCommand\",\n          \"payload\": {\n            \"$ref\": \"#/components/schemas/CustomClass\"\n          }\n        }\n      }\n    }\n  },\n  \"components\": {\n    \"schemas\" : {\n      \"CustomClass\": {\n        \"type\": \"object\",\n        \"properties\": {\n          \"prop\": { \n              \"type\": \"string\"\n          }\n        }\n      }\n    }\n  }\n}\n```\n\nWhich changes the following output: \n\n```java\n...\n  @Bean\n  public Consumer<CustomClass> test() {\n    // Add business logic here.\n    return null;\n  }\n...\n```\nTo\n```java\n...\n  @Bean\n  public Consumer<CustomClass> test() { System.out.println(\"injected\"); return someothername(); }\n  public Consumer<CustomClass> someothername() {\n    // Add business logic here.\n    return null;\n  }\n...\n```",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@asyncapi/java-spring-cloud-stream-template"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.7.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.6.9"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/asyncapi/java-spring-cloud-stream-template/security/advisories/GHSA-xj6r-2jpm-qvxp"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-37694"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/asyncapi/java-spring-cloud-stream-template"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-08-24T18:50:59Z",
    "nvd_published_at" : "2021-08-11T18:15:00Z"
  }
}