Fix authentication mass assignment vulnerability (#14468)

Users were able to submit changes to fields they should not have access to change by bypassing the frontend validation.  Correct backend validation to prevent that.
This commit is contained in:
Tony Murray
2022-10-17 12:11:14 -05:00
committed by GitHub
parent abf00ea75e
commit 09a2977adb
2 changed files with 15 additions and 2 deletions

View File

@@ -180,7 +180,7 @@ class UserController extends Controller
}
}
$user->fill($request->all());
$user->fill($request->validated());
if ($request->has('dashboard') && $this->updateDashboard($user, $request->get('dashboard'))) {
$flasher->addSuccess(__('Updated dashboard for :username', ['username' => $user->username]));

View File

@@ -37,11 +37,24 @@ class UpdateUserRequest extends FormRequest
*/
public function rules()
{
if ($this->user()->isAdmin()) {
return [
'realname' => 'nullable|max:64|alpha_space',
'email' => 'nullable|email|max:64',
'descr' => 'nullable|max:30|alpha_space',
'new_password' => 'nullable|confirmed|min:' . Config::get('password.min_length', 8),
'new_password_confirmation' => 'nullable|same:new_password',
'dashboard' => 'int',
'level' => 'int',
'enabled' => 'nullable',
'can_modify_passwd' => 'nullable',
];
}
return [
'realname' => 'nullable|max:64|alpha_space',
'email' => 'nullable|email|max:64',
'descr' => 'nullable|max:30|alpha_space',
'level' => 'int',
'old_password' => 'nullable|string',
'new_password' => 'nullable|confirmed|min:' . Config::get('password.min_length', 8),
'new_password_confirmation' => 'nullable|same:new_password',