CVE-2023-23619: @asyncapi/modelina Improper Control Of Generation Of Vulnerability

CRITICAL
Advisory Identifier: GHSA-4jg2-84c2-pj95
CVSS 9.9
CWE-94
Published
Advisory Summary

CVE-2023-23619 is a CRITICAL (CVSS 9.9) improper control of generation of vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting @asyncapi/modelina libraries in the npm ecosystem. The issue involves improper control of generation of code ('code injection') in @asyncapi/modelina. Remediation is available by upgrading affected packages to version 1.0.0.

CVE-2023-23619 at a Glance

CVE Identifier CVE-2023-23619
GHSA Identifier GHSA-4jg2-84c2-pj95
Severity CRITICAL
CVSS v3.1 Base Score 9.9
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product @asyncapi/modelina
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 9.9

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:C/C:H/I:H/A:H).

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

How to Fix CVE-2023-23619

To remediate this vulnerability, upgrade all affected @asyncapi/modelina 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/modelina fixed: 1.0.0
npm install @asyncapi/modelina@1.0.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/modelina

How to Check if You Are Affected

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

npm ls @asyncapi/modelina

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

Note: The npm ls @asyncapi/modelina 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 @asyncapi/modelina, 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

### Impact Anyone who is using the default presets and/or does not handle the functionality themself. ### Patches It is impossible to fully guard against this, because users have access to the original raw information. However, as of version 1, if you only access the constrained models, you will not encounter this issue. Further similar situations are NOT seen as a security issue, but intended behavior. ### Workarounds Fully custom presets that change the entire rendering process which can then escape the user input. ### For more information Even though that I changed all the presets here, the vulnerability is still present throughout. I am using a JSON Schema here for simplicity. ```ts const jsonSchemaDoc = { $id: 'CustomClass', type: 'object', properties: { 'property: any; \n constructor(){console.log("injected")} \n private _temp': { type: 'string' }, } }; generator = new TypeScriptGenerator( { presets: [ { class: { property({ propertyName, content }) { return `private ${propertyName}: any;`; }, ctor() { return ''; }, getter() { return ''; }, setter() { return ''; } } } ] } ); const inputModel = await generator.process(jsonSchemaDoc); ``` This would render ```ts export class CustomClass { private property: any; constructor(){console.log("injected")} private _temp: any; private additionalProperties: any; } ```

CVE-2023-23619 Affected @asyncapi/modelina Versions

1 component(s)
Fixed Versions:
1.0.0
Product / Package Ecosystem Affected Versions Fixed Version
@asyncapi/modelina
npm
< 1.0.0
1.0.0

References

Frequently Asked Questions

What is CVE-2023-23619?
CVE-2023-23619 is a security vulnerability in @asyncapi/modelina involving Improper Control of Generation of Code ('Code Injection') in @asyncapi/modelina under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which @asyncapi/modelina versions are affected?
Affected versions include releases prior to 1.0.0 across affected packages: @asyncapi/modelina.
What version fixes CVE-2023-23619?
Upgrading to 1.0.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @asyncapi/modelina affected?
Yes, @asyncapi/modelina is affected in releases prior to 1.0.0. Upgrade your dependency to 1.0.0 or later.
What is the CVSS score of CVE-2023-23619?
CVE-2023-23619 has a CVSS v3.1 base score of 9.9 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2023-23619?
CVE-2023-23619 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-2023-23619?
Run the dependency tree command: 'npm ls @asyncapi/modelina'. 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-4jg2-84c2-pj95",
  "modified" : "2023-01-26T21:57:36Z",
  "published" : "2021-09-21T18:41:59Z",
  "aliases" : [ "CVE-2023-23619" ],
  "summary" : "Improper Control of Generation of Code ('Code Injection') in @asyncapi/modelina",
  "details" : "### Impact\nAnyone who is using the default presets and/or does not handle the functionality themself.\n\n### Patches\nIt is impossible to fully guard against this, because users have access to the original raw information. However, as of version 1, if you only access the constrained models, you will not encounter this issue.\n\nFurther similar situations are NOT seen as a security issue, but intended behavior.\n\n### Workarounds\nFully custom presets that change the entire rendering process which can then escape the user input.\n\n### For more information\nEven though that I changed all the presets here, the vulnerability is still present throughout. I am using a JSON Schema here for simplicity.\n```ts\nconst jsonSchemaDoc = {\n  $id: 'CustomClass',\n  type: 'object',\n  properties: {\n      'property: any; \\n constructor(){console.log(\"injected\")} \\n private _temp': { type: 'string' },\n  }\n};\ngenerator = new TypeScriptGenerator(\n  { \n    presets: [\n      {\n        class: {\n            property({ propertyName, content }) {\n              return `private ${propertyName}: any;`;\n            },\n            ctor() {\n              return '';\n            },\n            getter() {\n              return '';\n            },\n            setter() {\n              return '';\n            }\n        }\n      }\n    ]\n  }\n);\nconst inputModel = await generator.process(jsonSchemaDoc);\n```\nThis would render\n```ts\nexport class CustomClass {\n  private property: any; \n   constructor(){console.log(\"injected\")} \n   private _temp: any;\n  private additionalProperties: any;\n}\n```",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@asyncapi/modelina"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.0.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/asyncapi/modelina/security/advisories/GHSA-4jg2-84c2-pj95"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-23619"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/asyncapi/modelina"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-09-21T16:14:04Z",
    "nvd_published_at" : "2023-01-26T21:18:00Z"
  }
}