Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anchor_movie_review_program::update_movie_review do not sanitize rating parameter #431

Open
T-Mathieu opened this issue Sep 5, 2024 · 1 comment · May be fixed by #541
Open

anchor_movie_review_program::update_movie_review do not sanitize rating parameter #431

T-Mathieu opened this issue Sep 5, 2024 · 1 comment · May be fixed by #541

Comments

@T-Mathieu
Copy link
Contributor

Problem

update_movie_review do not include any check on the rating input, allowing the rating to be out of the 1-5 limit.

This test highlights the situation:

it("Movie review is updated with incorrect rating`", async () => {
    const newDescription = "Wow this is new";
    const newRating = 10; // Rating should not be above 5
   
    const tx = await program.methods
      .updateMovieReview(movie.title, newDescription, newRating)
      .rpc();
   
    const account = await program.account.movieAccountState.fetch(moviePda);
    expect(newRating === account.rating);
    expect(newDescription === account.description);
  });

Proposed Solution

Add the same require! in update_movie_review as in add_movie_review:

require!(rating >= MIN_RATING && rating <= MAX_RATING, MovieReviewError::InvalidRating);
@rishabhguptareal
Copy link

can you assign this

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 a pull request may close this issue.

2 participants