Submitted by xiaoming90
If the user deposits too little GMX compared to other users (or total supply of pxGMX), the user will not be able to receive rewards after calling the PirexRewards.claim function. Subsequently, their accrued rewards will be cleared out (set to zero), and they will lose their rewards.
The amount of reward tokens that are claimable by a user is computed in Line 403 of the PirexRewards.claim function.
If the balance of pxGMX of a user is too small compared to other users (or total supply of pxGMX), the code below will always return zero due to rounding issues within solidity.
Since the users accrued rewards is cleared at Line 391 within the PirexRewards.claim function (p.userStates[user].rewards = 0;), the users accrued rewards will be lost.
https://github.com/code-423n4/2022-11-redactedcartel/blob/03b71a8d395c02324cb9fdaf92401357da5b19d1/src/PirexRewards.sol#L373
The graph below represents the amount of GMX tokens Alice and Bob staked in PirexGmx for each second during the period. Note that the graph is not drawn proportionally.
Green = Number of GMX tokens staked by Alice
Blue = Number of GMX tokens staked by Bob

Based on the above graph:
Assume that the emission rate is 0.1 esGMX per 1 GMX staked per second.
In this case, the state variable will be as follows at the end of T83, assuming both the global and all user states have been updated and rewards have been harvested.
Following is the description of rewardState for reference:
At the end of T85, Alice should be entitled to 1.2 esGMX tokens (0.2/sec * 6).
Following is the formula used in the PirexRewards contract to compute the number of reward tokens a user is entitled to.
If Alice claims the rewards at the end of T85, she will get zero esGMX tokens instead of 1.2 esGMX tokens.
Since Alices accrued rewards are cleared at Line 391 within the PirexRewards.claim function (p.userStates[user].rewards = 0;), Alices accrued rewards will be lost. Alice will have to start accruing the rewards from zero after calling the PirexRewards.claim function.
Another side effect is that since the 1.2 esGMX tokens that belong to Alice are still in the contract, they will be claimed by other users.
Users who deposit too little GMX compared to other users (or total supply of pxGMX), the user will not be able to receive rewards after calling the PirexRewards.claim function. Also, their accrued rewards will be cleared out (set to zero). Loss of reward tokens for the users.
Additionally, the PirexRewards.claim function is permissionless, and anyone can trigger the claim on behalf of any user. A malicious user could call the PirexRewards.claim function on behalf of a victim at the right time when the victims accrued reward is small enough to cause a rounding error or precision loss, thus causing the victim accrued reward to be cleared out (set to zero).
Following are some of the possible remediation actions:
Avoid calculating the rewards that the users are entitled based on the ratio of userRewards and globalRewards.
Instead, consider implementing the RewardPerToken for users and global, as seen in many of the well-established reward contracts below, which are not vulnerable to this issue:
If the amount is zero, revert the transaction. Alternatively, if the amount is zero, do not clear out the users accrued reward state variable since the user did not receive anything yet.
kphed (Redacted Cartel) confirmed 
