Solar Grid Smart Contract Exposed to Front-Running Attack on Initialize Function
A critical access control vulnerability has been identified in the Solar Grid smart contract deployed on Soroban, raising serious concerns about the security of administrative functions. The `initialize` function in `contracts/solar_grid/src/lib.rs` contains no authentication mechanism, allowing any external account to invoke it before the legitimate deployer completes setup. This classic front-running exploit enables an attacker to seize admin privileges by calling the function first and designating their own address as the contract administrator.
The vulnerability stems from the absence of access control on the initialization entry point. In Soroban environments, the `initialize` function serves as the critical setup mechanism for contract state, and when left unprotected, becomes a prime attack surface. The GitHub issue documents a proposed remediation requiring the designated admin to cryptographically authorize the initialization transaction via `require_auth()`. This ensures only the intended administrator can set core parameters and role assignments. The fix also mandates a check preventing re-initialization: `if env.storage().instance().has(&ADMIN) { panic("already initialized"); }`.
The Solar Grid project now faces pressure to resolve this flaw before any production deployment. The issue establishes a clear Definition of Done: the initialize function must enforce admin authentication, unit tests must verify unauthorized initialization attempts are rejected, and the deployment pipeline must incorporate these safeguards. Smart contracts managing financial assets or governance functions face heightened scrutiny when such foundational vulnerabilities surface, as compromised admin control can lead to fund drainage, parameter manipulation, or complete protocol takeover.