fix(allocation): resolve unauthorized state mutation in compute_alloc…#280
Open
0xnsikak wants to merge 2 commits intoSuncrest-Labs:mainfrom
Open
fix(allocation): resolve unauthorized state mutation in compute_alloc…#2800xnsikak wants to merge 2 commits intoSuncrest-Labs:mainfrom
0xnsikak wants to merge 2 commits intoSuncrest-Labs:mainfrom
Conversation
…ation - Refactored compute_allocation to be a pure view function - Implemented set_allocation with require_auth() and RBAC checks - Added AccessControlClient for operator role verification - Fixed event emission syntax for correct topic indexing - Added security tests to verify unauthorized access is blocked Closes Suncrest-Labs#237
|
@0xnsikak Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Motivation
The compute_allocation function was performing a "write" to contract storage without any authorization checks. This allowed any random account on the Stellar network to change the vault's investment strategy, leading to potential loss of funds or strategy manipulation.
The Changes
Split the Logic: Created a "Read" function (compute_allocation) that just does the math and a "Write" function (set_allocation) that saves the data.
Added Security: The new set_allocation function now requires a signature (require_auth) and checks if the caller has the OPERATOR role.
Fixed Events: Corrected a syntax error in the event logging to ensure it compiles and indexes correctly.
The Result
Only authorized operators can now change the capital allocation. Anyone else trying to do so will trigger a contract panic, securing user funds.
Fixes #237