Skip to content

weaponid isn't validated in basic synchronization types #797

Closed

Description

@NexiusTailer

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

Release version
v1.1.0.2612

Activity

  1. added
    bug
    on Dec 2, 2023
  2. BeckzyBoi commented on Dec 3, 2023

    @BeckzyBoi

    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...

  3. NexiusTailer commented on Dec 3, 2023

    @NexiusTailer
    ContributorAuthor

    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).

  4. added
    security
    on Dec 3, 2023
  5. self-assigned this
    on Dec 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugsecurity

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions