BattleBet Info

Harness the power of Solana's blockchain to control your wagers, odds, and outcomes. Our platform enables a transparent, fair, and secure environment for peer-to-peer betting. Every wager is verified, and every outcome is immutable, ensuring a future of trust in betting

BattleBet Logo

TrustNet Score

The TrustNet Score evaluates crypto projects based on audit results, security, KYC verification, and social media presence. This score offers a quick, transparent view of a project's credibility, helping users make informed decisions in the Web3 space.

34.16
Poor Excellent

Real-Time Threat Detection

Real-time threat detection, powered by Cyvers.io, is currently not activated for this project.

This advanced feature provides continuous monitoring and instant alerts to safeguard your assets from potential security threats. Real-time detection enhances your project's security by proactively identifying and mitigating risks. For more information, click here.

Security Assessments

"Static Analysis Dynamic Analysis Symbolic Execution SWC Check Manual Review"
Contract address
N/A
Network N/A
License N/A
Compiler N/A
Type N/A
Language Rust / Solana
Onboard date 2024/12/05
Revision date 2024/12/24

Summary and Final Words

No crucial issues found

The contract does not contain issues of high or medium criticality. This means that no known vulnerabilities were found in the source code.

Contract owner cannot mint

It is not possible to mint new tokens.

Contract owner cannot blacklist addresses.

It is not possible to lock user funds by blacklisting addresses.

Contract owner cannot set high fees

The fees, if applicable, can be a maximum of 25% or lower. The contract can therefore not be locked. Please take a look in the comment section for more details.

Contract cannot be locked

Owner cannot lock any user funds.

Token cannot be burned

There is no burning within the contract without any allowances

Ownership is not renounced

The owner retains significant control, which could potentially be used to modify key contract parameters.

Scope of Work

This audit encompasses the evaluation of the files listed below, each verified with a SHA-1 Hash. The team referenced above has provided the necessary files for assessment.

The auditing process consists of the following systematic steps:

  1. Specification Review: Analyze the provided specifications, source code, and instructions to fully understand the smart contract's size, scope, and functionality.
  2. Manual Code Examination: Conduct a thorough line-by-line review of the source code to identify potential vulnerabilities and areas for improvement.
  3. Specification Alignment: Ensure that the code accurately implements the provided specifications and intended functionalities.
  4. Test Coverage Assessment: Evaluate the extent and effectiveness of test cases in covering the codebase, identifying any gaps in testing.
  5. Symbolic Execution: Analyze the smart contract to determine how various inputs affect execution paths, identifying potential edge cases and vulnerabilities.
  6. Best Practices Evaluation: Assess the smart contracts against established industry and academic best practices to enhance efficiency, maintainability, and security.
  7. Actionable Recommendations: Provide detailed, specific, and actionable steps to secure and optimize the smart contracts.

A file with a different Hash has been intentionally or otherwise modified after the security review. A different Hash may indicate a changed condition or potential vulnerability that was not within the scope of this review.

Final Words

The following provides a concise summary of the audit report, accompanied by insightful comments from the auditor. This overview captures the key findings and observations, offering valuable context and clarity.


Audit Findings

The audit identified several issues categorized as follows:

  • High: Inconsistent error handling and potential state corruption due to improper order of state updates and external calls.
  • Medium: Missing validations for time-based conditions and incomplete handling of possible outcomes in key functions.
  • Low: Missing input validations, such as ensuring positive values for critical parameters, and optimization opportunities like avoiding redundant calculations.
  • Informational: Lack of event emissions for better observability and missing uniqueness checks during initialization.

Note: This audit is limited to the provided Rust contract files. We recommend further testing and independent review before deployment.

Files and details

Functions
public

/

State variables
public

/

Total lines
of code

/

Capabilities
Hover on items

/

Functions
public

/

State variables
public

/

Total lines
of code

/

Capabilities
Hover on items

/

Findings and Audit result

high Issues | 2 findings

Resolved

#1 high Issue
Inconsistent Error Handling in claim Function
polyzone.rs
L190
Description

If a bet is neither Cancelled nor Completed, it defaults to an error, potentially locking user funds permanently.

Resolved

#2 high Issue
Potential state corruption or double payouts.
polyzone.rs
L97-126
Description

SOL transfers (invoke) followed by mutable state updates could enable reentrancy attacks if combined with malicious programs.

medium Issues | 2 findings

Pending

#1 medium Issue
Missing Validation for end_at Timestamp in create_single_bet
battlezone.rs
L17
Description

The create_single_bet function does not check whether the end_at timestamp is in the future. This oversight allows bets to be created with expired timelines, leading to potential logical issues and misuse. The end_at field is intended to represent the expiration time of a bet, and failing to validate it introduces risks such as inconsistent behavior and disputes over bet validity.

Pending

#2 medium Issue
Missing outcome in set_winner
polyzone.rs
L155-174
Description

The set_winner function assumes outcomes Outcome1 and Outcome2 but doesn't handle a NotDecided winner case robustly.

low Issues | 6 findings

Pending

#1 low Issue
Missing Validation for creator_amount in create_single_bet
battlezone.rs
L15
Description

The create_single_bet function does not validate whether the creator_amount is greater than zero. This allows users to create bets with an amount of zero, which undermines the system's integrity by permitting meaningless or invalid bets. Ensuring that the creator_amount is positive is critical to maintaining a fair and functional betting mechanism.

Pending

#2 low Issue
Increased gas usage.
polyzone.rs
L104
Description

Repeated Fee Calculations in claim: Fee-related calculations (e.g., payout divided by 1000 * 5) are repeated.

Pending

#3 low Issue
Lack of Tests for Overflow Conditions
polyzone.rs
L204-229
L130-141
Description

No clear protections against integer overflows in pool bet_join, calculate_odds and payout calculations. Verify all lamport arithmetic to prevent underflows/overflows during transfers, especially when combining amounts in bet_join and payout.

Pending

#4 low Issue
Precision Issues
battlezone.rs
L362-370
Description

Floating-point math in calculate_matcher_details can lead to precision issues.

Pending

#5 low Issue
Overflow/Underflow prevention
battlezone.rs
L158-174
Description

Verify all lamport arithmetic to prevent underflows/overflows during transfers, especially when combining amounts in set_winner and cancel_bet.

Pending

#6 low Issue
Re-entrancy
battlezone.rs
-
Description

In functions like set_winner and cancel_bet, where lamports are transferred, there's no safeguard against re-entrancy. Although Solana programs don't use traditional external calls, re-entrancy could still occur via CPI (Cross-Program Invocation).

informational Issues | 3 findings

Pending

#1 informational Issue
Winner Can Be Set Before Match Ends
battlezone.rs
L104
Description

Currently, the program allows the winner to be set immediately after a match is created, without verifying whether the match's lifecycle has ended. This can lead to premature winner assignments, which may result in disputes or undermine the fairness of the betting process.

Pending

#2 informational Issue
No Event Emissions
polyzone.rs
-
Description

The contract does not emit events for key actions (e.g., bet creation, claim, winner set).

Pending

#3 informational Issue
Initialization without Unique ID Validation
polyzone.rs
-
Description

No explicit checks for duplicate polyzone_id or bet_id creation.