You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
weaponid isn't validated in basic synchronization types #797
Describe the bug
A simple yet still unnoticed problem is that weaponid isn't validated as valid weapon id inside onfoot, driver and passenger synchronization sent by any player. This is pretty critical as GetPlayerWeapon is usually used as an array index.
To Reproduce
Spoof any type of sync (onfoot, driver or passenger) with invalid weaponid which is not in range of [0-18, 22-46] and it will be passed to GetPlayerWeapon which you can print right in OnPlayerUpdate to easily see when it reaches the server.
Important note is to send non-valid weaponid, but it should fit the datatype by its value (weapons can be 0-63 due to size of data in the bitstream argument, so send something more than 46 and less than 64).
Expected behavior
Is this case, SA-MP server just reset weaponid to 0 and the whole packet processes as usual.
Screenshots and/or logs
Could send my crashdetect log when I firstly discovered this issue ha-ha
Is this how some cheaters can use Minigun amongst other weapons in my server without it being detected (I'm using GetPlayerWeapon in OnPlayerUpdate to detect them)? I also wonder what GetPlayerWeaponData reports...
No it's not about weapon hack working, it is a flaw related to the lack of validation for the sane values sent by clients updating their holding weapon. The worst result it can bring is tons of out-of-bounds runtime errors inside any functions where you used GetPlayerWeapon as an array index. Which is still a critical thing, isn't it?
I also wonder what GetPlayerWeaponData reports...
GetPlayerWeaponData represent weapons update sync i.e. all weapons and ammo that the player has in every slot (while GetPlayerWeapon is just a "marker" which weapon from all those is in hands right now).
Activity
BeckzyBoi commentedon Dec 3, 2023
Is this how some cheaters can use Minigun amongst other weapons in my server without it being detected (I'm using GetPlayerWeapon in OnPlayerUpdate to detect them)? I also wonder what GetPlayerWeaponData reports...
NexiusTailer commentedon Dec 3, 2023
No it's not about weapon hack working, it is a flaw related to the lack of validation for the sane values sent by clients updating their holding weapon. The worst result it can bring is tons of out-of-bounds runtime errors inside any functions where you used GetPlayerWeapon as an array index. Which is still a critical thing, isn't it?
GetPlayerWeaponData represent weapons update sync i.e. all weapons and ammo that the player has in every slot (while GetPlayerWeapon is just a "marker" which weapon from all those is in hands right now).