Skip to content

fix(allocation): resolve unauthorized state mutation in compute_alloc…#280

Open
0xnsikak wants to merge 2 commits intoSuncrest-Labs:mainfrom
0xnsikak:fix/#237
Open

fix(allocation): resolve unauthorized state mutation in compute_alloc…#280
0xnsikak wants to merge 2 commits intoSuncrest-Labs:mainfrom
0xnsikak:fix/#237

Conversation

@0xnsikak
Copy link
Copy Markdown

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

…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 0xnsikak requested a review from 0xDeon as a code owner April 23, 2026 15:35
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 23, 2026

@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! 🚀

Learn more about application limits

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.

[Smart Contract] AllocationStrategy.compute_allocation writes persistent state with no access control — any network participant can force a rebalance

2 participants