Skip to content

Commit 74857d9

Browse files
authored
aggressive fix version detection (#213)
* OSV was burying fix versions inside database_specific attributes at times. Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com> * Track unaffected version from max excluding Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com> * Bump version Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com> * Fix tests Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com> --------- Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
1 parent ba88de9 commit 74857d9

File tree

8 files changed

+694
-477
lines changed

8 files changed

+694
-477
lines changed

packages/mcp-server-vdb/src/mcp_server_vdb/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ async def handle_call_tool(name: str, arguments: dict[str, Any] | None) -> list[
358358
write_stream,
359359
InitializationOptions(
360360
server_name="appthreat-vulnerability-db",
361-
server_version="6.3.0",
361+
server_version="6.3.1",
362362
capabilities=server.get_capabilities(
363363
notification_options=NotificationOptions(),
364364
experimental_capabilities={},

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "appthreat-vulnerability-db"
3-
version = "6.3.0"
3+
version = "6.3.1"
44
description = "AppThreat's vulnerability database and package search library with a built-in sqlite based storage. OSV, CVE, GitHub, npm are the primary sources of vulnerabilities."
55
authors = [
66
{name = "Team AppThreat", email = "cloud@appthreat.com"},
@@ -69,3 +69,8 @@ testpaths = [
6969
disable = ["broad-exception-caught", "too-many-branches", "too-many-statements", "too-many-nested-blocks", "too-many-locals", "missing-function-docstring", "too-many-lines", "missing-module-docstring"]
7070
ignore-paths = ["vdb/lib/cve_model/*"]
7171
generated-member = ["orjson.loads", "orjson.dumps", "orjson.OPT_NAIVE_UTC"]
72+
73+
[dependency-groups]
74+
dev = [
75+
"ruff>=0.11.7",
76+
]

test/data/osv-pypi4.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"id":"GHSA-vqfr-h8mv-ghfj","summary":"h11 accepts some malformed Chunked-Encoding bodies","details":"### Impact\n\nA leniency in h11's parsing of line terminators in chunked-coding message bodies can lead to request smuggling vulnerabilities under certain conditions.\n\n### Details\n\nHTTP/1.1 Chunked-Encoding bodies are formatted as a sequence of \"chunks\", each of which consists of:\n\n- chunk length\n- `\\r\\n`\n- `length` bytes of content\n- `\\r\\n`\n\nIn versions of h11 up to 0.14.0, h11 instead parsed them as:\n\n- chunk length\n- `\\r\\n`\n- `length` bytes of content\n- any two bytes\n\ni.e. it did not validate that the trailing `\\r\\n` bytes were correct, and if you put 2 bytes of garbage there it would be accepted, instead of correctly rejecting the body as malformed.\n\nBy itself this is harmless. However, suppose you have a proxy or reverse-proxy that tries to analyze HTTP requests, and your proxy has a _different_ bug in parsing Chunked-Encoding, acting as if the format is:\n\n- chunk length\n- `\\r\\n`\n- `length` bytes of content\n- more bytes of content, as many as it takes until you find a `\\r\\n`\n\nFor example, [pound](https://github.com/graygnuorg/pound/pull/43) had this bug -- it can happen if an implementer uses a generic \"read until end of line\" helper to consumes the trailing `\\r\\n`.\n\nIn this case, h11 and your proxy may both accept the same stream of bytes, but interpret them differently. For example, consider the following HTTP request(s) (assume all line breaks are `\\r\\n`):\n\n```\nGET /one HTTP/1.1\nHost: localhost\nTransfer-Encoding: chunked\n\n5\nAAAAAXX2\n45\n0\n\nGET /two HTTP/1.1\nHost: localhost\nTransfer-Encoding: chunked\n\n0\n```\n\nHere h11 will interpret it as two requests, one with body `AAAAA45` and one with an empty body, while our hypothetical buggy proxy will interpret it as a single request, with body `AAAAXX20\\r\\n\\r\\nGET /two ...`. And any time two HTTP processors both accept the same string of bytes but interpret them differently, you have the conditions for a \"request smuggling\" attack. For example, if `/two` is a dangerous endpoint and the job of the reverse proxy is to stop requests from getting there, then an attacker could use a bytestream like the above to circumvent this protection.\n\nEven worse, if our buggy reverse proxy receives two requests from different users:\n\n```\nGET /one HTTP/1.1\nHost: localhost\nTransfer-Encoding: chunked\n\n5\nAAAAAXX999\n0\n```\n\n```\nGET /two HTTP/1.1\nHost: localhost\nCookie: SESSION_KEY=abcdef...\n```\n\n...it will consider the first request to be complete and valid, and send both on to the h11-based web server over the same socket. The server will then see the two concatenated requests, and interpret them as _one_ request to `/one` whose body includes `/two`'s session key, potentially allowing one user to steal another's credentials.\n\n### Patches\n\nFixed in h11 0.15.0.\n\n### Workarounds\n\nSince exploitation requires the combination of buggy h11 with a buggy (reverse) proxy, fixing either component is sufficient to mitigate this issue.\n\n### Credits\n\nReported by Jeppe Bonde Weikop on 2025-01-09.","aliases":["CVE-2025-43859"],"modified":"2025-04-24T22:22:25.803917Z","published":"2025-04-24T16:07:56Z","related":["CGA-6568-886h-p4m7","CGA-7qwr-ggrp-xcp2"],"database_specific":{"github_reviewed_at":"2025-04-24T16:07:56Z","github_reviewed":true,"severity":"CRITICAL","cwe_ids":["CWE-444"],"nvd_published_at":"2025-04-24T19:15:47Z"},"references":[{"type":"WEB","url":"https://github.com/python-hyper/h11/security/advisories/GHSA-vqfr-h8mv-ghfj"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-43859"},{"type":"WEB","url":"https://github.com/python-hyper/h11/commit/114803a29ce50116dc47951c690ad4892b1a36ed"},{"type":"PACKAGE","url":"https://github.com/python-hyper/h11"}],"affected":[{"package":{"name":"h11","ecosystem":"PyPI","purl":"pkg:pypi/h11"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"0.16.0"}]}],"versions":["0.0.1","0.10.0","0.11.0","0.12.0","0.13.0","0.14.0","0.15.0","0.5.0","0.6.0","0.7.0","0.8.0","0.8.1","0.9.0"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/04/GHSA-vqfr-h8mv-ghfj/GHSA-vqfr-h8mv-ghfj.json"}}],"schema_version":"1.6.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N"}]}

test/test_source.py

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,15 @@ def test_osv_pypi3_json():
208208
return json.loads(fp.read())
209209

210210

211+
@pytest.fixture
212+
def test_osv_pypi4_json():
213+
test_cve_data = os.path.join(
214+
os.path.dirname(os.path.realpath(__file__)), "data", "osv-pypi4.json"
215+
)
216+
with open(test_cve_data, mode="r", encoding="utf-8") as fp:
217+
return json.loads(fp.read())
218+
219+
211220
@pytest.fixture
212221
def test_osv_swift_json():
213222
test_cve_data = os.path.join(
@@ -556,7 +565,7 @@ def test_convert(test_cve_json):
556565
results_count = len(
557566
list(search.search_by_any("cpe:2.3:o:google:android:8.1:*:*:*:*:*:*:*"))
558567
)
559-
assert results_count == 6
568+
assert results_count == 25
560569

561570
cvesource = CVESource()
562571
cve = cvesource.convert5(vulnerabilities)
@@ -692,7 +701,7 @@ def test_nvd_api_convert(
692701
)
693702
)
694703
)
695-
assert results_count == 1
704+
assert results_count == 2
696705

697706
# git_json
698707
vulnerabilities = nvdlatest.convert(test_nvd_api_git_json)
@@ -866,12 +875,12 @@ def test_osv_convert(
866875
db6.clear_all()
867876
osvlatest.store(cve_data)
868877
cve_data_count, cve_index_count = db6.stats()
869-
assert cve_data_count == 5
870-
assert cve_index_count == 5
878+
assert cve_data_count == 4
879+
assert cve_index_count == 4
871880
results_count = len(list(search.search_by_any("CVE-2020-8022")))
872881
assert results_count == 0
873882
results_count = len(list(search.search_by_any("CVE-2019-0647")))
874-
assert results_count == 5
883+
assert results_count == 4
875884
results_count = len(
876885
list(search.search_by_any("pkg:maven/org.springframework/spring-web"))
877886
)
@@ -893,20 +902,20 @@ def test_osv_convert(
893902
db6.clear_all()
894903
osvlatest.store(cve_data)
895904
cve_data_count, cve_index_count = db6.stats()
896-
assert cve_data_count == 4
897-
assert cve_index_count == 4
905+
assert cve_data_count == 3
906+
assert cve_index_count == 3
898907
results_count = len(list(search.search_by_any("CVE-2020-8022")))
899908
assert results_count == 0
900909
results_count = len(list(search.search_by_any("CVE-2019-3192")))
901-
assert results_count == 4
910+
assert results_count == 3
902911
results_count = len(
903912
list(search.search_by_any("pkg:apk/alpine/mariadb?arch=source"))
904913
)
905914
assert results_count == 0
906915
results_count = len(
907916
list(search.search_by_any("pkg:maven/org.springframework/spring-web"))
908917
)
909-
assert results_count == 4
918+
assert results_count == 3
910919

911920
# swift
912921
cve_data = osvlatest.convert(test_osv_swift_json)
@@ -1057,6 +1066,19 @@ def test_osv_convert(
10571066
cve_data = osvlatest.convert(test_osv_pypi3_json)
10581067
assert cve_data
10591068

1069+
def test_osv_pypi4(test_osv_pypi4_json):
1070+
osvlatest = OSVSource()
1071+
db6.clear_all()
1072+
cve_data = osvlatest.convert(test_osv_pypi4_json)
1073+
assert cve_data
1074+
osvlatest.store(cve_data)
1075+
cve_data_count, cve_index_count = db6.stats()
1076+
assert cve_data_count == 1
1077+
assert cve_index_count == 1
1078+
res = search.search_by_any("CVE-2025-43859")
1079+
results_count = len(list(res))
1080+
assert results_count == 1
1081+
10601082

10611083
def test_osv_convert2(test_osv_npm_star_json):
10621084
osvlatest = OSVSource()

0 commit comments

Comments
 (0)