CVE-2019-18413: SQL Injection and Cross-site Scripting in class-validator

class-validator Updated 02 Oct 2025

Summary

12/10/2021
Yes i
Critical
9.8

CVE-2019-18413: SQL Injection and Cross-site Scripting in class-validator. Affects class-validator versions < 0.14.0. Fixed in 0.14.0. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

class-validator is an npm package that provides input validation for TypeScript and JavaScript applications. It allows developers to define and enforce validation rules for various data types. However, a vulnerability exists in the package that allows attackers to bypass input validation and launch SQL Injection or Cross-site Scripting (XSS) attacks. This vulnerability arises due to the ability to overwrite internal attributes via a conflicting name. By injecting malicious input, an attacker can exploit this vulnerability to execute arbitrary SQL queries or inject malicious scripts into web pages.

Vulnerability Detail

The vulnerability in class-validator lies in the validate() function, where input validation can be bypassed by overwriting certain internal attributes. This can be achieved by using a conflicting name. Although there is an optional parameter called forbidUnknownValues that can reduce the risk of this bypass, it is not documented, and most developers configure input validation in the vulnerable default manner. As a result, attackers can exploit this vulnerability to perform SQL Injection or XSS attacks. The impact of these attacks can range from unauthorized data access to the execution of arbitrary code on the affected system.

How To Fix

Minimum fixed version

0.14.0

This is the first release that contains the fix.

npm install class-validator@0.14.0

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If updating the package is not immediately feasible, a temporary workaround is to explicitly set the forbidUnknownValues parameter to true when using the validate() function. This can be done by modifying the code as follows:

validate(input, { forbidUnknownValues: true });

Conclusion

In conclusion, the class-validator package is vulnerable to SQL Injection and Cross-site Scripting attacks due to a bypass in input validation. To mitigate this vulnerability, it is crucial to update the package to version 0.14.0 or later. Alternatively, the forbidUnknownValues parameter can be set to true as a temporary workaround. For further assistance with vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for class-validator →

Share this vulnerability

FAQ

class-validator is an npm package that provides input validation for TypeScript and JavaScript applications. It allows developers to define and enforce validation rules for various data types.

This vulnerability allows attackers to bypass input validation and launch SQL Injection or Cross-site Scripting (XSS) attacks. The impact can range from unauthorized data access to the execution of arbitrary code on the affected system.

To fix this vulnerability, update the class-validator package to version 0.14.0 or later. This version includes changes to the default settings that mitigate the risk of the bypass.

Yes, if updating the package is not immediately feasible, a temporary workaround is to explicitly set the forbidUnknownValues parameter to true when using the validate() function.

For more information about this vulnerability, you can refer to the GitHub Security Advisory GHSA-fj58-h2fr-3pp2 or the Vulert Playground at Vulert Scanner.

How To Fix

Minimum fixed version

0.14.0

This is the first release that contains the fix.

npm install class-validator@0.14.0

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback