CVE-2023-38492 (JSON, published 2023-07-27T16:15Z)
Description: value: Kirby is a content management system. A vulnerability in versions prior to 3.5.8.3, 3.6.6.3, 3.7.5.2, 3.8.4.1, and 3.9.6 affects all Kirby sites with user accounts (unless Kirby's API and Panel are disabled in the config). The real-world impact of this vulnerability is limited, however we still recommend to update to one of the patch releases because they also fix more severe vulnerabilities.

Kirby's authentication endpoint did not limit the password length. This allowed attackers to provide a password with a length up to the server's maximum request body length. Validating that password against the user's actual password requires hashing the provided password, which requires more CPU and memory resources (and therefore processing time) the longer the provided password gets. This could be abused by an attacker to cause the website to become unresponsive or unavailable. Because Kirby comes with a built-in brute force protection, the impact of this vulnerability is limited to 10 failed logins from each IP address and 10 failed logins for each existing user per hour.

The problem has been patched in Kirby 3.5.8.3, 3.6.6.3, 3.7.5.2, 3.8.4.1, and 3.9.6. In all of the mentioned releases, the maintainers have added password length limits in the affected code so that passwords longer than 1000 bytes are immediately blocked, both when setting a password and when logging in.
Severity: nan (CVSS v3 base score: 7.5)
Weakness: CWE-770 \u2014 Allocation of Resources Without Limits or Throttling
The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.
Repository: https://github.com/getkirby/kirby
Files changed:
i18n/translations/bg.json
i18n/translations/ca.json
i18n/translations/cs.json
i18n/translations/da.json
i18n/translations/de.json
i18n/translations/el.json
i18n/translations/en.json
i18n/translations/eo.json
i18n/translations/es_419.json
i18n/translations/es_ES.json
i18n/translations/fa.json
i18n/translations/fi.json
i18n/translations/fr.json
i18n/translations/hu.json
i18n/translations/id.json
i18n/translations/is_IS.json
i18n/translations/it.json
i18n/translations/ko.json
i18n/translations/lt.json
i18n/translations/nb.json
i18n/translations/nl.json
i18n/translations/pl.json
i18n/translations/pt_BR.json
i18n/translations/pt_PT.json
i18n/translations/ro.json
i18n/translations/ru.json
i18n/translations/sk.json
i18n/translations/sv_SE.json
i18n/translations/tr.json
src/Cms/User.php
src/Cms/UserRules.php
tests/Cms/Users/UserRulesTest.php
tests/Cms/Users/UserTest.php
Commit message: Fix password length vulnerability

https://github.com/getkirby/kirby/security/advisories/GHSA-3v6j-v3qc-cxff


Vulnerable code:
		$this->assertSame(2, $caught);

Fixed code:
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
	"error.user.password.excessive": "Please enter a valid password. Passwords must not be longer than 1000 characters.",
		// `UserRules` enforces a minimum length of 8 characters,
		// so everything below that is a typo
		// too long passwords can cause DoS attacks
		if (Str::length($password) > 1000) {
			throw new InvalidArgumentException(['key' => 'user.password.excessive']);
		}

		// too short passwords are ineffective
		// too long passwords can cause DoS attacks
		// and are therefore blocked in the auth system
		// (blocked here as well to avoid passwords
		// that cannot be used to log in)
		if (Str::length($password ?? null) > 1000) {
			throw new InvalidArgumentException([
				'key' => 'user.password.excessive',
			]);
		}

			['Password', str_repeat('1234', 300), 'Please enter a valid password. Passwords must not be longer than 1000 characters.'],
			[str_repeat('long', 300), false],
			$this->assertSame(
				'Please enter a valid password. Passwords must be at least 8 characters long.',
				$e->getMessage()
			);
			$this->assertSame(400, $e->getHttpCode());
			$caught++;
		}

		try {
			$user->validatePassword(str_repeat('long', 300));
		} catch (\Kirby\Exception\InvalidArgumentException $e) {
			$this->assertSame(
				'Please enter a valid password. Passwords must not be longer than 1000 characters.',
				$e->getMessage()
			);
			$this->assertSame('Wrong password', $e->getMessage());
		$this->assertSame(3, $caught);