Skip to content

Commit 01a0614

Browse files
author
Daniel Neto
committed
fix: Implement rate limiting for various API endpoints to prevent abuse
GHSA-8prq-2jr2-cm92
1 parent 83390ab commit 01a0614

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

plugin/API/API.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,7 @@ public function get_api_user_can_watch_video($parameters)
11101110
)]
11111111
public function get_api_video_password_is_correct($parameters)
11121112
{
1113+
$this->checkRateLimit('video_password_check', 10, 300); // 10 attempts per 5 minutes
11131114

11141115
$obj = new stdClass();
11151116
$obj->videos_id = intval($parameters['videos_id']);
@@ -3218,6 +3219,7 @@ public function get_api_users_list($parameters)
32183219

32193220
public function get_api_videosViewsCount($parameters)
32203221
{
3222+
$this->checkRateLimit('videos_views_count', 20, 60); // 20 per minute — full table scan, no cache
32213223
global $global;
32223224
require_once $global['systemRootPath'] . 'objects/video.php';
32233225
$obj = $this->startResponseObject($parameters);
@@ -4057,6 +4059,7 @@ public function set_api_removelike($parameters)
40574059

40584060
public function get_api_signIn($parameters)
40594061
{
4062+
$this->checkRateLimit('sign_in', 10, 300); // 10 attempts per 5 minutes
40604063
global $global;
40614064
$this->getToPost();
40624065
// Merge $parameters into $_POST so login.json.php can read them
@@ -4331,6 +4334,7 @@ private function like($parameters, $like)
43314334

43324335
public function get_api_vmap($parameters)
43334336
{
4337+
$this->checkRateLimit('vmap', 120, 60); // 120 per minute — prevents outbound HTTP flood via AdsForJesus
43344338
global $global;
43354339
$this->getToPost();
43364340
header('Content-type: application/xml');
@@ -5420,6 +5424,7 @@ public function get_api_app($parameters)
54205424

54215425
public function set_api_login_code($parameters)
54225426
{
5427+
$this->checkRateLimit('login_code_generate', 5, 300); // 5 generations per 5 minutes
54235428
$obj = getActivationCode();
54245429
return new ApiObject('', empty($obj['bytes']), $obj);
54255430
}
@@ -5465,6 +5470,7 @@ public function set_api_login_code($parameters)
54655470

54665471
public function get_api_login_code($parameters)
54675472
{
5473+
$this->checkRateLimit('login_code_verify', 5, 300); // 5 attempts per 5 minutes
54685474
global $global, $config;
54695475
$msg = '';
54705476
$obj = false;

0 commit comments

Comments
 (0)