Ecosyste.ms: Advisories
An open API service providing security vulnerability metadata for many open source software ecosystems.
Security Advisories: GSA_kwCzR0hTQS1tdnJwLTNjdngtYzMyNc4AA2PO
Zod denial of service vulnerability during email validation
Impact
API servers running express-zod-api
having:
- version of
express-zod-api
below10.0.0-beta1
, - and using the following (or similar) validation schema in its implementation:
z.string().email()
,
are vulnerable to a DoS attack due to:
- Inefficient Regular Expression Complexity in
zod
versions up to3.22.2
, - depending on
zod
.
Patches
The patched version of zod
fixing the vulnerability is 3.22.3
.
However, it's highly recommended to upgrade express-zod-api
to at least version 10.0.0
, which does not depend on zod
strictly and directly, but requires its installation as a peer dependency instead, enabling you to install the patched zod
version yourself.
Workarounds
When it's not possible to upgrade your dependencies, consider the following replacement in your implementation:
- z.string().email()
+ z.string().regex(
+ /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i
+ )
This regular expression is taken from the suggested patch of zod
.
References
- Original issue: https://github.com/colinhacks/zod/issues/2609
- The patch: https://github.com/colinhacks/zod/pull/2824
- Entry in database: https://nvd.nist.gov/vuln/detail/CVE-2023-4316
- Enumeration: https://cwe.mitre.org/data/definitions/1333.html
- Parent advisory: https://github.com/advisories/GHSA-m95q-7qp3-xv42
- Changelog entry for
express-zod-api
version10.0.0-beta1
: https://github.com/RobinTail/express-zod-api/blob/master/CHANGELOG.md#v1000-beta1
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS1tdnJwLTNjdngtYzMyNc4AA2PO
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: about 1 year ago
Updated: about 1 year ago
CVSS Score: 7.5
CVSS vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Identifiers: GHSA-mvrp-3cvx-c325
References:
- https://github.com/RobinTail/express-zod-api/security/advisories/GHSA-mvrp-3cvx-c325
- https://github.com/colinhacks/zod/issues/2609
- https://github.com/colinhacks/zod/pull/2824
- https://github.com/advisories/GHSA-m95q-7qp3-xv42
- https://github.com/advisories/GHSA-mvrp-3cvx-c325
Blast Radius: 5.2
Affected Packages
npm:express-zod-api
Dependent packages: 3Dependent repositories: 5
Downloads: 20,256 last month
Affected Version Ranges: < 10.0.0-beta1
Fixed in: 10.0.0-beta1
All affected versions: 0.2.2, 0.2.3, 0.2.4, 0.3.0, 0.3.1, 0.4.0, 0.4.1, 0.5.0, 0.6.0, 0.6.1, 0.7.0, 0.7.1, 0.7.2, 1.0.0, 1.1.0, 1.2.0, 1.2.1, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 2.0.0, 2.1.0, 2.1.1, 2.2.0, 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.4.0, 2.5.0, 2.5.1, 2.5.2, 2.6.0, 2.7.0, 2.8.0, 2.8.1, 2.8.2, 2.9.0, 2.10.0, 2.10.1, 2.10.2, 3.0.0, 3.1.1, 3.1.2, 3.2.0, 4.0.0, 4.1.0, 4.2.0, 5.0.0, 5.1.0, 5.2.0, 5.2.1, 5.3.0, 5.3.1, 5.3.2, 5.3.3, 5.4.0, 5.4.1, 5.4.2, 5.5.0, 5.5.1, 5.5.2, 5.5.3, 5.5.4, 5.5.5, 5.5.6, 5.6.0, 5.6.1, 5.7.0, 5.8.0, 6.0.0, 6.0.1, 6.0.2, 6.0.3, 6.1.0, 6.1.1, 6.1.2, 6.1.3, 6.1.4, 6.2.0, 6.2.1, 7.0.0, 7.1.0, 7.1.1, 7.2.0, 7.3.0, 7.3.1, 7.4.0, 7.4.1, 7.5.0, 7.6.0, 7.6.1, 7.6.2, 7.6.3, 7.7.0, 7.8.0, 7.8.1, 7.9.0, 7.9.1, 7.9.2, 7.9.3, 7.9.4, 8.0.0, 8.0.1, 8.0.2, 8.1.0, 8.2.0, 8.2.1, 8.3.0, 8.3.1, 8.3.2, 8.3.3, 8.3.4, 8.4.0, 8.4.1, 8.4.2, 8.4.3, 8.4.4, 8.5.0, 8.6.0, 8.7.0, 8.8.0, 8.8.1, 8.8.2, 8.9.0, 8.9.1, 8.9.2, 8.9.3, 8.9.4, 8.10.0, 8.11.0, 9.0.0, 9.1.0, 9.2.0, 9.2.1, 9.3.1, 9.4.0, 9.4.1, 9.4.2, 9.4.3
All unaffected versions: 10.0.0, 10.1.0, 10.1.1, 10.1.2, 10.1.3, 10.2.0, 10.3.0, 10.3.1, 10.3.2, 10.4.0, 10.5.0, 10.6.0, 10.7.0, 10.7.1, 10.8.0, 10.8.1, 10.9.0, 11.0.0, 11.1.0, 11.1.1, 11.2.0, 11.3.0, 11.4.0, 11.5.0, 11.6.0, 11.7.0, 12.0.0, 12.0.1, 12.0.2, 12.1.0, 12.2.0, 12.3.0, 12.4.0, 12.5.0, 12.5.1, 14.0.0, 14.0.1, 14.0.2, 14.0.3, 14.1.0, 14.2.0, 14.2.1, 14.2.2, 14.2.3, 14.2.4, 14.2.5, 15.0.0, 15.0.1, 15.1.0, 15.2.0, 15.3.0, 15.3.1, 16.0.0, 16.1.0, 16.2.0, 16.2.1, 16.2.2, 16.3.0, 16.4.0, 16.4.1, 16.5.0, 16.5.1, 16.5.2, 16.5.3, 16.5.4, 16.6.0, 16.6.1, 16.6.2, 16.7.0, 16.7.1, 16.8.0, 16.8.1, 17.0.0, 17.0.1, 17.1.0, 17.1.1, 17.1.2, 17.2.0, 17.2.1, 17.3.0, 17.4.0, 17.4.1, 17.5.0, 17.6.0, 17.6.1, 17.7.0, 17.7.1, 18.0.0, 18.1.0, 18.2.0, 18.3.0, 18.4.0, 18.5.0, 18.5.1, 18.5.2, 18.6.0, 18.6.1, 18.6.2, 18.6.3, 19.0.0, 19.1.0, 19.1.1, 19.1.2, 19.2.0, 19.2.1, 19.2.2, 19.2.3, 19.3.0, 20.0.0, 20.0.1, 20.1.0, 20.2.0, 20.3.0, 20.3.1, 20.3.2, 20.4.0, 20.4.1, 20.5.0, 20.6.0, 20.6.1, 20.6.2, 20.7.0, 20.7.1, 20.8.0, 20.9.0, 20.9.1, 20.9.2, 20.10.0, 20.11.0, 20.12.0, 20.14.0, 20.14.1, 20.14.2, 20.14.3, 20.15.0, 20.15.1, 20.15.2, 20.15.3, 20.16.0, 20.17.0, 20.18.0, 20.19.0, 20.20.0, 20.20.1, 20.21.0, 20.21.1, 20.21.2, 20.22.0, 20.22.1, 21.0.0, 21.1.0, 21.2.0