Commit Graph
196 Commits
Author SHA1 Message Date
robert dennis bc50a8bbeb backend cleanup 2026-10-08 17:22:14 -04:00
Sky Mulley ff9527a2e9 fix tests to pass 2026-10-08 09:54:19 +01:00
Sandip Ghimire bb4e89826e fix(security): harden path validation, session revocation, and request handling (#7255)
# 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.
2026-10-07 12:39:12 -04:00
Joshua Piper 6f91bdbb54 Prevent leaking password reset token to reCAPTCHA (#7258)
Changes the panel's default `Referrer-Policy` from
`no-referrer-when-downgrade` to `strict-origin-when-cross-origin`.

Prevents path and query string being sent in `Referrer`, so Google don't
get our tasty password reset url tokens.

Nothing I could find in panel reads a referrer cross-origin, and Wings
checks Origin not Referrer.
2026-10-06 23:00:11 -04:00
robert dennis 16b0198593 extension route middleware tweaks 2026-10-06 20:11:59 -04:00
Sky Mulley 6533e91b62 don't allow extensions to be installed from admin api 2026-10-06 01:06:15 +01:00
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00
Dane Everitt a81c3b4d52 Add support for stripe-style identifiers on existing models with UUIDs (#5548)
This is a partial implementation to begin moving towards stripe-style
identifiers for resources in the system. Any models with an existing
`uuid` column can easily be updated to return an identifier in the
format of `prfx_xyz` where `prfx` is a four character prefix, and `xyz`
is the UUID, encoded using base-32.

These are quite easy to use within the API layer because we just need to
do one quick transformation to extract the UUID for those models. This
PR implements that logic for servers in the `SubstituteClientBindings`
logic.

A future PR will need to come through and handle identifiers for models
that _don't_ currently use UUIDs for reference that we want to expose to
clients. In those cases it is easier to just generate base-32 encoded
UUID7s that get stored in the database and indexed. They follow the same
base approach, but you don't need to do any transformations in the code
(other than stripping the prefix, unless we decide to store the prefix).

There is also now a `PTERODACTYL_USE_SERVER_IDENTIFIERS` environment
variable, that when set to true, updates the front-end and API response
to use this new identifier in place of the `uuidShort` value.
2026-02-14 11:21:57 -08:00
Dane Everitt 14185a9430 Improve security posture, update dependencies (#5569)
Very minor changes, just adding some default headers in the event people
don't configure this on their webserver. Also updating some packages to
resolve open security alerts.
2026-02-14 11:18:17 -08:00
Dane Everitt a264791fd4 Update PHP and JS dependencies to latest versions and modernize codebase (#5446) 2025-12-20 15:55:13 -08:00
Matthew Penner 8ca098940a chore: update composer dependencies (#5198)
Signed-off-by: Matthew Penner <me@matthewp.io>
2024-10-21 19:18:20 -06:00
Matthew Penner 1d38b4f0e2 Laravel 10 (#4706) 2023-02-23 12:30:16 -07:00
Boy132 032e4f2e31 Apply node maintenance mode to servers (#4421) 2022-11-06 16:02:30 -07:00
Matthew PennerandDaneEveritt cbcf62086f Upgrade to Laravel 9 (#4413)
Co-authored-by: DaneEveritt <dane@daneeveritt.com>
2022-10-14 10:59:20 -06:00
DaneEveritt 0520014c0f Add support for tracking when an activity event is triggered from an API key 2022-06-18 12:07:44 -04:00
DaneEveritt 92c1c162af Code cleanup for facades 2022-06-18 12:07:32 -04:00
DaneEveritt 6ffe5730da Log when an API key is blocked due to IP restrictions 2022-06-18 12:04:51 -04:00
DaneEveritt 287fd60891 Log activity when modifying account details 2022-05-29 18:48:35 -04:00
DaneEveritt 5bb66a00d8 Add new activity logging code to replace audit log 2022-05-28 15:36:26 -04:00
DaneEveritt b051718afe Fix up API handling logic for keys and set a prefix on all keys 2022-05-22 19:03:51 -04:00
DaneEveritt 4d3362b24f Perform a bit of code cleanup 2022-05-22 17:23:48 -04:00
DaneEveritt 56f15c15a1 We can make this middleware significantly simpler 2022-05-22 16:54:07 -04:00
DaneEveritt 0fa33e0438 Mark a request as being stateful if a cookie for the session is provided at all
This accounts for poorly configured API clients that try to use cookies for authentication purposes. Treat everything with a session cookie as being a stateful request from the front-end.
2022-05-22 16:50:36 -04:00
DaneEveritt bd37978a98 Initial pass at implementing Laravel Sanctum for authorization on the API 2022-05-22 14:57:06 -04:00
DaneEveritt e313dff674 Massively simplify API binding logic
Changes the API internals to use normal Laravel binding which automatically supports nested-models and can determine their relationships. This removes a lot of confusingly complex internal logic and replaces it with standard Laravel code.

This also removes a deprecated "getModel" method and fully replaces it with a "parameter" method that does stricter type-checking.
2022-05-22 14:10:01 -04:00
DaneEveritt 530558b0f8 Update deprecated JSON response creation and unnecessary middleware 2022-05-04 19:23:01 -04:00
DaneEveritt 34ffaebd3e Run cs-fix, ensure we only install dependency versions supporting 7.4+ 2022-05-04 19:01:29 -04:00
Dane Everitt dfa329ddf2 [security] ensure session is only for that request when authenticating user API key
https://github.com/pterodactyl/panel/security/advisories/GHSA-7v3x-h7r2-34jv
2022-01-19 21:09:17 -05:00
Dane Everitt bf9cbe2c6d Add consistent CSRF token verification to API endpoints; address security concern with non-CSRF protected endpoints 2021-11-16 20:02:18 -08:00
Dane Everitt 60eff40a0c Fix session management on client API requests; closes #3727
Versions of Pterodactyl prior to 1.6.3 used a different throttle pathway for
requests. That pathway found the current request user before continuing on to
other in-app middleware, thus the user was available downstream.

Changes introduced in 1.6.3 changed the throttler logic, therefore removing this
step. As a result, the client API could not always get the currently authenticated
user when cookies were used (aka, requests from the Panel UI, and not API directly).

This change corrects the logic to get the session setup correctly before falling
through to authenticating as a user using the API key. If a cookie is present and a
user is found as a result that session will be used. If an API key is provided it is
ignored when a cookie is also present.

In order to keep the API stateless any session created for an API request stemming
from an API key will have the associated session deleted at the end of the request,
and the 'Set-Cookies' header will be stripped from the response.
2021-11-03 20:51:39 -07:00
Alex 9656378783 Fix 401 error typo (#3393) 2021-06-03 13:35:51 -07:00
Dane Everitt e30a765071 Simplify logic when a server is in an unsupported state 2021-01-30 13:28:31 -08:00
Dane Everitt 0a2c89e9f4 Reeformat with new rules post merge 2021-01-25 19:20:51 -08:00
Dane Everitt 663143de0b Merge branch 'develop' into dane/restore-backups 2021-01-25 19:16:40 -08:00
Dane Everitt c449ca5155 Use more standardized phpcs 2021-01-23 12:33:34 -08:00
Dane EverittandMatthew Penner a043071e3c Update to Laravel 8
Co-authored-by: Matthew Penner <me@matthewp.io>
2021-01-23 12:12:54 -08:00
Dane Everitt e8dcd30e0c [security] fix resources not properly returning an error when they don't match the server in the URL
Prior to this fix certain resources were accessible even when their assigned server was not the same as the server in the URL. This causes the resource server relationship to not match the server variable present on the request.

Due to this failed logic it was possible for users to access resources they should not have been able to access otherwise for some areas of the panel.
2021-01-19 21:19:17 -08:00
Dane Everitt a75a347d65 Remove suspended & installing fields, replace with single status field 2021-01-17 15:51:56 -08:00
Dane Everitt 6c39288def Clarify error messaging for transfers 2020-12-24 10:14:10 -08:00
Matthew Penner 37cfa151b6 Use ServerTransferringException 2020-12-17 10:37:14 -07:00
Matthew Penner e69d9b2c26 Update comment in AuthenticateServerAccess.php 2020-12-17 10:35:54 -07:00
Matthew Penner fd848985ee Add ServerTransferringException, use is_null 2020-12-17 10:35:54 -07:00
Matthew Penner e6c4a68e4a Update logic for tracking a server's transfer state 2020-12-17 10:35:54 -07:00
Dane Everitt d22456d9ca Block API access when 2FA is required on account; closes #2791 2020-12-06 13:56:14 -08:00
Matt Malec df64026449 Update AuthenticateIPAccess.php
Fix a 500 error when processing a request with an IP filter
2020-11-08 21:57:22 -05:00
Dane Everitt c00e5b36a5 Return all servers for a node as a paginated response
Avoids crashing the PHP process and avoids a bad runaway N+1 query issue that previously existed.
2020-10-31 11:14:28 -07:00
Dane Everitt f31a6d3967 Fix parameter bindings for client API routes; closes pterodactyl/panel#2359 2020-09-27 10:39:18 -07:00
Dane Everitt 906cfce81c Don't return a 403 when returning resources for a suspended server; closes #2279 2020-08-30 09:54:59 -07:00
Dane Everitt 540cc82e3d Don't resolve database hosts; closes #2237 2020-08-19 20:38:51 -07:00
Dane Everitt 61e9771333 Code cleanup for subuser API endpoints; closes #2247 2020-08-19 20:21:12 -07:00