mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 11:25:52 -05:00
# Security, Validation & Session Improvements ## Changes * **Hardened IP/CIDR validation** * Properly handles invalid IP addresses and CIDR ranges during API key creation. * Invalid IP/CIDR data now fails safely instead of causing a 500 error. * **Improved reCAPTCHA error handling** * Handles network and verification failures gracefully. * Fixed undefined result notices and removed duplicate checks. * **Added file permission activity logging** * File permission (`chmod`) changes are now recorded in the activity log. * **Removed duplicate 2FA middleware** * Cleaned up duplicate `RequireTwoFactorAuthentication` registration from API routes. * **Improved session revocation on password changes** * Password changes now invalidate other active sessions. * Rotates the `remember_token` and removes stale database sessions where applicable. * Applies consistently across password resets and user password changes. * **Reduced unnecessary public storage access** * Disabled automatic public storage routes for the local filesystem disk to reduce the attack surface. * **Hardened file manager request validation** * Added strict validation for file permission modes. * Fixed optional `root` validation rules. * Added length limits for file paths, roots, and file/folder names. * **Hardened mount source and target path validation** * Prevents path traversal and subpath-based bypasses in mount source and target validation. * Handles trailing slashes and normalized paths correctly. * Prevents mounts from targeting protected subdirectories, such as another server's volume directory.
50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pterodactyl\Validation;
|
|
|
|
use Illuminate\Validation\Rule;
|
|
use Pterodactyl\Models\Mount;
|
|
use Pterodactyl\Rules\NotInPathHierarchy;
|
|
|
|
final class MountRules
|
|
{
|
|
/**
|
|
* Validation rules for the mount requests.
|
|
*
|
|
* @param Mount|null $ignore the mount being updated
|
|
* @return NormalizedValidationRules
|
|
*/
|
|
public static function rules(?Mount $ignore = null): array
|
|
{
|
|
return [
|
|
'name' => [
|
|
'required',
|
|
'string',
|
|
'min:2',
|
|
'max:64',
|
|
Rule::unique('mounts', 'name')->ignore($ignore),
|
|
],
|
|
'description' => ['nullable', 'string', 'max:191'],
|
|
|
|
'source' => [
|
|
'required',
|
|
'string',
|
|
'starts_with:/',
|
|
new NotInPathHierarchy(Mount::$invalidSourcePaths),
|
|
],
|
|
|
|
'target' => [
|
|
'required',
|
|
'string',
|
|
'starts_with:/',
|
|
new NotInPathHierarchy(Mount::$invalidTargetPaths),
|
|
],
|
|
|
|
'read_only' => ['sometimes', 'boolean'],
|
|
'user_mountable' => ['sometimes', 'boolean'],
|
|
];
|
|
}
|
|
}
|