CVE-2024-40624
Description
TorrentPier is an open source BitTorrent Public/Private tracker engine, written in php. In torrentpier/library/includes/functions.php, get_tracks() uses the unsafe native PHP serialization format to deserialize user-controlled cookies. One can use phpggc and the chain Guzzle/FW1 to write PHP code to an arbitrary file, and execute commands on the system. For instance, the cookie bb_t will be deserialized when browsing to viewforum.php. This issue has been addressed in commit ed37e6e52 which is expected to be included in release version 2.4.4. Users are advised to upgrade as soon as the new release is available. There are no known workarounds for this vulnerability.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
torrentpier/torrentpierPackagist | < 2.4.4 | 2.4.4 |
Patches
1ed37e6e522f3Merge commit from fork
2 files changed · +4 −6
library/includes/functions.php+2 −4 modified@@ -40,8 +40,6 @@ function delete_avatar($user_id, $avatar_ext_id) function get_tracks($type) { - static $pattern = '#^a:\d+:{[i:;\d]+}$#'; - switch ($type) { case 'topic': $c_name = COOKIE_TOPIC; @@ -55,7 +53,7 @@ function get_tracks($type) default: trigger_error(__FUNCTION__ . ": invalid type '$type'", E_USER_ERROR); } - $tracks = !empty($_COOKIE[$c_name]) ? @unserialize($_COOKIE[$c_name]) : false; + $tracks = !empty($_COOKIE[$c_name]) ? json_decode($_COOKIE[$c_name], true) : false; return $tracks ?: []; } @@ -113,7 +111,7 @@ function set_tracks($cookie_name, &$tracking_ary, $tracks = null, $val = TIMENOW } if (array_diff($tracking_ary, $prev_tracking_ary)) { - bb_setcookie($cookie_name, serialize($tracking_ary)); + bb_setcookie($cookie_name, json_encode($tracking_ary)); } }
src/Legacy/Common/User.php+2 −2 modified@@ -453,7 +453,7 @@ public function login(array $args, bool $mod_admin_login = false): array */ public function get_sessiondata() { - $sd_resv = !empty($_COOKIE[COOKIE_DATA]) ? unserialize($_COOKIE[COOKIE_DATA], ['allowed_classes' => false]) : []; + $sd_resv = !empty($_COOKIE[COOKIE_DATA]) ? json_decode($_COOKIE[COOKIE_DATA], true) : []; // autologin_id if (!empty($sd_resv['uk']) && verify_id($sd_resv['uk'], LOGIN_KEY_LENGTH)) { @@ -486,7 +486,7 @@ public function set_session_cookies($user_id) } } else { $c_sdata_resv = !empty($_COOKIE[COOKIE_DATA]) ? $_COOKIE[COOKIE_DATA] : null; - $c_sdata_curr = ($this->sessiondata) ? serialize($this->sessiondata) : ''; + $c_sdata_curr = ($this->sessiondata) ? json_encode($this->sessiondata) : ''; if ($c_sdata_curr !== $c_sdata_resv) { bb_setcookie(COOKIE_DATA, $c_sdata_curr, httponly: true);
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
5- github.com/advisories/GHSA-fg86-4c2r-7wxwghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2024-40624ghsaADVISORY
- github.com/torrentpier/torrentpier/blob/84f6c9f4a081d9ffff4c233098758280304bf50f/library/includes/functions.phpnvdWEB
- github.com/torrentpier/torrentpier/commit/ed37e6e522f345f2b46147c6f53c1ab6dec1db9envdWEB
- github.com/torrentpier/torrentpier/security/advisories/GHSA-fg86-4c2r-7wxwnvdWEB
News mentions
0No linked articles in our index yet.