The vulnerability exists in the swagger-typescript-api package, where an unescaped servers[0].url value from an OpenAPI specification can lead to code injection in the generated client code. The root cause is the createApiConfig function within the CodeGenProcess class in src/code-gen-process.ts. This function reads the serverUrl and uses it to populate the baseUrl configuration property without proper escaping.
The provided patch 306d59acb8ffbb00f953f807b97234b21f51d9de confirms this. The change in src/code-gen-process.ts modifies the createApiConfig function to wrap the serverUrl with a newly added escapeJsStringLiteral utility function. This prevents the injection by ensuring that any special characters in the URL are properly escaped before being inserted into the generated code template. The exploitation of this vulnerability would cause the CodeGenProcess.createApiConfig function to process the malicious input, making it the primary vulnerable function that would appear in a runtime profile during the code generation phase.