diff --git a/src/Database/Concerns/ValidatesDatabaseParameters.php b/src/Database/Concerns/ValidatesDatabaseParameters.php index 9488fee0..fd242d45 100644 --- a/src/Database/Concerns/ValidatesDatabaseParameters.php +++ b/src/Database/Concerns/ValidatesDatabaseParameters.php @@ -22,6 +22,9 @@ trait ValidatesDatabaseParameters * * Used as the default allowlist in validateParameter(), which validates non-password * parameters such as database names or usernames. + * + * Since special characters are not used in non-password parameters commonly, + * we can be more strict about them to prevent SQL injection and other related issues. */ protected function allowedParameterCharacters(): string { @@ -31,10 +34,13 @@ trait ValidatesDatabaseParameters /** * Characters allowed in database user passwords. * - * Passwords are always quoted in the SQL statements, so it's safe + * Parameters are always quoted in the SQL statements, so it's safe * to allow a wider range of characters, as long as it doesn't include * characters that can break out of the quoted SQL strings (so e.g. * ', ", \, and ` aren't allowed). + * + * The allowlist is less strict for passwords than for other parameters + * because it's more common to use special characters in passwords. */ protected function allowedPasswordCharacters(): string {