Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/security legacy urls #2556

Open
wants to merge 77 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
d5941ac
alert on legacy security.txt locations.
underdarknl Feb 22, 2024
bedbbe5
Update normalize.py
underdarknl Feb 26, 2024
166e62e
fix host header not being set for non https urls in main.py
underdarknl Feb 26, 2024
2bcc07b
add useragent to boefje.json
underdarknl Feb 26, 2024
e6f969f
Update kat_finding_types.json, add legacy security_txt location
underdarknl Feb 26, 2024
acbe491
linting normalize.py
underdarknl Feb 26, 2024
1701d4b
Update kat_finding_types.json
underdarknl Feb 26, 2024
83fbb71
Update normalize.py
underdarknl Feb 26, 2024
27265f4
Merge branch 'main' into feat/security-legacy-urls
underdarknl Feb 26, 2024
3f17ff6
fix legacy url check in normalize.py
underdarknl Mar 12, 2024
be3674f
Merge branch 'main' into feat/security-legacy-urls
underdarknl Mar 13, 2024
a97c534
Create missing security_txt bit.py
underdarknl Mar 13, 2024
65db495
Create missing_security_txt.py
underdarknl Mar 13, 2024
a60532d
Update report.py to handle missing security.txt finding and legacy se…
underdarknl Mar 13, 2024
847e070
Create __init__.py
underdarknl Mar 13, 2024
fa47316
Update bit.py linting
underdarknl Mar 13, 2024
9471edb
Update missing_security_txt.py linting
underdarknl Mar 13, 2024
6101e32
Update missing_security_txt.py
underdarknl Mar 13, 2024
8986326
Update bit.py
underdarknl Mar 13, 2024
3369ea4
Update missing_security_txt.py
underdarknl Mar 13, 2024
d7dceea
Update report.py
underdarknl Mar 13, 2024
c569e45
Update report.py
underdarknl Mar 13, 2024
1c4acc3
Update test_web_systems_report.py
underdarknl Mar 13, 2024
5886f2e
Update test_reports.py, security_Txt is located on website, as are it…
underdarknl Mar 13, 2024
68fb7fc
Update test_reports.py
underdarknl Mar 13, 2024
bd6a518
Merge branch 'main' into feat/security-legacy-urls
ammar92 Mar 20, 2024
d4c623d
Fixes
ammar92 Mar 20, 2024
93b5156
Merge branch 'main' into feat/security-legacy-urls
stephanie0x00 Mar 21, 2024
c9042cc
Fix capitalization
underdarknl Apr 12, 2024
bfa4316
Update missing_security_txt.py
underdarknl Apr 12, 2024
b39216e
Merge branch 'main' into feat/security-legacy-urls
underdarknl Apr 12, 2024
c872d20
Merge branch 'main' into feat/security-legacy-urls
underdarknl Apr 30, 2024
c29b191
Update normalize.py, handle 404's with content
underdarknl May 2, 2024
0d65dcb
Update main.py, add timeout, and make timeout configurable, add origi…
underdarknl May 2, 2024
437ecc2
Update boefje.json
underdarknl May 2, 2024
3f40ad1
Create schema.json
underdarknl May 2, 2024
0ff8af4
Update security_txt_result_different_website.json, add status code
underdarknl May 3, 2024
4ad34f2
Update security_txt_result_same_website.json
underdarknl May 3, 2024
2f63581
Update normalize.py, add fallback for old rawfiles that dont have sta…
underdarknl May 3, 2024
ab28a3d
Merge branch 'main' into feat/security-legacy-urls
underdarknl May 3, 2024
6692d94
linting
underdarknl May 3, 2024
0bdcefd
Update kat_finding_types.json
underdarknl May 3, 2024
eb8dac2
refactor boefje, single output
underdarknl May 3, 2024
9be85eb
Update normalize.py
underdarknl May 3, 2024
bfb27ea
Create security_txt_result_no_file.json
underdarknl May 3, 2024
6c1b57b
Create security_txt_legacy-only.json
underdarknl May 3, 2024
c43f7a6
add legacy only test
underdarknl May 3, 2024
d1ea058
linting security_txt_legacy-only.json
underdarknl May 3, 2024
77c2661
linting security_txt_result_no_file.json
underdarknl May 3, 2024
96ec478
linting main.py
underdarknl May 3, 2024
63c5f0f
linting normalize.py
underdarknl May 3, 2024
08d720c
Update test_sucurity_txt.py
underdarknl May 3, 2024
8645670
Update and rename test_sucurity_txt.py to test_security_txt.py
underdarknl May 3, 2024
d141857
Rename security_txt_legacy-only.json to security_txt_results_legacy_o…
underdarknl May 3, 2024
55ea05b
Update security_txt_results_legacy_only.json
underdarknl May 3, 2024
2501a68
Update security_txt_result_no_file.json
underdarknl May 3, 2024
b970158
Update main.py
underdarknl May 3, 2024
f638b07
Update normalize.py
underdarknl May 3, 2024
c40b024
Update test_security_txt.py
underdarknl May 3, 2024
1a76913
lint test_security_txt.py
underdarknl May 3, 2024
c0d6bc4
Update test_security_txt.py
underdarknl May 3, 2024
66bc846
Update main.py
underdarknl May 3, 2024
50028d1
Update normalize.py
underdarknl May 3, 2024
e77541a
Update security_txt_result_no_file.json
underdarknl May 3, 2024
a8dd860
Update security_txt_results_legacy_only.json
underdarknl May 3, 2024
c3725ff
Update test_security_txt.py
underdarknl May 3, 2024
1e94dcc
Update security_txt_results_legacy_only.json
underdarknl May 3, 2024
c55ce43
Update test_security_txt.py
underdarknl May 3, 2024
0a78b16
Merge branch 'main' into feat/security-legacy-urls
underdarknl May 21, 2024
d4aab32
Update test_security_txt.py
underdarknl May 21, 2024
9590a46
Update test_security_txt.py
underdarknl May 21, 2024
04ee3e2
Update test_security_txt.py
underdarknl May 21, 2024
b2d466c
Update test_security_txt.py
underdarknl May 21, 2024
e4b06ca
Merge branch 'main' into feat/security-legacy-urls
underdarknl Jun 3, 2024
d87c1c8
Merge branch 'main' into feat/security-legacy-urls
underdarknl Sep 10, 2024
df082be
precommit
underdarknl Dec 30, 2024
79b806a
linting
underdarknl Dec 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -504,45 +504,52 @@
"recommendation": "Ideally to minimize the attack surface as much as possible these panels should not be directly exposed to the internet"
},
"KAT-CRITICAL-BAD-CIPHER": {
"description": "Ciphers are used that are labeled as bad. These should not be used anymore",
"source": null,
"risk": "critical",
"impact": null,
"recommendation": "It is recommended to only use ciphers labelled as 'good': TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_GCM_SHA256"
"description": "Ciphers are used that are labeled as bad. These should not be used anymore",
"source": null,
"risk": "critical",
"impact": null,
"recommendation": "It is recommended to only use ciphers labelled as 'good': TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_GCM_SHA256"
},
"KAT-MEDIUM-BAD-CIPHER": {
"description": "Ciphers are used that are labeled as bad. These should not be used anymore",
"source": null,
"risk": "medium",
"impact": null,
"recommendation": "It is recommended to only use ciphers labelled as 'good': TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_GCM_SHA256"
"description": "Ciphers are used that are labeled as bad. These should not be used anymore",
"source": null,
"risk": "medium",
"impact": null,
"recommendation": "It is recommended to only use ciphers labelled as 'good': TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_GCM_SHA256"
},
"KAT-RECOMMENDATION-BAD-CIPHER": {
"description": "Ciphers are used that are labeled as bad. These should not be used anymore",
"source": null,
"risk": "recommendation",
"impact": null,
"recommendation": "It is recommended to only use ciphers labelled as 'good': TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_GCM_SHA256"
"description": "Ciphers are used that are labeled as bad. These should not be used anymore",
"source": null,
"risk": "recommendation",
"impact": null,
"recommendation": "It is recommended to only use ciphers labelled as 'good': TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_GCM_SHA256"
},
"KAT-NO-RPKI": {
"description": "The IP address does not have a route announcement that is matched by the published Route Policy and Authorization (RPKI)",
"source": null,
"risk": "low",
"impact": "Without RPKI validation, your servers might be more vulnerable to unintended or malicious routing configuration errors, potentially leading to inaccessibility of your servers or interception of internet traffic directed to them.",
"recommendation": "Work on implementing RPKI for your IP addresses. This may involve creating Route Origin Authorizations (ROAs) that specify which Autonomous Systems (AS) are authorized to announce your IP addresses."
"description": "The IP address does not have a route announcement that is matched by the published Route Policy and Authorization (RPKI)",
"source": null,
"risk": "low",
"impact": "Without RPKI validation, your servers might be more vulnerable to unintended or malicious routing configuration errors, potentially leading to inaccessibility of your servers or interception of internet traffic directed to them.",
"recommendation": "Work on implementing RPKI for your IP addresses. This may involve creating Route Origin Authorizations (ROAs) that specify which Autonomous Systems (AS) are authorized to announce your IP addresses."
},
"KAT-EXPIRED-RPKI": {
"description": "The route announcement that is matched by the published Route Policy and Authorization (RPKI) is expired",
"source": null,
"risk": "low",
"impact": "Without RPKI validation, your servers might be more vulnerable to unintended or malicious routing configuration errors, potentially leading to inaccessibility of your servers or interception of internet traffic directed to them.",
"recommendation": "Make sure that the Route Origin Authorizations (ROAs) that specify which Autonomous Systems (AS) are authorized to announce your IP addresses are valid and not expired."
"description": "The route announcement that is matched by the published Route Policy and Authorization (RPKI) is expired",
"source": null,
"risk": "low",
"impact": "Without RPKI validation, your servers might be more vulnerable to unintended or malicious routing configuration errors, potentially leading to inaccessibility of your servers or interception of internet traffic directed to them.",
"recommendation": "Make sure that the Route Origin Authorizations (ROAs) that specify which Autonomous Systems (AS) are authorized to announce your IP addresses are valid and not expired."
},
"KAT-NO-CAA": {
"description": "This zone does not carry at least one CAA record.",
"source": null,
"risk": "low",
"impact": null,
"recommendation": "Set a CAA record to limit which CA's are allowed to issue certs."
},
"KAT-LEGACY-SECURITY-LOCATION": {
"description": "This website only has a legacy location security.txt file.",
"source": "https://www.rfc-editor.org/rfc/rfc9116#section-3-1",
"risk": "info",
"impact": null,
"recommendation": "Add a security.txt file location in the .well-known folder."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
"consumes": [
"Website"
],
"environment_keys": [
"USERAGENT"
],
"scan_level": 2
}
8 changes: 4 additions & 4 deletions boefjes/boefjes/plugins/kat_security_txt_downloader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ def run(boefje_meta: BoefjeMeta) -> list[tuple[set, bytes | str]]:
session.mount(uri, ForcedIPHTTPSAdapter(dest_ip=ip))
else:
addr = ipaddress.ip_address(ip)
netloc = f"[{ip}]" if addr.version == 6 else ip

uri = f"{scheme}://{netloc}/{path}"
iploc = f"[{ip}]" if addr.version == 6 else ip
uri = f"{scheme}://{iploc}/{path}"

response = do_request(netloc, session, uri, useragent)

# if the response is 200, return the content
if response.status_code == 200:
results[path] = {"content": response.content.decode(), "url": response.url, "ip": ip, "status": 200}
# if the response is 301, we need to follow the location header to the correct security txt,
# we can not force the ip anymore
# we can not force the ip anymore because we dont know it yet.
# TODO return a redirected URL and have OpenKAT figure out if we want to follow this.
elif response.status_code in [301, 302, 307, 308]:
uri = response.headers["Location"]
response = requests.get(uri, stream=True, timeout=30, verify=False) # noqa: S501
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from octopoes.models.ooi.network import IPAddressV4, IPAddressV6, IPPort, Network
from octopoes.models.ooi.service import IPService, Service
from octopoes.models.ooi.web import URL, SecurityTXT, Website
from octopoes.models.types import Finding, KATFindingType


def run(normalizer_meta: NormalizerMeta, raw: bytes | str) -> Iterable[OOI]:
Expand All @@ -17,6 +18,7 @@ def run(normalizer_meta: NormalizerMeta, raw: bytes | str) -> Iterable[OOI]:
website_original = Reference.from_str(boefje_meta.input_ooi)
input_ = boefje_meta.arguments["input"]

location_rfc_compliant = False
for path, details in results.items():
if details["content"] is None:
continue
Expand All @@ -27,6 +29,16 @@ def run(normalizer_meta: NormalizerMeta, raw: bytes | str) -> Iterable[OOI]:
yield url_original
url = URL(raw=details["url"], network=Network(name=input_["hostname"]["network"]["name"]).reference)
yield url

# Check for legacy url https://www.rfc-editor.org/rfc/rfc9116#section-3-1
if path == ".well-known/security.txt":
location_rfc_compliant = True
elif path == "security.txt" and not location_rfc_compliant:
ft = KATFindingType(id="KAT-LEGACY-SECURITY-LOCATION")
yield ft
yield Finding(
description="Only legacy Security.txt location found.", finding_type=ft.reference, ooi=url.reference
)
underdarknl marked this conversation as resolved.
Show resolved Hide resolved
url_parts = urlparse(details["url"])
# we need to check if the website of the response is the same as the input website
if (
Expand Down