Skip to content

[BUG][HIGH] Race condition in free cloud selection for self-assignment #670

Description

@kambiz-aghaiepour

Description

When cloud is not specified in a self-assignment request, CloudDao.get_free_clouds() picks the first free cloud. Two concurrent requests can retrieve the same cloud before either creates an assignment, leading to two active assignments on one cloud.

Affected Code

  • src/quads/server/blueprints/assignments.py:373-381
_free_clouds = CloudDao.get_free_clouds()
if not _free_clouds:
    # ...
_cloud = _free_clouds[0]

Impact

  • Multiple active assignments on the same cloud
  • Network/VLAN conflicts
  • Resource allocation corruption

Recommended Fix

Use database-level locking (SELECT ... FOR UPDATE) when selecting a free cloud, or perform cloud selection and assignment creation within a single transaction.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions