Skip to content

Commit

Permalink
remove multiversions handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
ybadaoui-ostorlab committed Oct 17, 2024
1 parent c349e5a commit a489d16
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 40 deletions.
29 changes: 13 additions & 16 deletions agent/exploits/cve_2024_9487.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,17 @@ def check(self, target: definitions.Target) -> list[definitions.Vulnerability]:
return vulnerabilities

if (matched := self.version_pattern.findall(resp.text)) != []:
for extracted_version in matched:
if isinstance(extracted_version, tuple):
extracted_version = extracted_version[0]
if version.parse(extracted_version) < version.parse(MAX_FIXED_VERSION):
if version.parse(extracted_version) < version.parse(
MAX_NONFIXED_VERSION
):
vulnerability = self._create_vulnerability(target)
vulnerabilities.append(vulnerability)
continue
version_prefix = ".".join(extracted_version.split(".")[:2])
if version.parse(extracted_version) < version.parse(
FIXED_VERSIONS[version_prefix]
):
vulnerability = self._create_vulnerability(target)
vulnerabilities.append(vulnerability)
extracted_version = matched[0]
if version.parse(extracted_version) < version.parse(MAX_FIXED_VERSION):
version_prefix = ".".join(extracted_version.split(".")[:2])
if version.parse(extracted_version) < version.parse(
MAX_NONFIXED_VERSION
):
vulnerability = self._create_vulnerability(target)
vulnerabilities.append(vulnerability)
elif version.parse(extracted_version) < version.parse(
FIXED_VERSIONS[version_prefix]
):
vulnerability = self._create_vulnerability(target)
vulnerabilities.append(vulnerability)
return vulnerabilities
25 changes: 1 addition & 24 deletions tests/exploits/cve_2024_9487_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,4 @@ def testCVE20249487_whenVersionVeryOld_reportFinding(
"http://localhost:80 is vulnerable to CVE-2024-9487, "
"GITHUB ENTERPRISE SERVER AUTHENTICATION BYPASS"
)


def testCVE20249487_whenMultiVersions_doNotCrash(
requests_mock: req_mock.mocker.Mocker,
) -> None:
"""CVE_2024_9487 unit test: case when multible versions matched."""
requests_mock.get(
"http://localhost:80/",
text="""
<div class="d-flex flex-justify-center py-2">
<span class="f6 color-fg-muted">GitHub Enterprise Server 3.14.2</span>
<span class="f6 color-fg-muted">GitHub Enterprise Server 3.14.3</span>
</div>
""",
status_code=200,
)
exploit_instance = cve_2024_9487.CVE20249487Exploit()
target = definitions.Target("http", "localhost", 80)

accept = exploit_instance.accept(target)
vulnerabilities = exploit_instance.check(target)

assert accept is True
assert len(vulnerabilities) == 0

0 comments on commit a489d16

Please sign in to comment.