Skip to content

Commit

Permalink
16219 SEC Limit length of Hostname
Browse files Browse the repository at this point in the history
Prior to this Werk it was possible to create Hosts with arbitrary length.
Since Checkmk stores information in files which paths contain the hostname these path could exceed the allowed length leading to various errors to an extend that rendered the usage of parts of the GUI useless.

We found this vulnerability internally.

<b>Affected Versions</b>:
* 2.2.0
* 2.1.0
* 2.0.0

<b>Vulnerability Management</b>:
We have rated the issue with a CVSS Score of 2.7 (Low) with the following CVSS vector:
<tt>CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:N/A:L</tt>.
We assigned CVE-2023-23549 to this vulnerability.

<b>Changes</b>:
This Werk adds a maximum length of 253 characters for the hostname.

CMK-15105

Change-Id: I4be4745ede4220d05f4ff01d51aa6252dc9a1b57
  • Loading branch information
Shortfinga committed Nov 15, 2023
1 parent 666306b commit ba2276b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
30 changes: 30 additions & 0 deletions .werks/16219
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Title: Limit length of Hostname
Class: security
Compatible: compat
Component: wato
Date: 1699601325
Edition: cre
Knowledge: undoc
Level: 1
State: unknown
Version: 2.2.0p15

Prior to this Werk it was possible to create Hosts with arbitrary length.
Since Checkmk stores information in files which paths contain the hostname these path could exceed the allowed length leading to various errors to an extend that rendered the usage of parts of the GUI useless.

We found this vulnerability internally.

<b>Affected Versions</b>:
LI: 2.2.0
LI: 2.1.0
LI: 2.0.0

<b>Vulnerability Management</b>:
We have rated the issue with a CVSS Score of 2.7 (Low) with the following CVSS vector:
<tt>CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:N/A:L</tt>.
We assigned CVE-2023-23549 to this vulnerability.

<b>Changes</b>:
This Werk adds a maximum length of 253 characters for the hostname.


2 changes: 1 addition & 1 deletion cmk/utils/regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
g_compiled_regexes: dict[tuple[str, int], re.Pattern[str]] = {}

REGEX_HOST_NAME_CHARS = r"-0-9a-zA-Z_."
REGEX_HOST_NAME = r"^[%s]+$" % REGEX_HOST_NAME_CHARS
REGEX_HOST_NAME = f"^[{REGEX_HOST_NAME_CHARS}]{{,253}}$"

REGEX_GENERIC_IDENTIFIER_CHARS = r"-0-9a-zA-Z_."
REGEX_GENERIC_IDENTIFIER = r"^[%s]+$" % REGEX_GENERIC_IDENTIFIER_CHARS
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/cmk/gui/test_valuespec.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,18 @@ def test_transform_value_no_match(self) -> None:
vs.Integer(),
]
).transform_value("strange")


@pytest.mark.parametrize(
"hostname",
(
"", # empty
"../../foo", # invalid char, path traversal
"a" * 255, # too long
),
)
def test_nvalid_hostnames_rejected(hostname: str) -> None:
"""test that certain hostnames fail validation"""

with pytest.raises(MKUserError):
vs.Hostname().validate_value(hostname, "varprefix")

0 comments on commit ba2276b

Please sign in to comment.