CVE-2026-54662: swagger-typescript-api vulnerable to code injection via unescaped `servers[0].url` in fetch http-client template
swagger-typescript-api interpolates servers[0].url directly into a TypeScript class-body field initializer of the generated fetch HttpClient (templates/base/http-clients/fetch-http-client.ejs:75), without any escaping. A malicious URL containing a " closes the string literal that initializes public baseUrl and exposes the surrounding class body to injection. The most direct exploit declares a new static field whose initializer is an async IIFE — TypeScript evaluates static field initializers at class definition time, which is at module load. A consumer who imports the generated client (or anything that transitively imports it) executes the injected code with no further interaction — no instantiation, no method call, no use of the baseUrl. The attacker controls the OpenAPI spec; the victim is whoever runs the generator and imports the result.
This is the highest-impact sink in the package: the trigger requires only a bare import of the generated module.
References
- github.com/acacode/swagger-typescript-api/commit/306d59acb8ffbb00f953f807b97234b21f51d9de
- github.com/acacode/swagger-typescript-api/pull/1779
- github.com/acacode/swagger-typescript-api/releases/tag/v13.12.2
- github.com/acacode/swagger-typescript-api/security/advisories/GHSA-hqj5-cw9f-rx67
- github.com/advisories/GHSA-hqj5-cw9f-rx67
- nvd.nist.gov/vuln/detail/CVE-2026-54662
Code Behaviors & Features
Detect and mitigate CVE-2026-54662 with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →