Cloud-CV / Cloud-CV/EvalAI

Bug: Race Condition in Public Submission Toggling Allows Multiple Public Submissions

Open
#4,830 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2k
Forks
984
Avg merge
2h 54m
Merged PRs (30d)
14

Description

## Description
When is_restricted_to_select_one_submission is enabled for a challenge phase, multiple submissions can become public simultaneously due to a race condition. This violates the business rule that only one submission should be public at a time.

## Location
**File:** apps/jobs/views.py
**Lines:**
- 342-349 (in challenge_submission function)
- 475-485 (in change_submission_data_and_visibility function)

## Reproduction
1. Save the attached test script as test_bug_race_condition.py
2. Run: python3 test_bug_race_condition.py
3. Observe the output showing 2 public submissions instead of 1

**Test Output:**
Initial: 1 public submission(s) Final: 2 public submission(s) - IDs: [2, 3]

## Expected Behavior
When a challenge phase has is_restricted_to_select_one_submission=True:
- Only 1 submission should be public at any given time
- When making a new submission public, the existing public submission should be made private first
- This should work correctly even with concurrent requests

## Actual Behavior
- Multiple submissions can become public simultaneously
- The race condition occurs because there is no database-level locking
- Both concurrent requests pass the count() == 1 check at the same time
- Both proceed to make their submissions public

![Image](https://github.com/user-attachments/assets/48c0b968-7bfd-43c3-acad-6c723494d722)

Contributor guide

Open the contributing guide

Research direction

Start in apps/jobs/views.py at lines 342-349 in challenge_submission and 475-485 in change_submission_data_and_visibility. Run the supplied test_bug_race_condition.py reproduction and inspect how concurrent requests pass the count check without database-level locking. Done means concurrent requests leave only one public submission for a restricted challenge phase, with regression coverage for the reproduced case.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.