mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
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:
@@ -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]));
|
||||
|
@@ -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',
|
||||
|
Reference in New Issue
Block a user