# GHSA-7v3x-h7r2-34jv: Insufficient Session Expiration in Pterodactyl API


- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Fix available:** Yes
- **Published:** 21 Jan 2022

## What is GHSA-7v3x-h7r2-34jv?

GHSA-7v3x-h7r2-34jv is a vulnerability in pterodactyl/panel, published on 21 Jan 2022. 

### Official description

### Impact
A vulnerability exists in Pterodactyl Panel `<= 1.6.6` that could allow a malicious attacker that compromises an API key to generate an authenticated user session that is not revoked when the API key is deleted, thus allowing the malicious user to remain logged in as the user the key belonged to.

It is important to note that **a malicious user must first compromise an existing API key for a user to exploit this issue**. It cannot be exploited by chance, and requires a coordinated attack against an individual account using a known API key.

### Patches
This issue has been addressed in the `v1.7.0` release of Pterodactyl Panel.

### Workarounds
Those not wishing to upgrade may apply the change below:

```diff
diff --git a/app/Http/Middleware/Api/AuthenticateKey.php b/app/Http/Middleware/Api/AuthenticateKey.php
index eb25dac6..857bfab2 100644
--- a/app/Http/Middleware/Api/AuthenticateKey.php
+++ b/app/Http/Middleware/Api/AuthenticateKey.php
@@ -70,7 +70,7 @@ class AuthenticateKey
         } else {
             $model = $this->authenticateApiKey($request->bearerToken(), $keyType);

-            $this->auth->guard()->loginUsingId($model->user_id);
+            $this->auth->guard()->onceUsingId($model->user_id);
         }
```

### For more information
If you have any questions or comments about this advisory please reach out to `Tactical Fish#8008` on [Discord](https://discord.gg/pterodactyl) or email `dane@pterodactyl.io`.

## Which versions are affected by GHSA-7v3x-h7r2-34jv?

2 open source packages ship an affected version, including pterodactyl/panel.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `pterodactyl/panel` | Packagist | All versions | 1.7.0 |
| `pterodactyl/panel` | Packagist | All versions | 1.7.0 |

## How do I fix GHSA-7v3x-h7r2-34jv?

Upgrade pterodactyl/panel to 1.7.0 or later.

## Is GHSA-7v3x-h7r2-34jv being exploited?

There is no known exploitation of GHSA-7v3x-h7r2-34jv in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-7v3x-h7r2-34jv and fix it if it is affected.

What it is: GHSA-7v3x-h7r2-34jv is a vulnerability in pterodactyl/panel, published on 21 Jan 2022. 
Exploitation: There is no known exploitation of GHSA-7v3x-h7r2-34jv in the wild and no public exploit code.

Affected packages and fixed versions:
- pterodactyl/panel (Packagist): affected all versions; fixed in 1.7.0
- pterodactyl/panel (Packagist): affected all versions; fixed in 1.7.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-7v3x-h7r2-34jv/ (Markdown: https://insights.sbomify.com/GHSA-7v3x-h7r2-34jv/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-7v3x-h7r2-34jv

---
From sbomify Insights: https://insights.sbomify.com/GHSA-7v3x-h7r2-34jv/
Summaries are generated and may contain mistakes; the official description above is the record.
