Skip to content

Concurrent platform-link creation can assign duplicate display orders and corrupt link ordering #485

@Ridanshi

Description

@Ridanshi

Summary

Platform link creation determines the next display order using a read-before-write workflow that is not transactionally protected.

Concurrent requests can assign the same display order to multiple links.

Affected Files

  • profileService.ts
  • schema.prisma

Root Cause

The creation flow calculates the current maximum display order and then inserts a new record separately.

Concurrent requests can observe the same maximum value and both create links using identical display orders.

No transactional enforcement or uniqueness constraint prevents this condition.

Reproduction

  1. Create multiple platform-link creation requests simultaneously for the same user.
  2. Allow both requests to execute concurrently.
  3. Inspect the resulting displayOrder values.
  4. Observe duplicate ordering assignments.

Expected Behavior

Each newly created platform link should receive a unique display order.

Actual Behavior

Concurrent requests can generate duplicate display orders.

Why This Is Difficult To Detect

Sequential testing behaves correctly.

The issue only appears under concurrent request execution.

Production Impact

  • Unstable link ordering
  • Ambiguous reorder behavior
  • Inconsistent profile rendering
  • Persistent ordering corruption

Suggested Fix

Protect display-order assignment with transactional guarantees or enforce uniqueness and retry behavior.

Severity

High

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendcriticalIncludes schema, architecture, or other critical core functionality changes.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions