Skip to content

Commit f91e4c5

Browse files
committed
Attach user to cache to prevent showing servers they can't access.
1 parent 911434d commit f91e4c5

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ This file is a running track of new features and fixes to each version of the pa
33

44
This project follows [Semantic Versioning](http://semver.org) guidelines.
55

6+
## v0.6.0-pre.4 (Courageous Carniadactylus)
7+
### Fixed
8+
* `[pre.3]` — Fixes bug in cache handler that doesn't cache against the user making the request. Would have allowed for users to access servers not belonging to themselves in production.
9+
610
## v0.6.0-pre.3 (Courageous Carniadactylus)
711
### Fixed
812
* `[pre.2]` — Fixes bug where servers could not be manually deployed to nodes due to a broken SQL call.

app/Models/Server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class Server extends Model
9696
public static function byUuid($uuid)
9797
{
9898
// Results are cached because we call this functions a few times on page load.
99-
$result = Cache::remember('Server.byUuid.' . $uuid, 60, function () use ($uuid) {
99+
$result = Cache::remember('Server.byUuid.' . $uuid . Auth::user()->uuid, 60, function () use ($uuid) {
100100
$query = self::with('service', 'node')->where(function ($q) use ($uuid) {
101101
$q->where('uuidShort', $uuid)->orWhere('uuid', $uuid);
102102
});

app/Observers/ServerObserver.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
namespace Pterodactyl\Observers;
2626

27+
use Auth;
2728
use Cache;
2829
use Carbon;
2930
use Pterodactyl\Events;
@@ -141,8 +142,8 @@ public function updating(Server $server)
141142
public function updated(Server $server)
142143
{
143144
// Clear Caches
144-
Cache::forget('Server.byUuid.' . $server->uuid);
145-
Cache::forget('Server.byUuid.' . $server->uuidShort);
145+
Cache::forget('Server.byUuid.' . $server->uuid . Auth::user()->uuid);
146+
Cache::forget('Server.byUuid.' . $server->uuidShort . Auth::user()->uuid);
146147

147148
event(new Events\Server\Updated($server));
148149
}

0 commit comments

Comments
 (0)