Commit Graph
1300 Commits
Author SHA1 Message Date
robert dennis 8d4f47fa6a extensions facade 2026-10-08 16:53:56 -04:00
Sky Mulley ff9527a2e9 fix tests to pass 2026-10-08 09:54:19 +01:00
Sky Mulley 173f2da8c3 fix issue where chmod would be refused by wings due to it not being string typed 2026-10-08 09:43:07 +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
Sky Mulley dd81db5d4d implement ability to set icon for extensions 2026-10-07 10:46:54 +01: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
Joshua Piper 66ce0f2a16 Fix 2 SFTP Lockout Ratelimit Bugs (#7257)
Fixes two SFTP lockout bugs:

- `ad374661f` moved the server lookup after the password check, so fake
server identifiers bypassed the rate limit.
- `24f340c9a` keyed the lockout on server + Wings IP, so anyone could
lock every user out of a server.

Unknown servers are now rejected before any credential check, and the
lockout is keyed on the normalised username + resolved server UUID.
2026-10-06 22:46:46 -04:00
robert dennis 368b4bf6a6 regex fixes 2026-10-06 20:11:59 -04:00
robert dennis 7db75f2e4a install handling cleanup 2026-10-06 20:11:59 -04:00
robert dennis 8ebfdf8119 settings cleanup 2026-10-06 20:11:59 -04:00
robert dennis 16b0198593 extension route middleware tweaks 2026-10-06 20:11:59 -04:00
DarkZmaj fcec806acb Apply Pint formatting to two extension files (#7250)
## Problem

`vendor/bin/pint --test` fails on the current 2.0 development branch,
which fails the Tests workflow for every pull request.

## Reproduction

Run `vendor/bin/pint --test --parallel --cache-file=.pint.cache app
bootstrap/app.php bootstrap/tests.php config database routes tests` on a
clean checkout. It reports two files:
`app/Http/Requests/Api/Admin/Extensions/InstallExtensionRequest.php` and
`app/Services/Extensions/ExtensionPackageLocator.php`.

## Root cause

Two recent changes were merged without running Pint. One docblock uses
`@inheritdoc` where the project style wants `{@inheritdoc}`, and one
blank line contains trailing whitespace.

## Fix

Run Pint on exactly those two files. The change is one docblock line and
one whitespace only line.

## Testing

`vendor/bin/pint --test` on the same paths passes afterwards. No
behaviour changes.

## Compatibility considerations

None. Formatting only.
2026-10-06 15:17:00 +01:00
DarkZmaj be0509dfb7 Apply the Rector changes reported on the current branch (#7251)
## Problem

`vendor/bin/rector --dry-run` reports three files that would change,
which fails the Static Analysis job of the Tests workflow.

## Reproduction

Run `vendor/bin/rector --dry-run --no-progress-bar` on a clean checkout
with PHP 8.4, as the workflow does. Rector lists `PasswordBroker.php`,
`PasswordBrokerManager.php` and `FileController.php`. With PHP 8.3 the
command reports nothing, because some rules depend on the running PHP
version.

## Root cause

Recent changes in these three files were merged without running Rector,
so they differ from the style the project enforces.

## Fix

Apply exactly the changes Rector prints:

* `PasswordBroker`: compare the callback with `instanceof Closure`
instead of `!== null`.
* `PasswordBrokerManager`: use `throw_unless` and `throw_if` with the
exception class string.
* `FileController`: name the caught exception
`$daemonConnectionException` after its type.

## Testing

* `vendor/bin/rector --dry-run` no longer reports changes locally, and
PHPStan and Pint still pass.
* The authentication integration tests and the server file integration
tests pass (86 tests).
* I could not run Rector under PHP 8.4 locally, so the Static Analysis
job of this pull request is the confirmation.

## Compatibility considerations

Behaviour is unchanged. The `instanceof Closure` check is stricter than
a null check only for callbacks that are not closures, and the parameter
is already typed as a nullable closure.
2026-10-06 15:16:49 +01:00
Sky Mulley 240aaf62ea properly handle file permissions regarding to creation and updating 2026-10-06 13:51:34 +01:00
Sky Mulley 76b49b1be1 improve reset password security 2026-10-06 13:13:39 +01:00
Sky Mulley c848794e13 hide recaptcha inputted secret key from settings 2026-10-06 12:57:00 +01:00
Sky Mulley ad374661f2 prevent ability to scrape usernames from panel by preventing timing differences between correct and wrong usernames 2026-10-06 12:53:25 +01:00
Anthony e52fdfd416 Fix extension translations staying cached after an extension update
Fixes #7245
2026-10-06 00:18:41 -05:00
Sky Mulley 90fc8c7005 fix issue where saving a subuser with more permissions than you would strip their permissions 2026-10-06 01:17:42 +01:00
Sky Mulley 6533e91b62 don't allow extensions to be installed from admin api 2026-10-06 01:06:15 +01:00
Sky Mulley 5fdc4ec5f6 validate enabled bool on extension install through admin 2026-10-06 00:24:39 +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
Noah Ross a94b8bdb4e Fix API Key Limit Race Condition Bypass (#5620)
The API key creation endpoint checks that a user has fewer than 25 keys
before creating a new one. The problem is that the count was read from
an eager-loaded collection (`$user->apiKeys->count()`) with no lock
held, so concurrent requests could both pass the check and each create a
key, pushing the user past the 25-key cap.

The fix wraps the count check and key creation in a single database
transaction with `lockForUpdate()` on the query. Only one request at a
time can evaluate and modify the count, closing the race window.

### Proof of Concept

Run this in the browser console while authenticated with a user that has
24 API keys:

```js
(async () => {
    const makeKey = (desc) => fetch('/api/client/account/api-keys', {
      method: 'POST',
      headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json',
        'X-Requested-With': 'XMLHttpRequest',
        'X-XSRF-TOKEN':
  decodeURIComponent(document.cookie.match(/XSRF-TOKEN=([^;]+)/)[1]),
      },
      body: JSON.stringify({ description: desc, allowed_ips: [] }),
    });

    const [r1, r2] = await Promise.all([makeKey('0024'), makeKey('0025')]);
    console.log('0024:', r1.status, (await r1.text()).slice(0, 200));
    console.log('0025:', r2.status, (await r2.text()).slice(0, 200));
})();
```

On the old code, both requests can return 200 (you may need to run this
a few times to hit the race window). After the fix, the second request
correctly returns a 400 error.
2026-05-23 11:16:18 -07:00
Dane Everitt 7ffcd63631 Attach a scope(s) to JWTs created by the panel (#5636)
Necessary for proper token identification on Wings.
2026-05-23 11:15:36 -07:00
Dane Everitt ec7231bd4a Lock resources more explicitly when creating databases or backups (#5613)
Addresses an issue where the concept of a lock was there, but no actual
lock was acquired.
2026-04-01 18:46:01 -07:00
Dane Everitt 56fe10fdd6 Throttle email address changes on accounts to limit enumeration (#5612)
This change applies a rate limit to account email changes to prevent
enumeration on the system. The throttle is applied at the account level.
Administrators can still update an account's email address manually to
bypass this restriction if/when necessary.
2026-04-01 17:54:30 -07:00
Carlton 33695c642d Fix transfer status permission checks (#5573) 2026-03-26 16:53:41 -07:00
Daniel Barton 51bbd10a01 Fix: Compare to correct variable in startup variable activity log (#5605)
- Fixes issue where the panel would create activity logs even when the
value didn't change
- Log an empty string instead of displaying "null" when the variable is
empty

Closes #5604
2026-03-26 16:24:02 -07: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 0e74f3aade Improve SFTP session revocation to cover password changes and account deletion (#5568)
This expands upon previous work done to better disconnect users from
SFTP when different events occur within Pterodactyl. This new logic also
accounts for password changes and their account being deleted entirely
from the system.

These events now trigger background jobs that will reach out to every
node they are associated with to ensure they're disconnected if
currently connected.
2026-02-14 10:51:26 -08:00
Dane Everitt 7c9c56bf51 Scope the remote node token to limit the servers it can manage for backups/transfers (#5476)
Improves the security posture of things more by limiting the servers
that a node can even communicate about with the Panel.
2026-02-11 16:04:09 -08:00
Mackenzie MolloyandDaneEveritt 7576d0d08e Added support for viewing and deleting of any Application API Keys (#5176)
This PR closes Issue #5175.

For context, I am aware that Application API Keys are deprecated in
favour of Client API Keys however they are still operational within
Pterodactyl and thus, not fully removed.

Currently in Pterodactyl, as an Admin, you can only view your
Application API Keys on the Admin Panel. In this PR, I made it so all
Application Keys are visible and deletable. The key strings are
obfuscated if the key does not belong to the user viewing.


![image](https://github.com/user-attachments/assets/9edb2533-d99c-4ec3-80cc-25630fd48594)

The reason for adding this is primarily so other admin users can be
aware of and delete another admin user's Application API keys from the
UI. This functionality is useful in the event of a malicious user
compromising an admin account, creating some API Keys to continue their
attacks and the owner of the compromised admin account being unaware of
Application API Keys. In this instance, even after a password reset, the
attack could continue via the Application API without the admin
realising it.

I've tested the creation and deleting of keys along with using keys via
the Application API to ensure no breakages have occurred.

---------

Co-authored-by: DaneEveritt <dane@daneeveritt.com>
2026-02-11 16:03:35 -08:00
Всеволод МельникandDaneEveritt 09caa0d499 Merge commit from fork
* Add throttling to resource creation endpoints

* Fix middleware registration for the throttlers

* Lock the server's resource models when adding new ones

* Throttle subusers even more

---------

Co-authored-by: DaneEveritt <dane@daneeveritt.com>
2026-01-05 16:05:38 -08:00
Mackenzie Molloy 238d371352 Feature: Sort Users on Admin/Users by Administrators first (#5098) 2026-01-04 11:12:55 -08:00
Dane Everitt 032bf076d9 Ensure that TOTP tokens cannot be reused (#5481) 2025-12-30 12:27:11 -08:00
Dane Everitt 2bd9d8badd Disconnect SFTP/Websocket when a user is removed as a subuser (#5472) 2025-12-26 17:51:25 -08:00
Dane Everitt 895adb6e6f Ensure that a node description can be set, add additional test coverage (#5457) 2025-12-24 16:43:00 -08:00
Dane Everitt 0917e60a3b Return correct error message when deleting self, add test coverage (#5456) 2025-12-24 16:13:31 -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 01fd763fe9 fix: add additional input validation
Signed-off-by: Matthew Penner <me@matthewp.io>
2025-06-18 12:21:26 -06: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
Dawid Jaworski 8ae76c3889 feat: add egg features editor in Admin UI (#5130) 2024-06-29 12:59:05 -06:00
Daniel Barton 371c7a671d api: fix docker_image validation for local images (#5103) 2024-05-21 13:29:31 -06:00
Matthew Penner f8dfef04c4 api(remote): fix oops in BackupStatusController, yet again 2024-05-08 18:08:18 -06:00
Matthew Penner 7bfc265a7e api(remote): fix use of missing node_id field
Fixes #5088
2024-05-04 16:06:13 -06:00
Matthew Penner b1fa3927c1 api(remote): fix oops in BackupStatusController 2024-04-11 10:42:18 -06:00
Matthew Penner f671046947 admin: tweaks to validation and rendering 2024-04-10 18:13:25 -06:00
Matthew Penner 319ca683f8 api(remote): ensure requesting node is checked 2024-04-10 17:38:09 -06:00
Matthew Penner 1172d71d31 app: improve docker_image validation 2024-04-10 17:22:29 -06:00