Skip to content
Webvirtcloud Api Missing Authz Migrate Create

Webvirtcloud Api Missing Authz Migrate Create

hackmd.io • November 5, 2026

# CVE-2026-122224: WebVirtCloud REST API missing authorization lets any logged-in user migrate, create, and enumerate other users' instances

![type](

![cwe](

![component](

![severity](

![status](

**Project:** [retspen/webvirtcloud]( Django KVM/libvirt virtualization web panel, REST API instance viewsets

**Affected:** v1.0 and the default branch at pinned commit `bb920b0a7ffdf00c09e994dc2e45f05bc9ec1bb3`

**Class:** CWE-862 Missing Authorization, CWE-639 Authorization Bypass Through User-Controlled Key, CWE-284 Improper Access Control

WebVirtCloud is a multi-user web panel for managing KVM/libvirt virtual machines. Regular users get access to specific instances through per-user grants (the `UserInstance` model), while superusers manage everything. The HTML views enforce this with a helper named `get_instance` and with `@superuser_only` decorators on the sensitive operations.

The REST API does not keep this contract. The API is built on Django REST Framework, and the project sets no project-wide DRF permission default, so any viewset that does not declare its own `permission_classes` falls back to the framework default `AllowAny`. Two viewsets omit the declaration: `MigrateViewSet` and `CreateInstanceViewSet`. A global login middleware still forces a valid session, so these two routes are reachable by any authenticated account, including a plain user with no grant on any instance.

Through `MigrateViewSet` a user selects any instance by primary key from the full `Instance.objects.all()` set and moves it to another compute host. The migration helper never checks ownership. Through `CreateInstanceViewSet` the same class of user defines new domains and volumes on any compute. A third view, the per-compute `InstanceViewSet.list`, returns every instance on a compute with no per-user filter, which discloses the names and UUIDs an attacker needs to drive the first two. The trust boundary crossed is user to user, and the impact is control over another tenant's virtual machine, not a change to the attacker's own account.

### The intended model: grants, get_instance, and superuser_only

Regular users reach an instance only when a `UserInstance` grant links them to it. The HTML layer funnels every instance action through `get_instance`, which raises 404 when the caller is neither a superuser, nor holds the `instances.view_instances` permission, nor has a grant on that instance.

Check that instance is available for user, if not raise 404

instance = get_object_or_404(Instance, pk=pk)

user_instances = user.userinstance_set.all().values_list("instance", flat=True)

or user.has_perm("instances.view_instances")

The most sensitive HTML operations add a second guard. Migration and creation are superuser only.

`instances/views.py:1596` and `instances/views.py:1648`

def create_instance_select_type(request, compute_id):

def create_instance(request, compute_id, arch, machine):

The REST layer defines no default permission class.

`webvirtcloud/settings.py.template:291-293`

"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",

There is no `DEFAULT_PERMISSION_CLASSES` and no `DEFAULT_AUTHENTICATION_CLASSES`. When these keys are absent, Django REST Framework uses its built-in default of `rest_framework.permissions.AllowAny`. The viewsets that are meant to be protected set the permission class by hand, which confirms there is no global default to inherit.

`instances/api/viewsets.py:37`, `:68`, `:171`

class InstancesViewSet(viewsets.ViewSet):

permission_classes = [permissions.IsAuthenticated]

permission_classes = [permissions.IsAuthenticated]

class FlavorViewSet(viewsets.ModelViewSet):

permission_classes = [permissions.IsAuthenticated]

### The one guard that still fires: login middleware

A global middleware requires a valid session for every view that is not explicitly exempt.

`webvirtcloud/settings.py.template:72-86`

"django.middleware.security.SecurityMiddleware",

"whitenoise.middleware.WhiteNoiseMiddleware",

"django.contrib.sessions.middleware.SessionMiddleware",

"django.middleware.locale.LocaleMiddleware",

"django.middleware.common.CommonMiddleware",

"django.middleware.csrf.CsrfViewMiddleware",

"django.contrib.auth.middleware.AuthenticationMiddleware",

"login_required.middleware.LoginRequiredMiddleware",

LOGIN_REQUIRED_IGNORE_VIEW_NAMES = ["accounts:login", "accounts:email_otp"]

`LoginRequiredMiddleware` from django-login-required-middleware forces authentication on every route except login and OTP. It checks authentication only. It makes no role or object decision. So the two unguarded API viewsets are not open to anonymous callers, they are open to every authenticated account.

### FINDING 1: MigrateViewSet moves any instance

serializer = MigrateSerializer(data=request.data)

instance = serializer.validated_data["instance"]

target_host = serializer.validated_data["target_compute"]

return Response({"status": "instance migrate is started"})

The class has no `permission_classes`, so it is `AllowAny`. The `instance` value comes from the serializer. `MigrateSerializer` is a `ModelSerializer` over `MigrateInstance`, whose `instance` attribute is a foreign key to `Instance`.

class MigrateSerializer(serializers.ModelSerializer):

instance = Instance.objects.all().prefetch_related("userinstance_set")

live = serializers.BooleanField(initial=True)

xml_del = serializers.BooleanField(initial=True)

fields = ["instance", "target_compute", "live", "xml_del", ...]

Instance, related_name="source_host", on_delete=models.DO_NOTHING

Compute, related_name="target_host", on_delete=models.DO_NOTHING

DRF turns that foreign key into a primary key related field whose queryset is every instance. The caller supplies any `instance` pk and any `target_compute` pk. There is no owner filter and no superuser check anywhere in the request path.

The migration helper confirms that the `user` argument is never used for an authorization decision.

status = connection_manager.host_is_up(new_compute.type, new_compute.hostname)

`user` is a parameter that is never read. The function moves the domain to the new host and, with the default `xml_del` of True, undefines it on the source, then rewrites `instance.compute`.

### FINDING 2: CreateInstanceViewSet defines domains on any compute

class CreateInstanceViewSet(viewsets.ViewSet):

serializer_class = CreateInstanceSerializer

def create(self, request, compute_pk=None, arch=None, machine=None):

context={"compute_pk": compute_pk, "arch": arch, "machine": machine},

compute = Compute.objects.get(pk=compute_pk)

conn = wvmCreate(compute.hostname, compute.login, compute.password, compute.type)

Same defect. No `permission_classes`, so `AllowAny`. The compute is taken straight from the URL. Any authenticated user creates a volume and defines a domain on any compute host. The HTML equivalents are superuser only, shown above.

### FINDING 3: InstanceViewSet.list enumerates every instance on a compute

permission_classes = [permissions.IsAuthenticated]

def list(self, request, compute_pk=None):

compute = get_object_or_404(Compute, pk=compute_pk)

queryset = Instance.objects.filter(compute=compute).prefetch_related(

serializer = InstanceSerializer(queryset, many=True, context={"request": request})

This viewset does require authentication, so it is not `AllowAny`. The flaw is the query. It returns every instance on the compute with no per-user grant filter. Compare the flat list, which filters by grant for non-privileged users.

if request.user.is_superuser or request.user.has_perm("instances.view_instances"):

queryset = Instance.objects.all().prefetch_related("userinstance_set")

The serialized fields include `id` and `uuid`.

class InstanceSerializer(serializers.ModelSerializer):

fields = ["id", "compute", "name", "uuid", "is_template", "created", "drbd"]

So any authenticated user learns the primary key and UUID of every instance on a compute. The primary key is the exact value Finding 1 needs. The compute id together with the UUID is also the shape of a console token used elsewhere in the product.

participant A as Low privilege user (valid session, no grant)

participant E as InstanceViewSet.list (per compute)

participant G as MigrateViewSet create (AllowAny)

participant L as libvirt on source and target hosts

A->>M: GET per compute instances list with session cookie

E-->>A: returns all instances on compute with id and uuid

A->>G: POST migrate with victim instance id and target compute id

G->>H: call migrate_instance with victim instance and attacker user

H->>L: move domain to target host and undefine on source

H-->>A: status instance migrate is started

Prerequisites. A running WebVirtCloud with at least two users. The attacker holds any ordinary account with a valid session, including one with no instance grant. The victim owns one or more instances. At least two compute hosts are registered so that a migration target exists. All request bodies below are illustrative and were not executed against a live service.

1. Authenticate as the low privilege user.

- Request: the attacker logs in through `accounts:login` and keeps the session cookie.

- Response: a session cookie is set, which `LoginRequiredMiddleware` accepts on later requests.

- State change: the attacker now has an authenticated session with no instance grant.

2. Enumerate every instance on a compute (Finding 3).

- Request: `GET /api/computes/ /instances/` with the session cookie.

- Response: a JSON array of all instances on that compute, each with `id`, `name`, and `uuid`, including the victim's instances.

- State change: the attacker now knows the victim instance primary key and UUID.

3. Migrate the victim instance to another host (Finding 1).

- Request: `POST /api/migrate/` with a JSON body that sets `instance` to the victim instance primary key, `target_compute` to a different compute primary key, and leaves `live` and `xml_del` at their defaults.

- Response: HTTP 200 with body `{"status": "instance migrate is started"}`.

- State change: `migrate_instance` runs, `conn_migrate.moveto` moves the domain to the target host, the default `xml_del` undefines it on the source, and `instance.compute` is rewritten to the target. The victim's VM now lives on a host the attacker chose, and its original definition on the source host is removed.

4. Optional, define a new domain on any compute (Finding 2).

- Request: `POST /api/computes/ /instances/create/ / /` with a valid creation body that names a storage pool, a size, and a network.

- Response: HTTP 200 with body `{"status": "Instance is created"}`.

- State change: a new volume is created in the chosen storage pool and a new libvirt domain is defined on the chosen compute, consuming that host's disk and compute capacity, with no grant linking the attacker to that compute.

This finding was derived from static review of the pinned source at commit `bb920b0a7ffdf00c09e994dc2e45f05bc9ec1bb3`. Runtime validation was not performed. No PoC was executed, no live deployment was contacted, and no account or data was used.

The following facts were confirmed in the pinned source.

- `MigrateViewSet` (instances/api/viewsets.py:125) and `CreateInstanceViewSet` (instances/api/viewsets.py:174) declare no `permission_classes`, while `InstancesViewSet` (line 37), `InstanceViewSet` (line 68), and `FlavorViewSet` (line 171) do declare `permission_classes = [permissions.IsAuthenticated]`.

- `REST_FRAMEWORK` in webvirtcloud/settings.py.template:291-293 sets no `DEFAULT_PERMISSION_CLASSES`, so the framework default `AllowAny` applies to the two undeclared viewsets. The development settings file sets no `REST_FRAMEWORK` block either.

- `LoginRequiredMiddleware` is present at settings MIDDLEWARE line 81, and its ignore list at line 288 contains only the login and OTP view names. It enforces authentication only.

- `migrate_instance` at instances/utils.py:110-165 accepts a `user` argument and never reads it for an authorization check.

- The HTML migrate and create views are `@superuser_only` at instances/views.py:434, :1596, and :1648.

- `MigrateSerializer.instance` maps to the `MigrateInstance.instance` foreign key over `Instance`, so the primary key field accepts any instance id.

The DRF default of `AllowAny` when no permission class is set is documented framework behavior, and the explicit per-viewset `IsAuthenticated` declarations on the sibling viewsets corroborate that there is no project-wide default in effect.

Attacker model. A single ordinary authenticated account. No instance grant, no staff flag, and no superuser flag are required. The global login middleware is the only gate the attacker must pass, and a normal login satisfies it.

Finding 1, migration. The attacker moves any instance to any registered compute. With the default `xml_del` of True the source definition is undefined after the move. Impact on the victim is loss of control over VM placement and removal of the VM definition on the original host, which affects availability and the integrity of the deployment. If the chosen target host cannot run the guest, the migration can leave the VM unavailable.

Finding 2, creation. The attacker consumes storage and compute capacity on any host by defining new volumes and domains, with no grant to that host. This is an unauthorized write to shared infrastructure.

Finding 3, enumeration. The attacker learns the id, name, and UUID of every instance on a compute. On its own this is cross-user information disclosure. It also supplies the exact identifiers that Findings 1 and 2 consume.

What is not established. No remote code execution is claimed. No arbitrary file read is claimed. The review did not run against a live service, so exact HTTP status codes and the precise success or failure of a libvirt migration under a given host configuration were not observed, they are inferred from the source path. The migration helper returns early when the target host is down or equals the source, so a successful migration requires a reachable distinct target compute, which is the normal multi-host configuration this product targets.

**Where exactly:** instances/api/viewsets.py:125 (MigrateViewSet) and instances/api/viewsets.py:174 (CreateInstanceViewSet), plus instances/api/viewsets.py:70-75 (InstanceViewSet.list), plus webvirtcloud/settings.py.template:291-293.

@@ class MigrateViewSet(viewsets.ViewSet):

- serializer_class = MigrateSerializer

+ permission_classes = [permissions.IsAdminUser]

+ serializer_class = MigrateSerializer

serializer = MigrateSerializer(data=request.data)

instance = serializer.validated_data["instance"]

+ # enforce that the caller may act on this instance

+ get_instance(request.user, instance.pk)

target_host = serializer.validated_data["target_compute"]

@@ class CreateInstanceViewSet(viewsets.ViewSet):

- serializer_class = CreateInstanceSerializer

+ permission_classes = [permissions.IsAdminUser]

+ serializer_class = CreateInstanceSerializer

@@ class InstanceViewSet(viewsets.ViewSet):

def list(self, request, compute_pk=None):

compute = get_object_or_404(Compute, pk=compute_pk)

- queryset = Instance.objects.filter(compute=compute).prefetch_related(

+ queryset = Instance.objects.filter(compute=compute)

+ if not (request.user.is_superuser or request.user.has_perm("instances.view_instances")):

+ queryset = queryset.filter(userinstance__user=request.user)

+ queryset = queryset.prefetch_related("userinstance_set")

Short term. Add an explicit `permission_classes` to `MigrateViewSet` and `CreateInstanceViewSet` that matches the superuser-only policy the HTML views use. Filter `InstanceViewSet.list` by grant for non-privileged callers, exactly as the flat `InstancesViewSet.list` already does.

Medium term. Set a project-wide DRF default so a missing declaration fails closed.

"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",

"DEFAULT_PERMISSION_CLASSES": ["rest_framework.permissions.IsAuthenticated"],

Defense in depth. Route every instance-targeted API action through the same `get_instance` ownership helper that the HTML views use, so that object-level authorization is enforced in one place for both the HTML and the API surface, and make `migrate_instance` reject a call whose `user` lacks a grant on the instance rather than ignoring the argument.

Declare the missing permission classes, add a project-wide `IsAuthenticated` default, enforce `get_instance` object-level checks inside the migrate and create API actions, and filter the per-compute instance list by grant for non-privileged users.

- No public advisory for this API authorization gap at time of writing. CVE-2026-92761 is a separate issue in the HTML instance views (per-grant permission flags not enforced for a user who already holds a grant) and does not cover the API viewsets described here.

- Pinned source, viewsets:

- Pinned source, serializers:

- Pinned source, migrate helper:

- Pinned source, HTML views and guards:

- Pinned source, settings and middleware:

- Pinned source, API routes:

Reported by hieuPenguinnn, [github.com/hieuPenguinnn](