Skip to content

Staking Audit Fixes#999

Merged
0x4007 merged 9 commits intoubiquity:developmentfrom
ryzhak:fix/audit-staking
Sep 2, 2025
Merged

Staking Audit Fixes#999
0x4007 merged 9 commits intoubiquity:developmentfrom
ryzhak:fix/audit-staking

Conversation

@ryzhak
Copy link
Contributor

@ryzhak ryzhak commented Aug 26, 2025

Resolves #998

In particular applies changes from #998 (comment).

Issue Status
[H-01] Missing "mass pool update" on creating/updating a pool affects users' rewards Fixed
[M-01] Staking and reward tokens overlapping with LibUbiquityPool's collateral skews calculations Fixed
[M-02] Possible reentrancy Fixed
[M-03] setStakingRewardToken causes DoS of stake/unstake methods Acknowledged
[M-04] Staked tokens are stuck in the contract Acknowledged
[M-05] Staking DoS if UBQ_MINTER_ROLE is revoked from the Diamond contract Acknowledged
[M-06] User can get 0 rewards on high stake amounts Fixed
[M-07] Dust reward tokens are stuck in the contract Acknowledged
[M-08] Some "weird" ERC20 tokens are not supported Acknowledged
[L-01] Unused imports Fixed
[L-02] whenNotPaused modifier not used Fixed
[L-03] Treasury griefing Fixed
[L-04] governanceTreasuryDivider can't be set to 0 Fixed
[L-05] DoS when treasuryAddress is 0 Acknowledged

The Check For Diamond Storage Changes workflow is failing because of #992. Anyway it's safe to update the storage layout of the LibStaking since it's not deployed yet.

@ubiquity-os
Copy link
Contributor

ubiquity-os bot commented Aug 26, 2025

Caution

No labels are set.

@ubiquity-os
Copy link
Contributor

ubiquity-os bot commented Aug 26, 2025

Caution

No labels are set.

@ubiquity-os
Copy link
Contributor

ubiquity-os bot commented Aug 26, 2025

Caution

No labels are set.

@ubiquity-os
Copy link
Contributor

ubiquity-os bot commented Aug 26, 2025

Caution

No labels are set.

@ubiquity-os
Copy link
Contributor

ubiquity-os bot commented Aug 26, 2025

Caution

No labels are set.

@ubiquity-os
Copy link
Contributor

ubiquity-os bot commented Aug 26, 2025

Caution

No labels are set.

@ubiquity-os
Copy link
Contributor

ubiquity-os bot commented Aug 26, 2025

Caution

No labels are set.

@ubiquity-os
Copy link
Contributor

ubiquity-os bot commented Aug 26, 2025

Caution

No labels are set.

@ubiquity-os
Copy link
Contributor

ubiquity-os bot commented Aug 26, 2025

Caution

No labels are set.

@ubiquity-os
Copy link
Contributor

ubiquity-os bot commented Aug 26, 2025

Caution

No labels are set.

@ubiquity-os
Copy link
Contributor

ubiquity-os bot commented Aug 26, 2025

Caution

No labels are set.

@ubiquity-os
Copy link
Contributor

ubiquity-os bot commented Aug 26, 2025

Caution

No labels are set.

@ubiquity-os
Copy link
Contributor

ubiquity-os bot commented Aug 26, 2025

Caution

No labels are set.

@ubiquity-os
Copy link
Contributor

ubiquity-os bot commented Aug 26, 2025

Caution

No labels are set.

@ubiquity-os
Copy link
Contributor

ubiquity-os bot commented Aug 27, 2025

Caution

No labels are set.

@ubiquity-os
Copy link
Contributor

ubiquity-os bot commented Aug 27, 2025

Caution

No labels are set.

@ubiquity-os
Copy link
Contributor

ubiquity-os bot commented Aug 27, 2025

Caution

No labels are set.

@ubiquity-os
Copy link
Contributor

ubiquity-os bot commented Aug 27, 2025

Caution

No labels are set.

@ryzhak ryzhak marked this pull request as ready for review August 27, 2025 08:00
@ryzhak ryzhak requested a review from rndquu as a code owner August 27, 2025 08:00
@ryzhak
Copy link
Contributor Author

ryzhak commented Aug 27, 2025

@0x4007 This PR is ready for review

@0x4007
Copy link
Member

0x4007 commented Aug 27, 2025

Tip

Hello, world!

@0x4007
Copy link
Member

0x4007 commented Aug 28, 2025

[!CAUTION]
No labels are set.

@gentlementlegen not sure why this sent so many consecutively this shouldn't happen (isBotEvent related?) also should be a warning not caution.

@ryzhak I'll review when I'm on my computer

Copy link
Member

@0x4007 0x4007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should get more eyes on this.

@0x4007 0x4007 requested a review from Copilot August 28, 2025 04:03
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR applies audit fixes for the staking functionality, addressing high and medium severity issues found during security review. The changes focus on improving reward calculations, preventing token overlap conflicts, and enhancing security through proper access controls.

  • Implements mass pool updates when creating/updating pools to ensure accurate reward calculations
  • Adds validation to prevent staking/reward tokens from overlapping with UbiquityPool collateral tokens
  • Adds reentrancy protection and pause functionality to critical staking operations

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
LibStaking.sol Core staking logic updates including mass pool updates, collateral overlap checks, and treasury divider validation
StakingFacet.sol Added security modifiers (whenNotPaused, nonReentrant) and simplified function signatures
IStaking.sol Updated interface to match simplified function signatures and added documentation
StakingFacet.t.sol Updated tests to match new function signatures and added new test cases for collateral overlap validation
StakingFacet.fuzz.t.sol Updated fuzz tests with new function signatures and improved parameter bounds
AaveAmo.t.sol Fixed test to use valid function call instead of empty call

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@0x4007
Copy link
Member

0x4007 commented Aug 28, 2025

We should get more eyes on this.

zgo said they can take a look soon

Copy link
Contributor

@zgorizzo69 zgorizzo69 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job fixing the issues from the audit
I would only add one small test and assess if feasible to make setStakingRewardToken revert if there are pending rewards

@gentlementlegen
Copy link
Member

[!CAUTION]
No labels are set.

@gentlementlegen not sure why this sent so many consecutively this shouldn't happen (isBotEvent related?) also should be a warning not caution.

@ryzhak I'll review when I'm on my computer

This emanates from command-start-stop that tried to assign the user to the linked issue, unsuccessfully due to the labels lacking there. It reacts to pull-request.opened but also to pull_request.edited, so it tried to assign the user again on each edit.

@0x4007
Copy link
Member

0x4007 commented Aug 30, 2025

@ryzhak I guess the failed CI doesn't matter?

@ryzhak
Copy link
Contributor Author

ryzhak commented Sep 1, 2025

@ryzhak I guess the failed CI doesn't matter?

Yes

The Check For Diamond Storage Changes workflow is failing because of #992. Anyway it's safe to update the storage layout of the LibStaking since it's not deployed yet.

@0x4007
Copy link
Member

0x4007 commented Sep 2, 2025

@rndquu please resolve zgorizzo69's review comments- whether to implement or ignore is your decision

@ryzhak
Copy link
Contributor Author

ryzhak commented Sep 2, 2025

@rndquu please resolve zgorizzo69's review comments- whether to implement or ignore is your decision

All resolved, everything is kept "as is"

@0x4007 0x4007 merged commit 7eb880f into ubiquity:development Sep 2, 2025
16 of 18 checks passed
@ryzhak ryzhak deleted the fix/audit-staking branch September 2, 2025 17:01
@ryzhak ryzhak mentioned this pull request Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Staking Security Audit

5 participants