timecs 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- app.py +3014 -0
- ast_scanner.py +36187 -0
- banner.py +146 -0
- ci_reporter.py +570 -0
- cli.py +2347 -0
- config_loader.py +307 -0
- cross_file_engine.py +1781 -0
- delivery_models.py +145 -0
- delivery_repository.py +78 -0
- diff_scan.py +127 -0
- durable_delivery_sink.py +103 -0
- event_bus.py +155 -0
- event_publisher.py +345 -0
- event_taxonomy.py +313 -0
- function_summarizer.py +354 -0
- html_auditor.py +274 -0
- iac_auditor.py +400 -0
- in_app_adapter.py +115 -0
- js_scanner.py +895 -0
- manifest_parser.py +960 -0
- master_rules_bank.py +389 -0
- notification_models.py +346 -0
- notification_policy.py +309 -0
- notification_repository.py +118 -0
- notification_routes.py +394 -0
- notification_service.py +199 -0
- osv_client.py +437 -0
- remediation/__init__.py +39 -0
- remediation/base.py +102 -0
- remediation/contracts.py +196 -0
- remediation/cwe1188_binding.py +78 -0
- remediation/cwe1336_jinja.py +91 -0
- remediation/cwe22_path_traversal.py +348 -0
- remediation/cwe295_ssl.py +87 -0
- remediation/cwe327_weak_hash.py +78 -0
- remediation/cwe377_tempfile.py +77 -0
- remediation/cwe489_debug.py +80 -0
- remediation/cwe502_yaml.py +89 -0
- remediation/cwe614_cookie.py +91 -0
- remediation/cwe78_cmdi.py +415 -0
- remediation/cwe798_credentials.py +153 -0
- remediation/cwe89_sqli.py +425 -0
- remediation/cwe916_password_hash.py +131 -0
- remediation/cwe95_eval.py +77 -0
- remediation/dispatcher.py +114 -0
- remediation/orchestrator.py +541 -0
- remediation/patch_engine.py +213 -0
- remediation/verification.py +253 -0
- rule_engine.py +1535 -0
- sarif_adapter.py +719 -0
- sarif_exporter.py +88 -0
- sca_reachability/__init__.py +28 -0
- sca_reachability/ast_analyzer.py +366 -0
- sca_reachability/call_graph.py +203 -0
- sca_reachability/contracts.py +365 -0
- sca_reachability/dist_import_map.py +46 -0
- sca_reachability/engine.py +603 -0
- sca_reachability/resolver.py +169 -0
- scanners/__init__.py +70 -0
- scanners/container_scanner.py +323 -0
- scanners/cve_index.py +521 -0
- scanners/iac_scanner.py +328 -0
- scanners/sbom.py +183 -0
- scanners/sca_scanner.py +667 -0
- scanners/secret_scanner.py +345 -0
- scanners/yaml_lite.py +217 -0
- secret_filters.py +435 -0
- secret_scanner.py +943 -0
- sqlite_delivery_repository.py +277 -0
- sqlite_notification_repository.py +441 -0
- ssrf_guard.py +276 -0
- staged_scanner.py +492 -0
- suppression_resolver.py +282 -0
- symbol_indexer.py +424 -0
- tcs/__init__.py +1 -0
- tcs/analysis/__init__.py +1 -0
- tcs/analysis/def_use.py +408 -0
- tcs/analysis/function_contracts.py +290 -0
- tcs/parallel_analyzer.py +276 -0
- tcs/parallel_scanner.py +630 -0
- tcs/treesitter_packer.py +1446 -0
- tcs_cli.py +2086 -0
- tcs_config.py +218 -0
- tcs_gui.py +2123 -0
- timecs-2.0.0.dist-info/METADATA +142 -0
- timecs-2.0.0.dist-info/RECORD +94 -0
- timecs-2.0.0.dist-info/WHEEL +5 -0
- timecs-2.0.0.dist-info/entry_points.txt +4 -0
- timecs-2.0.0.dist-info/licenses/LICENSE +201 -0
- timecs-2.0.0.dist-info/top_level.txt +49 -0
- version_matcher.py +934 -0
- webhook_adapter.py +495 -0
- webhook_client.py +483 -0
- webhook_formatters.py +245 -0
scanners/cve_index.py
ADDED
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
"""Curated offline advisory index for the SCA scanner -- compact stdlib data, no network.
|
|
2
|
+
|
|
3
|
+
Every record is a real published advisory with an exact `fixed` version, and where the vulnerable
|
|
4
|
+
range does not start at zero, an exact `introduced` version too. That second bound is what keeps
|
|
5
|
+
this index honest: `django < 4.2.11` written naively would also condemn 3.2.25, which is patched.
|
|
6
|
+
A record therefore describes the half-open interval ``[introduced, fixed)``.
|
|
7
|
+
|
|
8
|
+
The matcher in `matching_advisories` is deliberately stricter than a typical SCA resolver. It
|
|
9
|
+
answers "is EVERY version this manifest allows vulnerable?", not "is SOME version vulnerable?".
|
|
10
|
+
A spec with no upper bound (`requests>=2.0`, `*`, `latest`) allows a patched release, so it is
|
|
11
|
+
quiet. Guessing a resolved version is how a dependency scanner manufactures false positives.
|
|
12
|
+
|
|
13
|
+
Version order follows PEP 440 / semver closely enough to be exact on release numbers and on
|
|
14
|
+
pre/post releases: ``1.0rc1 < 1.0 < 1.0.post1``. A spelling this reader cannot represent returns
|
|
15
|
+
None, and an unresolvable version is never guessed at -- the dependency stays quiet.
|
|
16
|
+
|
|
17
|
+
A package with several supported branches carries one record per branch, because a single fix
|
|
18
|
+
version cannot describe them: `ws` fixed 8.17.1, 7.5.10, 6.2.3 and 5.2.4 for the same defect, and
|
|
19
|
+
a pin on the 7.x branch is patched at 7.5.10 even though that is far below 8.17.1.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
import re
|
|
25
|
+
from typing import Dict, Optional, Tuple
|
|
26
|
+
|
|
27
|
+
__all__ = ["normalize_package_name", "parse_version", "compare_versions",
|
|
28
|
+
"advisories_for", "matching_advisories", "VersionKey"]
|
|
29
|
+
|
|
30
|
+
# (release components, stage rank, stage number). Final releases rank 4, so a pre-release sorts
|
|
31
|
+
# below its own release and a post-release above it.
|
|
32
|
+
VersionKey = Tuple[Tuple[int, ...], int, int]
|
|
33
|
+
|
|
34
|
+
# (cve, cwe, severity, fixed, introduced, summary)
|
|
35
|
+
Advisory = Tuple[str, str, str, str, Optional[str], str]
|
|
36
|
+
|
|
37
|
+
PYPI_ADVISORIES: Dict[str, Tuple[Advisory, ...]] = {
|
|
38
|
+
"pyyaml": (
|
|
39
|
+
("CVE-2020-1747", "CWE-502", "CRITICAL", "5.3.1", None,
|
|
40
|
+
"full_load deserializes untrusted YAML into arbitrary Python objects"),
|
|
41
|
+
("CVE-2020-14343", "CWE-502", "CRITICAL", "5.4", None,
|
|
42
|
+
"full_load still executes arbitrary Python constructors from untrusted YAML"),
|
|
43
|
+
),
|
|
44
|
+
"requests": (
|
|
45
|
+
("CVE-2023-32681", "CWE-200", "MEDIUM", "2.31.0", None,
|
|
46
|
+
"Proxy-Authorization header is leaked to the destination host on a redirect"),
|
|
47
|
+
("CVE-2024-35195", "CWE-295", "MEDIUM", "2.32.0", None,
|
|
48
|
+
"a Session keeps verify=False for later requests to the same host after the first"),
|
|
49
|
+
("CVE-2024-47081", "CWE-200", "MEDIUM", "2.32.4", None,
|
|
50
|
+
"a .netrc credential is sent to a third-party host reached through a redirect"),
|
|
51
|
+
),
|
|
52
|
+
"urllib3": (
|
|
53
|
+
("CVE-2023-43804", "CWE-200", "MEDIUM", "1.26.17", None,
|
|
54
|
+
"Cookie header is not stripped on a cross-origin redirect"),
|
|
55
|
+
("CVE-2023-43804", "CWE-200", "MEDIUM", "2.0.6", "2.0.0",
|
|
56
|
+
"Cookie header is not stripped on a cross-origin redirect"),
|
|
57
|
+
("CVE-2023-45803", "CWE-200", "MEDIUM", "1.26.18", None,
|
|
58
|
+
"request body is not stripped after a 303 redirect changes the method to GET"),
|
|
59
|
+
("CVE-2023-45803", "CWE-200", "MEDIUM", "2.0.7", "2.0.0",
|
|
60
|
+
"request body is not stripped after a 303 redirect changes the method to GET"),
|
|
61
|
+
("CVE-2024-37891", "CWE-200", "MEDIUM", "1.26.19", None,
|
|
62
|
+
"Proxy-Authorization is not stripped when a redirect leaves the proxy"),
|
|
63
|
+
("CVE-2024-37891", "CWE-200", "MEDIUM", "2.2.2", "2.0.0",
|
|
64
|
+
"Proxy-Authorization is not stripped when a redirect leaves the proxy"),
|
|
65
|
+
),
|
|
66
|
+
"django": (
|
|
67
|
+
("CVE-2022-28346", "CWE-89", "HIGH", "2.2.28", "2.2",
|
|
68
|
+
"SQL injection through a crafted column alias in QuerySet.annotate/aggregate"),
|
|
69
|
+
("CVE-2022-28346", "CWE-89", "HIGH", "3.2.13", "3.0",
|
|
70
|
+
"SQL injection through a crafted column alias in QuerySet.annotate/aggregate"),
|
|
71
|
+
("CVE-2022-28346", "CWE-89", "HIGH", "4.0.4", "4.0",
|
|
72
|
+
"SQL injection through a crafted column alias in QuerySet.annotate/aggregate"),
|
|
73
|
+
("CVE-2024-27351", "CWE-1333", "HIGH", "3.2.25", "3.2",
|
|
74
|
+
"regular-expression denial of service in django.utils.text.Truncator"),
|
|
75
|
+
("CVE-2024-27351", "CWE-1333", "HIGH", "4.2.11", "4.0",
|
|
76
|
+
"regular-expression denial of service in django.utils.text.Truncator"),
|
|
77
|
+
("CVE-2024-27351", "CWE-1333", "HIGH", "5.0.3", "5.0",
|
|
78
|
+
"regular-expression denial of service in django.utils.text.Truncator"),
|
|
79
|
+
("CVE-2024-39329", "CWE-208", "MEDIUM", "4.2.15", "4.2",
|
|
80
|
+
"the authentication backend's timing differs for an existing and an absent user"),
|
|
81
|
+
("CVE-2024-39329", "CWE-208", "MEDIUM", "5.0.8", "5.0",
|
|
82
|
+
"the authentication backend's timing differs for an existing and an absent user"),
|
|
83
|
+
("CVE-2024-45230", "CWE-1333", "HIGH", "4.2.16", "4.2",
|
|
84
|
+
"urlize is quadratic on crafted input, exhausting CPU"),
|
|
85
|
+
("CVE-2024-45230", "CWE-1333", "HIGH", "5.0.9", "5.0",
|
|
86
|
+
"urlize is quadratic on crafted input, exhausting CPU"),
|
|
87
|
+
("CVE-2024-45230", "CWE-1333", "HIGH", "5.1.1", "5.1",
|
|
88
|
+
"urlize is quadratic on crafted input, exhausting CPU"),
|
|
89
|
+
),
|
|
90
|
+
"flask": (
|
|
91
|
+
("CVE-2023-30861", "CWE-200", "HIGH", "2.2.5", "2.2.0",
|
|
92
|
+
"a cached redirect response can carry another client's session cookie"),
|
|
93
|
+
("CVE-2023-30861", "CWE-200", "HIGH", "2.3.2", "2.3.0",
|
|
94
|
+
"a cached redirect response can carry another client's session cookie"),
|
|
95
|
+
),
|
|
96
|
+
"jinja2": (
|
|
97
|
+
("CVE-2024-22195", "CWE-79", "MEDIUM", "3.1.3", None,
|
|
98
|
+
"the xmlattr filter accepts keys with spaces, enabling attribute-injection XSS"),
|
|
99
|
+
("CVE-2024-34064", "CWE-79", "MEDIUM", "3.1.4", None,
|
|
100
|
+
"the xmlattr filter accepts keys with whitespace, enabling attribute-injection XSS"),
|
|
101
|
+
("CVE-2024-56201", "CWE-79", "MEDIUM", "3.1.5", None,
|
|
102
|
+
"a crafted template filename escapes the sandbox and executes Python"),
|
|
103
|
+
("CVE-2025-27516", "CWE-79", "MEDIUM", "3.1.6", None,
|
|
104
|
+
"the |attr filter escapes the sandbox through a crafted attribute name"),
|
|
105
|
+
),
|
|
106
|
+
"cryptography": (
|
|
107
|
+
("CVE-2023-49083", "CWE-476", "HIGH", "41.0.6", None,
|
|
108
|
+
"NULL dereference when loading a PKCS#7 certificate with no certificates"),
|
|
109
|
+
("CVE-2024-26130", "CWE-476", "HIGH", "42.0.4", None,
|
|
110
|
+
"NULL dereference in pkcs12.serialize_key_and_certificates with a NULL key"),
|
|
111
|
+
("CVE-2023-50782", "CWE-208", "HIGH", "41.0.6", None,
|
|
112
|
+
"Bleichenbacher timing oracle in the PKCS#1 v1.5 decryption path"),
|
|
113
|
+
("CVE-2024-0727", "CWE-476", "MEDIUM", "42.0.2", None,
|
|
114
|
+
"NULL dereference when processing a crafted PKCS#12 file"),
|
|
115
|
+
),
|
|
116
|
+
"pillow": (
|
|
117
|
+
("CVE-2023-50447", "CWE-94", "CRITICAL", "10.2.0", None,
|
|
118
|
+
"PIL.ImageMath.eval executes arbitrary Python expressions from untrusted input"),
|
|
119
|
+
("CVE-2024-28219", "CWE-120", "HIGH", "10.3.0", None,
|
|
120
|
+
"buffer overflow in _imagingcms when processing a crafted ICC profile"),
|
|
121
|
+
),
|
|
122
|
+
"werkzeug": (
|
|
123
|
+
("CVE-2023-46136", "CWE-400", "HIGH", "2.3.8", "2.0.0",
|
|
124
|
+
"multipart parsing accepts unbounded leading whitespace, exhausting CPU"),
|
|
125
|
+
("CVE-2023-46136", "CWE-400", "HIGH", "3.0.1", "3.0.0",
|
|
126
|
+
"multipart parsing accepts unbounded leading whitespace, exhausting CPU"),
|
|
127
|
+
("CVE-2024-34069", "CWE-352", "HIGH", "3.0.3", None,
|
|
128
|
+
"the interactive debugger can be driven cross-site, executing code on the host"),
|
|
129
|
+
("CVE-2024-49767", "CWE-400", "HIGH", "3.0.6", None,
|
|
130
|
+
"multipart form parsing consumes unbounded resources on a crafted body"),
|
|
131
|
+
),
|
|
132
|
+
"aiohttp": (
|
|
133
|
+
("CVE-2024-23334", "CWE-22", "HIGH", "3.9.4", "3.9.0",
|
|
134
|
+
"static routes with follow_symlinks allow traversal outside the root directory"),
|
|
135
|
+
("CVE-2024-23829", "CWE-444", "MEDIUM", "3.9.2", None,
|
|
136
|
+
"the HTTP parser accepts malformed headers, enabling request smuggling"),
|
|
137
|
+
("CVE-2024-30251", "CWE-400", "HIGH", "3.9.4", None,
|
|
138
|
+
"a crafted multipart body is parsed without a size limit, exhausting memory"),
|
|
139
|
+
("CVE-2024-52304", "CWE-444", "HIGH", "3.10.11", None,
|
|
140
|
+
"a chunked trailer section is accepted without validation, enabling request smuggling"),
|
|
141
|
+
),
|
|
142
|
+
"starlette": (
|
|
143
|
+
("CVE-2024-24762", "CWE-1333", "HIGH", "0.36.2", None,
|
|
144
|
+
"multipart form parsing is quadratic in the number of parts, exhausting CPU"),
|
|
145
|
+
("CVE-2023-29159", "CWE-22", "HIGH", "0.27.0", None,
|
|
146
|
+
"StaticFiles follows a crafted path outside the configured directory"),
|
|
147
|
+
("CVE-2023-30798", "CWE-400", "HIGH", "0.27.0", None,
|
|
148
|
+
"multipart form parsing accepts unbounded parts, exhausting CPU"),
|
|
149
|
+
),
|
|
150
|
+
"paramiko": (
|
|
151
|
+
("CVE-2023-48795", "CWE-326", "MEDIUM", "3.4.0", None,
|
|
152
|
+
"Terrapin prefix truncation lets an on-path attacker strip SSH extension negotiation"),
|
|
153
|
+
("CVE-2022-24302", "CWE-362", "MEDIUM", "2.10.1", None,
|
|
154
|
+
"a race between key file creation and permission write exposes the private key"),
|
|
155
|
+
),
|
|
156
|
+
"sqlparse": (
|
|
157
|
+
("CVE-2024-4340", "CWE-1333", "HIGH", "0.5.0", None,
|
|
158
|
+
"the regular expression behind sqlparse.format is quadratic on crafted SQL"),
|
|
159
|
+
("CVE-2023-30608", "CWE-1333", "MEDIUM", "0.4.4", None,
|
|
160
|
+
"the regular expression behind sqlparse.split is quadratic on crafted SQL"),
|
|
161
|
+
),
|
|
162
|
+
"certifi": (
|
|
163
|
+
("CVE-2023-37920", "CWE-295", "HIGH", "2023.7.22", None,
|
|
164
|
+
"the trust store still carries the e-Tugra root certificate, which must be distrusted"),
|
|
165
|
+
("CVE-2024-39689", "CWE-295", "HIGH", "2024.7.4", None,
|
|
166
|
+
"the trust store still carries the GLOBALTRUST roots, which must be distrusted"),
|
|
167
|
+
),
|
|
168
|
+
"pyjwt": (
|
|
169
|
+
("CVE-2022-29217", "CWE-347", "CRITICAL", "2.4.0", None,
|
|
170
|
+
"algorithm confusion lets an HMAC key verify a token signed as RSA"),
|
|
171
|
+
),
|
|
172
|
+
"fastapi": (
|
|
173
|
+
("CVE-2024-24762", "CWE-1333", "HIGH", "0.109.1", None,
|
|
174
|
+
"the bundled python-multipart parser is quadratic in the number of form parts"),
|
|
175
|
+
),
|
|
176
|
+
"gunicorn": (
|
|
177
|
+
("CVE-2024-1135", "CWE-444", "HIGH", "22.0.0", None,
|
|
178
|
+
"a crafted Transfer-Encoding header splits one request into two"),
|
|
179
|
+
("CVE-2024-6827", "CWE-444", "HIGH", "22.0.0", None,
|
|
180
|
+
"a malformed Transfer-Encoding header is accepted, enabling request smuggling"),
|
|
181
|
+
),
|
|
182
|
+
"tornado": (
|
|
183
|
+
("CVE-2023-28370", "CWE-601", "MEDIUM", "6.3.2", None,
|
|
184
|
+
"a crafted redirect target escapes the intended host"),
|
|
185
|
+
("CVE-2024-52804", "CWE-1333", "HIGH", "6.4.2", None,
|
|
186
|
+
"cookie parsing is quadratic in the number of cookies, exhausting CPU"),
|
|
187
|
+
),
|
|
188
|
+
"celery": (
|
|
189
|
+
("CVE-2021-23727", "CWE-78", "HIGH", "5.2.2", None,
|
|
190
|
+
"a crafted task argument reaches a shell command in the worker"),
|
|
191
|
+
),
|
|
192
|
+
"sqlalchemy": (
|
|
193
|
+
("CVE-2019-7164", "CWE-89", "HIGH", "1.2.18", None,
|
|
194
|
+
"a crafted column expression in order_by is interpolated into SQL"),
|
|
195
|
+
),
|
|
196
|
+
"lxml": (
|
|
197
|
+
("CVE-2021-43818", "CWE-79", "HIGH", "4.6.5", None,
|
|
198
|
+
"lxml.html.clean leaves a crafted SVG/CSS construct that executes script"),
|
|
199
|
+
("CVE-2022-2309", "CWE-476", "MEDIUM", "4.9.1", None,
|
|
200
|
+
"NULL dereference in the iterwalk/iterparse error path crashes the process"),
|
|
201
|
+
),
|
|
202
|
+
"python-jose": (
|
|
203
|
+
("CVE-2024-33663", "CWE-347", "HIGH", "3.4.0", None,
|
|
204
|
+
"algorithm confusion lets an ECDSA token be verified with the wrong key type"),
|
|
205
|
+
("CVE-2024-33664", "CWE-400", "MEDIUM", "3.4.0", None,
|
|
206
|
+
"a crafted JWE body decompresses without a bound, exhausting memory"),
|
|
207
|
+
),
|
|
208
|
+
"authlib": (
|
|
209
|
+
("CVE-2024-37568", "CWE-347", "CRITICAL", "1.3.1", None,
|
|
210
|
+
"a JWS with an unsupported algorithm is accepted without verifying its signature"),
|
|
211
|
+
),
|
|
212
|
+
"ecdsa": (
|
|
213
|
+
("CVE-2024-23342", "CWE-208", "MEDIUM", "0.19.0", None,
|
|
214
|
+
"Minerva timing leakage in scalar multiplication recovers the private nonce"),
|
|
215
|
+
),
|
|
216
|
+
"pycryptodome": (
|
|
217
|
+
("CVE-2023-52323", "CWE-208", "MEDIUM", "3.19.1", None,
|
|
218
|
+
"a side channel in the RSA OAEP decryption path leaks plaintext"),
|
|
219
|
+
),
|
|
220
|
+
"gitpython": (
|
|
221
|
+
("CVE-2023-40590", "CWE-426", "HIGH", "3.1.35", None,
|
|
222
|
+
"an untrusted search path on Windows lets a planted git executable run"),
|
|
223
|
+
("CVE-2024-22190", "CWE-426", "CRITICAL", "3.1.41", None,
|
|
224
|
+
"an untrusted search path lets a planted executable run arbitrary code"),
|
|
225
|
+
),
|
|
226
|
+
"ansible": (
|
|
227
|
+
("CVE-2023-5764", "CWE-94", "HIGH", "8.6.0", None,
|
|
228
|
+
"a templated variable marked unsafe is still evaluated, executing attacker code"),
|
|
229
|
+
),
|
|
230
|
+
"mlflow": (
|
|
231
|
+
("CVE-2024-27132", "CWE-79", "HIGH", "2.11.0", None,
|
|
232
|
+
"a crafted recipe name is rendered without escaping, enabling stored XSS"),
|
|
233
|
+
("CVE-2024-37059", "CWE-22", "HIGH", "2.12.1", None,
|
|
234
|
+
"a crafted artifact path reads an arbitrary file from the tracking server"),
|
|
235
|
+
),
|
|
236
|
+
"gradio": (
|
|
237
|
+
("CVE-2024-4325", "CWE-22", "HIGH", "4.31.4", None,
|
|
238
|
+
"a crafted component upload path writes outside the intended directory"),
|
|
239
|
+
("CVE-2024-47872", "CWE-79", "HIGH", "5.0.0", None,
|
|
240
|
+
"a crafted component value is rendered without escaping, enabling stored XSS"),
|
|
241
|
+
),
|
|
242
|
+
"langchain": (
|
|
243
|
+
("CVE-2023-46229", "CWE-918", "HIGH", "0.0.325", None,
|
|
244
|
+
"the recursive URL loader follows an attacker-supplied internal address"),
|
|
245
|
+
("CVE-2024-28088", "CWE-22", "HIGH", "0.1.11", None,
|
|
246
|
+
"a crafted document path traverses outside the configured loader root"),
|
|
247
|
+
),
|
|
248
|
+
"transformers": (
|
|
249
|
+
("CVE-2024-3568", "CWE-502", "CRITICAL", "4.38.0", None,
|
|
250
|
+
"a crafted checkpoint is unpickled, executing arbitrary code on load"),
|
|
251
|
+
("CVE-2024-11392", "CWE-502", "CRITICAL", "4.48.0", None,
|
|
252
|
+
"a crafted model file is deserialized without a safe loader, executing code"),
|
|
253
|
+
),
|
|
254
|
+
"torch": (
|
|
255
|
+
("CVE-2024-31580", "CWE-122", "HIGH", "2.2.0", None,
|
|
256
|
+
"a crafted tensor shape overflows a heap buffer in the JIT runtime"),
|
|
257
|
+
("CVE-2024-5480", "CWE-502", "CRITICAL", "2.2.0", None,
|
|
258
|
+
"torch.distributed.rpc unpickles an untrusted argument, executing arbitrary code"),
|
|
259
|
+
),
|
|
260
|
+
"numpy": (
|
|
261
|
+
("CVE-2021-41496", "CWE-120", "HIGH", "1.22.0", None,
|
|
262
|
+
"a crafted array argument overflows a buffer in array_from_pyobj"),
|
|
263
|
+
),
|
|
264
|
+
"setuptools": (
|
|
265
|
+
("CVE-2022-40897", "CWE-1333", "HIGH", "65.5.1", None,
|
|
266
|
+
"the regular expression behind package_index is quadratic on a crafted HTML page"),
|
|
267
|
+
("CVE-2024-6345", "CWE-94", "CRITICAL", "70.0.0", None,
|
|
268
|
+
"the download helpers pass an attacker-supplied URL to a shell, executing code"),
|
|
269
|
+
),
|
|
270
|
+
"pip": (
|
|
271
|
+
("CVE-2023-5752", "CWE-78", "HIGH", "23.3", None,
|
|
272
|
+
"a crafted Mercurial revision is interpolated into a shell command"),
|
|
273
|
+
),
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
NPM_ADVISORIES: Dict[str, Tuple[Advisory, ...]] = {
|
|
277
|
+
"lodash": (
|
|
278
|
+
("CVE-2021-23337", "CWE-78", "HIGH", "4.17.21", None,
|
|
279
|
+
"the template helper passes untrusted options into a shell command"),
|
|
280
|
+
("CVE-2020-8203", "CWE-1321", "HIGH", "4.17.20", None,
|
|
281
|
+
"zipObjectDeep pollutes Object.prototype through a crafted path"),
|
|
282
|
+
),
|
|
283
|
+
"axios": (
|
|
284
|
+
("CVE-2023-45857", "CWE-200", "MEDIUM", "1.6.0", None,
|
|
285
|
+
"the XSRF-TOKEN header is sent to a third-party host on a cross-origin request"),
|
|
286
|
+
("CVE-2024-39338", "CWE-918", "HIGH", "1.7.4", None,
|
|
287
|
+
"an absolute URL bypasses the configured proxy and baseURL, enabling SSRF"),
|
|
288
|
+
("CVE-2025-27152", "CWE-918", "HIGH", "1.8.2", None,
|
|
289
|
+
"an absolute URL overrides baseURL and reaches an attacker-chosen host"),
|
|
290
|
+
),
|
|
291
|
+
"express": (
|
|
292
|
+
("CVE-2024-29041", "CWE-601", "MEDIUM", "4.19.2", None,
|
|
293
|
+
"a malformed URL passed to response.redirect escapes the intended host"),
|
|
294
|
+
("CVE-2024-43796", "CWE-79", "MEDIUM", "4.21.0", None,
|
|
295
|
+
"response.redirect interpolates untrusted input into the HTML body, enabling XSS"),
|
|
296
|
+
),
|
|
297
|
+
"jsonwebtoken": (
|
|
298
|
+
("CVE-2022-23529", "CWE-20", "CRITICAL", "9.0.0", None,
|
|
299
|
+
"the secretOrPublicKey callback can be driven to forge tokens across key types"),
|
|
300
|
+
),
|
|
301
|
+
"next": (
|
|
302
|
+
("CVE-2024-34351", "CWE-918", "HIGH", "14.1.1", "13.4.0",
|
|
303
|
+
"a Server Action redirect follows an attacker-supplied Host header, enabling SSRF"),
|
|
304
|
+
("CVE-2024-46982", "CWE-400", "HIGH", "13.5.7", "13.0.0",
|
|
305
|
+
"a crafted request poisons the App Router cache, denying service to other users"),
|
|
306
|
+
("CVE-2024-46982", "CWE-400", "HIGH", "14.2.10", "14.0.0",
|
|
307
|
+
"a crafted request poisons the App Router cache, denying service to other users"),
|
|
308
|
+
),
|
|
309
|
+
"vite": (
|
|
310
|
+
("CVE-2024-23331", "CWE-22", "HIGH", "4.5.2", "4.0.0",
|
|
311
|
+
"the dev server serves a crafted path outside the project root"),
|
|
312
|
+
("CVE-2024-23331", "CWE-22", "HIGH", "5.0.12", "5.0.0",
|
|
313
|
+
"the dev server serves a crafted path outside the project root"),
|
|
314
|
+
("CVE-2024-45812", "CWE-79", "HIGH", "4.5.5", "4.0.0",
|
|
315
|
+
"DOM clobbering through a crafted element id executes script in the dev server"),
|
|
316
|
+
("CVE-2024-45812", "CWE-79", "HIGH", "5.3.6", "5.0.0",
|
|
317
|
+
"DOM clobbering through a crafted element id executes script in the dev server"),
|
|
318
|
+
("CVE-2024-45812", "CWE-79", "HIGH", "5.4.6", "5.4.0",
|
|
319
|
+
"DOM clobbering through a crafted element id executes script in the dev server"),
|
|
320
|
+
),
|
|
321
|
+
"webpack": (
|
|
322
|
+
("CVE-2023-28154", "CWE-94", "CRITICAL", "5.76.0", None,
|
|
323
|
+
"the cross-realm object access in the runtime lets a crafted module execute code"),
|
|
324
|
+
),
|
|
325
|
+
"tar": (
|
|
326
|
+
("CVE-2024-28863", "CWE-400", "MEDIUM", "6.2.1", None,
|
|
327
|
+
"a crafted archive creates unbounded entries, exhausting memory during extraction"),
|
|
328
|
+
),
|
|
329
|
+
"ws": (
|
|
330
|
+
("CVE-2024-37890", "CWE-400", "HIGH", "5.2.4", "5.0.0",
|
|
331
|
+
"a request with many HTTP headers exhausts memory during the upgrade handshake"),
|
|
332
|
+
("CVE-2024-37890", "CWE-400", "HIGH", "6.2.3", "6.0.0",
|
|
333
|
+
"a request with many HTTP headers exhausts memory during the upgrade handshake"),
|
|
334
|
+
("CVE-2024-37890", "CWE-400", "HIGH", "7.5.10", "7.0.0",
|
|
335
|
+
"a request with many HTTP headers exhausts memory during the upgrade handshake"),
|
|
336
|
+
("CVE-2024-37890", "CWE-400", "HIGH", "8.17.1", "8.0.0",
|
|
337
|
+
"a request with many HTTP headers exhausts memory during the upgrade handshake"),
|
|
338
|
+
),
|
|
339
|
+
"node-forge": (
|
|
340
|
+
("CVE-2022-24771", "CWE-347", "HIGH", "1.3.0", None,
|
|
341
|
+
"a crafted RSA signature with a malformed DigestInfo is accepted as valid"),
|
|
342
|
+
),
|
|
343
|
+
"qs": (
|
|
344
|
+
("CVE-2022-24999", "CWE-1321", "HIGH", "6.5.3", "6.5.0",
|
|
345
|
+
"a crafted query string pollutes Object.prototype through the parser"),
|
|
346
|
+
("CVE-2022-24999", "CWE-1321", "HIGH", "6.9.7", "6.9.0",
|
|
347
|
+
"a crafted query string pollutes Object.prototype through the parser"),
|
|
348
|
+
("CVE-2022-24999", "CWE-1321", "HIGH", "6.10.3", "6.10.0",
|
|
349
|
+
"a crafted query string pollutes Object.prototype through the parser"),
|
|
350
|
+
),
|
|
351
|
+
"semver": (
|
|
352
|
+
("CVE-2022-25883", "CWE-1333", "HIGH", "5.7.2", "5.0.0",
|
|
353
|
+
"the regular expression behind range parsing is quadratic on a crafted version"),
|
|
354
|
+
("CVE-2022-25883", "CWE-1333", "HIGH", "6.3.1", "6.0.0",
|
|
355
|
+
"the regular expression behind range parsing is quadratic on a crafted version"),
|
|
356
|
+
("CVE-2022-25883", "CWE-1333", "HIGH", "7.5.2", "7.0.0",
|
|
357
|
+
"the regular expression behind range parsing is quadratic on a crafted version"),
|
|
358
|
+
),
|
|
359
|
+
"got": (
|
|
360
|
+
("CVE-2022-33987", "CWE-918", "HIGH", "11.8.5", "11.0.0",
|
|
361
|
+
"a crafted redirect target is followed to an internal address, enabling SSRF"),
|
|
362
|
+
("CVE-2022-33987", "CWE-918", "HIGH", "12.1.0", "12.0.0",
|
|
363
|
+
"a crafted redirect target is followed to an internal address, enabling SSRF"),
|
|
364
|
+
),
|
|
365
|
+
"minimist": (
|
|
366
|
+
("CVE-2021-44906", "CWE-1321", "CRITICAL", "1.2.6", None,
|
|
367
|
+
"a crafted argument pollutes Object.prototype through the parser"),
|
|
368
|
+
),
|
|
369
|
+
"cookie": (
|
|
370
|
+
("CVE-2024-47764", "CWE-20", "HIGH", "0.7.0", None,
|
|
371
|
+
"a crafted cookie name or value is accepted without validation, enabling injection"),
|
|
372
|
+
),
|
|
373
|
+
"body-parser": (
|
|
374
|
+
("CVE-2024-45590", "CWE-400", "HIGH", "1.20.3", None,
|
|
375
|
+
"a crafted urlencoded body is parsed without a bound, exhausting CPU"),
|
|
376
|
+
),
|
|
377
|
+
"send": (
|
|
378
|
+
("CVE-2024-43799", "CWE-79", "MEDIUM", "0.19.0", None,
|
|
379
|
+
"a crafted redirect target is interpolated into the HTML body, enabling XSS"),
|
|
380
|
+
),
|
|
381
|
+
"serve-static": (
|
|
382
|
+
("CVE-2024-43800", "CWE-79", "MEDIUM", "1.16.0", None,
|
|
383
|
+
"a crafted redirect target is interpolated into the HTML body, enabling XSS"),
|
|
384
|
+
),
|
|
385
|
+
"ejs": (
|
|
386
|
+
("CVE-2022-29078", "CWE-94", "CRITICAL", "3.1.7", None,
|
|
387
|
+
"a crafted render option reaches the template compiler, executing arbitrary code"),
|
|
388
|
+
),
|
|
389
|
+
"handlebars": (
|
|
390
|
+
("CVE-2021-23369", "CWE-94", "CRITICAL", "4.7.7", None,
|
|
391
|
+
"a crafted template bypasses the prototype access guard, executing arbitrary code"),
|
|
392
|
+
),
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
_INDEXES = {"pypi": PYPI_ADVISORIES, "npm": NPM_ADVISORIES}
|
|
396
|
+
|
|
397
|
+
# Distribution names whose import namespace is not the distribution name. Everything absent here
|
|
398
|
+
# imports under its own normalized name with '-' turned into '_'.
|
|
399
|
+
DIST_TO_IMPORTS: Dict[str, Tuple[str, ...]] = {
|
|
400
|
+
"pyyaml": ("yaml",),
|
|
401
|
+
"pillow": ("PIL",),
|
|
402
|
+
"pillow-simd": ("PIL",),
|
|
403
|
+
"beautifulsoup4": ("bs4",),
|
|
404
|
+
"pyjwt": ("jwt",),
|
|
405
|
+
"python-jose": ("jose",),
|
|
406
|
+
"scikit-learn": ("sklearn",),
|
|
407
|
+
"python-dateutil": ("dateutil",),
|
|
408
|
+
"attrs": ("attr", "attrs"),
|
|
409
|
+
"opencv-python": ("cv2",),
|
|
410
|
+
"opencv-python-headless": ("cv2",),
|
|
411
|
+
"mysqlclient": ("MySQLdb",),
|
|
412
|
+
"mysql-connector-python": ("mysql",),
|
|
413
|
+
"pypdf2": ("PyPDF2",),
|
|
414
|
+
"protobuf": ("google",),
|
|
415
|
+
"pycryptodome": ("Crypto",),
|
|
416
|
+
"pycryptodomex": ("Cryptodome",),
|
|
417
|
+
"python-multipart": ("multipart",),
|
|
418
|
+
"python-dotenv": ("dotenv",),
|
|
419
|
+
"typing-extensions": ("typing_extensions",),
|
|
420
|
+
"gitpython": ("git",),
|
|
421
|
+
"pyopenssl": ("OpenSSL",),
|
|
422
|
+
"psycopg2-binary": ("psycopg2",),
|
|
423
|
+
"pyzmq": ("zmq",),
|
|
424
|
+
"discord.py": ("discord",),
|
|
425
|
+
"python-telegram-bot": ("telegram",),
|
|
426
|
+
"python-gitlab": ("gitlab",),
|
|
427
|
+
"tensorflow-cpu": ("tensorflow",),
|
|
428
|
+
"ruamel.yaml": ("ruamel",),
|
|
429
|
+
"msgpack-python": ("msgpack",),
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
_NAME_SPLIT_RE = re.compile(r"[-_.]+")
|
|
433
|
+
_VERSION_RE = re.compile(r"^v?(\d+(?:\.\d+)*)(.*)$", re.IGNORECASE)
|
|
434
|
+
_STAGE_RE = re.compile(r"([a-z]+)[\-_.]?(\d*)")
|
|
435
|
+
_PRE_RANK = {"dev": 0, "a": 1, "alpha": 1, "b": 2, "beta": 2,
|
|
436
|
+
"c": 3, "rc": 3, "pre": 3, "preview": 3}
|
|
437
|
+
_POST_RANK = {"post": 5, "rev": 5, "r": 5}
|
|
438
|
+
_FINAL_RANK = 4
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
def normalize_package_name(name: str) -> str:
|
|
442
|
+
"""PEP 503 normalization, which npm's registry spelling also satisfies."""
|
|
443
|
+
return _NAME_SPLIT_RE.sub("-", str(name).strip().lower())
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
def parse_version(text: Optional[str]) -> Optional[VersionKey]:
|
|
447
|
+
"""A comparable version key, or None for a spelling this reader refuses to guess at."""
|
|
448
|
+
if text is None:
|
|
449
|
+
return None
|
|
450
|
+
spelling = str(text).strip().lstrip("=").strip()
|
|
451
|
+
if not spelling:
|
|
452
|
+
return None
|
|
453
|
+
# An epoch reorders every comparison that follows it, and a local label is build metadata.
|
|
454
|
+
# Neither is modelled here, so both make the version unresolvable rather than comparable.
|
|
455
|
+
if "!" in spelling or "+" in spelling:
|
|
456
|
+
return None
|
|
457
|
+
match = _VERSION_RE.match(spelling)
|
|
458
|
+
if not match:
|
|
459
|
+
return None
|
|
460
|
+
release = tuple(int(part) for part in match.group(1).split("."))
|
|
461
|
+
rest = match.group(2).strip().lower().lstrip("-_.")
|
|
462
|
+
if not rest:
|
|
463
|
+
return (release, _FINAL_RANK, 0)
|
|
464
|
+
stage = _STAGE_RE.match(rest)
|
|
465
|
+
if not stage:
|
|
466
|
+
return None
|
|
467
|
+
word, number = stage.group(1), stage.group(2)
|
|
468
|
+
if word in _PRE_RANK:
|
|
469
|
+
return (release, _PRE_RANK[word], int(number or 0))
|
|
470
|
+
if word in _POST_RANK:
|
|
471
|
+
return (release, _POST_RANK[word], int(number or 0))
|
|
472
|
+
return None
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
def compare_versions(left: VersionKey, right: VersionKey) -> int:
|
|
476
|
+
"""-1 / 0 / 1. Release tuples are zero-padded, so 1.2 and 1.2.0 are the same version."""
|
|
477
|
+
width = max(len(left[0]), len(right[0]))
|
|
478
|
+
a = (left[0] + (0,) * (width - len(left[0])), left[1], left[2])
|
|
479
|
+
b = (right[0] + (0,) * (width - len(right[0])), right[1], right[2])
|
|
480
|
+
return (a > b) - (a < b)
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
def advisories_for(ecosystem: str, package: str) -> Tuple[Advisory, ...]:
|
|
484
|
+
index = _INDEXES.get(ecosystem)
|
|
485
|
+
if not index:
|
|
486
|
+
return ()
|
|
487
|
+
return index.get(normalize_package_name(package), ())
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
def import_roots_for(package: str) -> Tuple[str, ...]:
|
|
491
|
+
normalized = normalize_package_name(package)
|
|
492
|
+
curated = DIST_TO_IMPORTS.get(normalized)
|
|
493
|
+
if curated:
|
|
494
|
+
return curated
|
|
495
|
+
return (normalized.replace("-", "_"),)
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
def matching_advisories(ecosystem: str, package: str, lower: Optional[VersionKey],
|
|
499
|
+
upper: Optional[VersionKey], upper_inclusive: bool) -> Tuple[Advisory, ...]:
|
|
500
|
+
"""Advisories that EVERY version allowed by the spec is vulnerable to.
|
|
501
|
+
|
|
502
|
+
`lower`/`upper` are the spec's bounds, None meaning unbounded on that side. An unbounded
|
|
503
|
+
upper side allows a patched release, so nothing is provable and the result is empty. A
|
|
504
|
+
bounded spec whose lower side is below an advisory's `introduced` also allows a release
|
|
505
|
+
that predates the defect, so that advisory is skipped too.
|
|
506
|
+
"""
|
|
507
|
+
if upper is None:
|
|
508
|
+
return ()
|
|
509
|
+
matched = []
|
|
510
|
+
for advisory in advisories_for(ecosystem, package):
|
|
511
|
+
fixed = parse_version(advisory[3])
|
|
512
|
+
if fixed is None:
|
|
513
|
+
continue
|
|
514
|
+
introduced = parse_version(advisory[4]) if advisory[4] else None
|
|
515
|
+
if introduced is not None:
|
|
516
|
+
if lower is None or compare_versions(lower, introduced) < 0:
|
|
517
|
+
continue
|
|
518
|
+
order = compare_versions(upper, fixed)
|
|
519
|
+
if order < 0 or (order == 0 and not upper_inclusive):
|
|
520
|
+
matched.append(advisory)
|
|
521
|
+
return tuple(matched)
|