Ecosyste.ms: Advisories
An open API service providing security vulnerability metadata for many open source software ecosystems.
Security Advisories: GSA_kwCzR0hTQS00amcyLTg0YzItcGo5Nc0V7A
Improper Control of Generation of Code ('Code Injection') in @asyncapi/modelina
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.
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
export class CustomClass {
private property: any;
constructor(){console.log("injected")}
private _temp: any;
private additionalProperties: any;
}
Permalink: https://github.com/advisories/GHSA-4jg2-84c2-pj95JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS00amcyLTg0YzItcGo5Nc0V7A
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Critical
Classification: General
Published: over 2 years ago
Updated: over 1 year ago
CVSS Score: 10.0
CVSS vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H
Identifiers: GHSA-4jg2-84c2-pj95, CVE-2023-23619
References:
- https://github.com/asyncapi/modelina/security/advisories/GHSA-4jg2-84c2-pj95
- https://nvd.nist.gov/vuln/detail/CVE-2023-23619
- https://github.com/advisories/GHSA-4jg2-84c2-pj95
Blast Radius: 16.0
Affected Packages
npm:@asyncapi/modelina
Dependent packages: 22Dependent repositories: 40
Downloads: 77,060 last month
Affected Version Ranges: < 1.0.0
Fixed in: 1.0.0
All affected versions: 0.8.0, 0.8.1, 0.8.2, 0.9.0, 0.10.0, 0.10.1, 0.11.0, 0.12.0, 0.13.0, 0.14.0, 0.14.1, 0.15.0, 0.16.0, 0.17.0, 0.18.0, 0.19.0, 0.20.0, 0.20.1, 0.21.0, 0.21.1, 0.21.2, 0.22.0, 0.23.0, 0.23.1, 0.23.2, 0.23.3, 0.24.0, 0.25.0, 0.26.0, 0.27.0, 0.27.1, 0.27.2, 0.27.3, 0.27.4, 0.27.5, 0.28.0, 0.28.1, 0.28.2, 0.28.3, 0.28.4, 0.28.5, 0.29.0, 0.29.1, 0.29.2, 0.29.3, 0.29.4, 0.30.0, 0.30.1, 0.31.0, 0.31.1, 0.31.2, 0.31.3, 0.32.0, 0.32.1, 0.33.0, 0.34.0, 0.35.0, 0.36.0, 0.37.0, 0.38.0, 0.39.0, 0.39.1, 0.39.2, 0.39.3, 0.39.4, 0.39.5, 0.39.6, 0.39.7, 0.39.8, 0.39.9, 0.39.10, 0.39.11, 0.40.0, 0.40.1, 0.40.2, 0.41.0, 0.42.0, 0.42.1, 0.42.2, 0.43.0, 0.44.0, 0.45.0, 0.46.0, 0.46.1, 0.47.0, 0.48.0, 0.49.0, 0.50.0, 0.51.0, 0.52.0, 0.53.0, 0.54.0, 0.55.0, 0.55.1, 0.55.2, 0.56.0, 0.56.1, 0.56.2, 0.56.3, 0.56.4, 0.56.5, 0.56.6, 0.57.0, 0.58.0, 0.59.0, 0.59.1, 0.59.2, 0.59.3, 0.59.4, 0.59.5, 0.59.6, 0.59.7, 0.59.8, 0.59.9
All unaffected versions: 1.0.0, 1.1.0, 1.1.1, 1.2.0, 1.2.1, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.4.0, 1.5.0, 1.6.0, 1.6.1, 1.7.0, 1.7.1, 1.8.0, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.8.5, 1.8.6, 1.8.7, 1.8.8, 1.8.9, 1.8.10, 1.8.11, 1.8.12, 1.9.0, 1.9.1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