Beginner FriendlyFoundryDeFi
100 EXP
View results
Submission Details
Severity: low
Invalid

Data Integrity and Functionality Vulnerabilities in Steak Points Schema

Summary

The current Steak Points schema has multiple vulnerabilities that could lead to data inconsistencies, inaccurate point calculations, and performance issues. These include the possibility of duplicate entries, inadequate data types for large numbers, lack of proper indexing and validation, and limited functionality for point management.

Vulnerability Details

Relevant code - 2024-08-steaking/steaking-server/src/models/steakPoints.js at main · Cyfrin/2024-08-steaking (github.com)

  • The schema allows duplicate walletAddress entries, potentially leading to data conflicts.

  • The use of Number type for points is insufficient for handling uint256 values from smart contracts.

  • Lack of indexing on the walletAddress field may result in poor query performance.

  • The schema lacks timestamp fields for auditing purposes.

  • Limited data model restricts the ability to track comprehensive staking information.

Impact

  • Data Integrity: Duplicate entries and invalid data can lead to incorrect point totals and unfair distribution of rewards or voting power.

  • Calculation Errors: Inadequate number handling can result in inaccurate point calculations, especially for large stake amounts.

  • Performance: Lack of indexing can cause slow queries as the dataset grows, impacting system responsiveness.

Tools Used

Manual Review

Recommendations

  • Implement unique constraint on walletAddress:

walletAddress: {
type: String,
required: true,
unique: true,
index: true
}
  • Use String type for points with BigInt validation:

    points: {
    type: String,
    required: true,
    validate: {
    validator: function(v) {
    return /^\d+$/.test(v) && BigInt(v) >= 0 && BigInt(v) <= BigInt("115792089237316195423570985008687907853269984665640564039457584007913129639935");
    },
    message: props => `${props.value} is not a valid uint256 value!`
    }

}

Updates

Lead Judging Commences

inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Precision

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.