Skip to content

Commit 1f0e957

Browse files
committed
🔒 Don't disclose if account exists when resetting passwords, closes pterodactyl#358
1 parent 9106971 commit 1f0e957

File tree

5 files changed

+233
-125
lines changed

5 files changed

+233
-125
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
1212
### Changed
1313
* Subuser permissions are now stored in `Permission::list()` to make views way cleaner and make adding to views significantly cleaner.
1414
* `[pre.7]` — Sidebar for file manager now is a single link rather than a dropdown.
15+
* Attempting to reset a password for an account that does not exist no longer returns an error, rather it displays a success message. Failed resets trigger a `Pterodactyl\Events\Auth\FailedPasswordReset` event that can be caught if needed to perform other actions.
1516

1617
## v0.6.0-pre.7 (Courageous Carniadactylus)
1718
### Fixed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* Pterodactyl - Panel
4+
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
namespace Pterodactyl\Events\Auth;
26+
27+
use Illuminate\Queue\SerializesModels;
28+
29+
class FailedPasswordReset
30+
{
31+
use SerializesModels;
32+
33+
/**
34+
* The IP that the request originated from.
35+
*
36+
* @var string
37+
*/
38+
public $ip;
39+
40+
/**
41+
* The email address that was used when the reset request failed.
42+
*
43+
* @var string
44+
*/
45+
public $email;
46+
47+
/**
48+
* Create a new event instance.
49+
*
50+
* @param string $ip
51+
* @param string $email
52+
* @return void
53+
*/
54+
public function __construct($ip, $email)
55+
{
56+
$this->ip = $ip;
57+
$this->email = $email;
58+
}
59+
}

app/Http/Controllers/Auth/ForgotPasswordController.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,33 @@
11
<?php
2+
/**
3+
* Pterodactyl - Panel
4+
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
224

325
namespace Pterodactyl\Http\Controllers\Auth;
426

27+
use Illuminate\Http\Request;
28+
use Illuminate\Support\Facades\Password;
529
use Pterodactyl\Http\Controllers\Controller;
30+
use Pterodactyl\Events\Auth\FailedPasswordReset;
631
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
732

833
class ForgotPasswordController extends Controller
@@ -29,4 +54,21 @@ public function __construct()
2954
{
3055
$this->middleware('guest');
3156
}
57+
58+
/**
59+
* Get the response for a failed password reset link.
60+
*
61+
* @param \Illuminate\Http\Request
62+
* @param string $response
63+
* @return \Illuminate\Http\RedirectResponse
64+
*/
65+
protected function sendResetLinkFailedResponse(Request $request, $response)
66+
{
67+
// As noted in #358 we will return success even if it failed
68+
// to avoid pointing out that an account does or does not
69+
// exist on the system.
70+
event(new FailedPasswordReset($request->ip(), $request->only('email')));
71+
72+
return $this->sendResetLinkResponse(Password::RESET_LINK_SENT);
73+
}
3274
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313
"require": {
1414
"php": ">=5.6.4",
15-
"laravel/framework": "5.3.21",
15+
"laravel/framework": "5.3.31",
1616
"barryvdh/laravel-debugbar": "2.2.3",
1717
"doctrine/dbal": "2.5.5",
1818
"guzzlehttp/guzzle": "6.2.2",

0 commit comments

Comments
 (0)