Packages / class-validator / Security

CriticalVulnerabilityGHSA-fj58-h2fr-3pp2CVE-2019-18413Published 12 Oct 2021

SQL Injection and Cross-site Scripting in class-validator

Affected releases · class-validator

  • 0.13.x and older0.3.0 – 0.13.2No fix, no longer updated

0.13.x has no fix yet; the newest fixed line:

npm install class-validator@0.14.0
  1. Affected

    0.3.0 – 0.13.2

    38 releases

  2. Fixed

    0.14.0 – 0.15.1

    6 releases, latest

44 stable releases of class-validator, oldest to newest.

Is your project affected?

Paste your package.json, or type the range you declare for class-validator. It is read in your browser and sent nowhere.

What happens

In TypeStack class-validator, validate() input validation can be bypassed because certain internal attributes can be overwritten via a conflicting name. Even though there is an optional forbidUnknownValues parameter that can be used to reduce the risk of this bypass, this option is not documented and thus most developers configure input validation in the vulnerable default manner. With this vulnerability, attackers can launch SQL Injection or XSS attacks by injecting arbitrary malicious input.

The default settings for forbidUnknownValues has been changed to true in 0.14.0.

NOTE: a software maintainer agrees with the "is not documented" finding but suggests that much of the responsibility for the risk lies in a different product.