- All findings
- 2
- Critical
- 0
- High
- 0
- Medium
- 1
- Low
- 0
- Informational
- 1
Date of engagement: 7th May 2025 - 12th May 2025
About Us
Guvenkaya is a security research firm specializing in Rust security, Web3 security of Rust-based protocols, and Web2 security. With our expertise, we provide both security auditing services and custom security solutions
About The Sweat
Foundation The Sweat Foundation is an organization behind Sweat Economy, an innovative project at the intersection of fitness and crypto. It motivates users to stay active by converting their steps into SWEAT Token. This approach promotes health and fitness and works as an entry point to crypto for many users.
Audit Results
Guvenkaya conducted a security assessment of the Sweat migration and refactor changes inside the Sweat Jar smart contract. During this engagement, 2 findings were reported. One is Medium severity and another is Ingormational severity. The Sweat Foundation team has fixed the medium issue and acknowledged the informational one.
Project Scope
Sweat Jar Contract
Out of Scope
The audit will include, but is not limited to, reviewing the code for security vulnerabilities, coding practices, and architecture. The audit does not include a review of the dependencies.
Scope only includes:
New Migration Functionality: Migration code in new contract and old contract Restaking changes: Addition of ticketing system to restake and restake_all Withdrawal Changes: withdraw_all accepting optional product arguments Codebase refactor: Moving non-NEAR related code to the models folder. High level review
Timeline
- Start of the audit
7th May 2025
- Draft report
12th May 2025
- Final report
12th May 2025
Methodology
- RESEARCH INTO PROJECT ARCHITECTURE
- PREPARING ATTACK VECTORS
- SETTING UP AN ENVIRONMENT
- MANUAL CODE REVIEW OF THE CODE
- ASSESSMENT OF RUST SECURITY ISSUES
- ASSESSMENT OF NEAR SECURITY ISSUES
- ASSESSMENT OF ARITHMETIC ISSUES
- BUSINESS LOGIC VULNERABILITY ASSESSMENT
- ONCHAIN TESTING USING NEAR WORKSPACES
- BEST PRACTICES AND CODE QUALITY
- CHECKING FOR CODE REFACTORING/SIMPLIFICATION POSSIBILITIES
- ARCHITECTURE IMPROVEMENT SUGGESTIONS
- PREPARING POCS AND/OR TESTS FOR EACH CRITICAL/HIGH/MEDIUM ISSUES
Severity Breakdown
Findings Summary
| Finding | Impact | Likelihood | Severity | Remediation complexity | Remediation status |
|---|---|---|---|---|---|
| GUV-1: Possible Double Claim Through Race Condition | Severe | Rare | Medium | Simple | Fixed |
| GUV-2: Cross Function Ticket Reuse | Negligible | Rare | Informational | Simple | Fixed |
Findings Details
GUV-1: Possible Double Claim Through Race Condition
MediumWe observed that it is not verified whether a user is in migrating state through assert_account_is_not_migrating in any of the state changing functions like claim/withdraw/restake in old contract. Since the account is deleted only inside of the after_account_transferred, there is a time for a malicious actor to call claim to claim accumulated amount and then after the account is deleted, call claim again on a new migrated smart contract to claim twice.
migration:contract/src/migration/v2.rs
pub fn after_account_transferred(&mut self, account_id: AccountId) ->
PromiseOrValue<(AccountId, bool)> {
let is_success = is_promise_success(); if is_success {
self.clear_account(&account_id);
emit(EventKind::JarsMerge(account_id.clone()));
}
...PROPOSED SOLUTION
Consider asserting the assert_account_is_not_migrating in all state mutating functions.
REMEDIATION - FIXED
The Sweat Foundation team has fixed the issue by adding the assert_account_is_not_migrating in all state mutating functions in this commit: 89755f5cfbac88764131560ec1d0085464f58cc9
GUV-2: Cross Function Ticket Reuse
InformationalWe observed that it is possible to generate a ticket with a signature for jar creation but supply it to the restake and restake_all functions. Depending on logic of both functions, it can introduce security issues in the future and in general it increases the attack surface.
migration:contract/src/feature/restake/api/api.rs
fn restake(
&mut self,
from: ProductId,
ticket: DepositTicket,
signature: Option<Base64VecU8>,
amount: Option<U128>,
) -> PromiseOrValue<()> {migration:contract/src/migration/v2.rs
pub(crate) fn create_jar( &mut self, account_id: AccountId, ticket: JarTicket, amount: U128, signature: Option<Base64VecU8>, ) -> JarView
PROPOSED SOLUTION
Consider disallowing cross-function ticket reuse.
REMEDIATION - FIXED
The Sweat Foundation team has fixed the issue by introducing purpose in deposit message in this commit and update on the backend: fd72e8cb72af66eb254d90c173387bf8236e61f3
Source: published GitHub report · 12 pages. The original PDF includes the source formatting, figures, and linked references.
