Leaderboard Score Direct Manipulation Vulnerability (#83)#86
Merged
Conversation
|
@Ayaanshaikh12243 is attempting to deploy a commit to the csxark's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Leaderboard Score Direct Manipulation Vulnerability (#83)
close #83
Overview
This PR implements server-side validation, session-based score verification, and an admin review system to prevent teams from cheating on the leaderboard through direct score manipulation.
Problem
Leaderboard points were calculated client-side before submission, with no server-side validation:
time_spentvalues (0 seconds, negative values)Solution Implemented
1) Server-Side Score Validation & Calculation
Modified file:
supabase/functions/validate-flag/index.tsChanges:
time_spentagainst elapsed time fromsession_start_timeregister_leaderboard_submission()RPC to check for score anomalies2) Database-Layer Integrity Tracking
New migration:
Databases/supabase/migrations/20260304_leaderboard_score_integrity.sqlAdds:
challenge_sessionstable: Track per-challenge per-team interactionshint_reveal_count: Server-authoritative hints used countwrong_attempt_count: Server-authoritative wrong attempts countsubmitted_*: Client-submitted values for comparisonflagged_for_review: Auto-set if validation failsleaderboard_integrity_flagstable: Admin review queueflag_type: 'time_anomaly', 'impossible_time', 'hints_mismatch', 'attempts_mismatch', etc.severity: 'low', 'medium', 'high', 'critical'evidence: JSON with submitted vs stored values for auditreviewed_by,action,admin_notes: Admin response trackingValidation columns on
leaderboard:validation_level: 'unvalidated', 'validated', 'flagged', 'rejected'validation_warnings: Array of anomalies detectedsession_start_time,server_received_time: Timing audit trailpoints,hints_used: From server calculation, not clientValidation function:
validate_leaderboard_submission()Auto-flagging triggers:
enforce_leaderboard_integrity(): Validates on INSERT, setsvalidation_levelflag_suspicious_leaderboard_entries(): Creates flag record for review if anomalies detectedHelper functions:
record_hint_reveal(): Increment server-side hint count when hint revealedrecord_wrong_attempt(): Increment server-side wrong attempt count on failed submissionAdmin views:
admin_review_queue: Unflagged submissions awaiting review (sorted by severity)leaderboard_with_validation: All submissions with validation status3) Frontend Session Tracking (Anti-Cheat Instrumentation)
Modified file:
src/components/ChallengePage.tsxChanges:
challenge_sessionswithsession_start_timerecord_hint_reveal()RPC to increment server counter4) Admin Review Queue & Actions
New Edge Functions:
get-admin-review-queue/index.ts:admin-flag-action/index.ts:approved: Trust the submission, mark reviewedrejected: Discard the submission from leaderboardpenalize: Remove 25% of earned points (minimum 50) from team as punishmentSecurity Improvements
Files Changed
Databases/supabase/migrations/20260304_leaderboard_score_integrity.sql– new database layer with validation & flaggingsupabase/functions/validate-flag/index.ts– server-side score validation and calculationsupabase/functions/get-admin-review-queue/index.ts– new Edge function for admin reviewsupabase/functions/admin-flag-action/index.ts– new Edge function for admin actionssrc/components/ChallengePage.tsx– session tracking and hint recordingHow It Works (End-to-End)
challenge_sessionstablesubmitted_time_spent,submitted_attempts,submitted_hints_usedregister_leaderboard_submission()RPCvalidation_level = 'validated'validation_level = 'flagged', flag record createdTesting Checklist
validation_level = 'validated', correct points awardedtime_spent = 0→ flagged as impossible_time, high severitytime_spent > actual_elapsed_time + 5s→ flagged as time_anomaly, medium severityhints_used = 0but revealed 3 hints → flagged as hints_mismatchattempts = 1but 5 wrong attempts recorded → flagged as attempts_mismatchchallenge_sessionstable populated after submissionleaderboard_integrity_flagstable has audit evidence (JSON)Deployment Notes
supabase db pushsupabase functions deploy validate-flagsupabase functions deploy get-admin-review-queuesupabase functions deploy admin-flag-actionFollow-up