fix(security): fix pervasive IDOR - force JWT user identity in 9 endpoints, fix host injection, exception leaks, wallet auth
This commit is contained in:
@@ -7,8 +7,17 @@ header('Content-Type: application/json');
|
||||
|
||||
try {
|
||||
$inviteId = filterRequest("invite_id");
|
||||
$driverId = filterRequest("driver_id");
|
||||
$passengerId = filterRequest("passenger_id");
|
||||
// Force user ID from JWT based on role
|
||||
if ($role === 'driver') {
|
||||
$driverId = $user_id;
|
||||
$passengerId = null;
|
||||
} elseif ($role === 'passenger') {
|
||||
$passengerId = $user_id;
|
||||
$driverId = null;
|
||||
} else {
|
||||
echo json_encode(["status" => "failure", "message" => "Invalid user role."]);
|
||||
exit;
|
||||
}
|
||||
$countryCode = filterRequest("country_code"); // Expected: Jordan, Syria, Egypt
|
||||
|
||||
if (empty($inviteId)) {
|
||||
@@ -88,6 +97,7 @@ try {
|
||||
}
|
||||
|
||||
function addWalletBalance($url, $userId, $userType, $amount) {
|
||||
$s2sKey = getenv('S2S_SHARED_KEY');
|
||||
$data = [
|
||||
"user_id" => $userId,
|
||||
"user_type" => $userType,
|
||||
@@ -100,6 +110,11 @@ function addWalletBalance($url, $userId, $userType, $amount) {
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
||||
if ($s2sKey) {
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, ["X-Auth-Token: $s2sKey"]);
|
||||
}
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $response;
|
||||
|
||||
Reference in New Issue
Block a user