ajax.php ACE security patch

This commit is contained in:
Rey5
2023-05-07 04:18:19 +08:00
parent a75abb91dc
commit e546013dac

View File

@@ -6,6 +6,29 @@ loggedinorreturn();
$action = $_POST['action'] ?? 'noAction';
$params = $_POST['params'] ?? [];
const ALLOWED_ACTION = [
'toggleUserMedalStatus',
'attendanceRetroactive',
'getPtGen',
'addClaim',
'removeClaim',
'removeUserLeechWarn',
'getOffer',
'approvalModal',
'approval',
'addSeedBoxRecord',
'removeSeedBoxRecord',
'removeHitAndRun',
'consumeBenefit',
'clearShoutBox',
'buyMedal',
'giftMedal',
'saveUserMedal',
];
if(!in_array($action,ALLOWED_ACTION)){
do_log('hack attempt '.print_r($CURUSER,true),'error');
$action = 'noAction';
}
function noAction()
{
throw new \RuntimeException("no Action");
@@ -13,6 +36,7 @@ function noAction()
try {
if(!isset($CURUSER))throw new \RuntimeException('Permission Denied');
$result = call_user_func($action, $params);
exit(json_encode(success($result)));
} catch (\Throwable $exception) {