v2 session enqueue and deployment revision skip the image availability check (customized-image owner, registry allow-list)

Open
#17,289 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
32/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
graphql, python

Research direction

Start in src/ai/backend/manager/services/session/service.py at SessionService.enqueue_session, where only SessionRepository.resolve_image_by_id runs before enqueue_session_from_draft. Compare with ScheduleDBSource.check_available_image reached via SchedulingController.validate_session_spec, and with DeploymentController.add_revision. Done means v2 enqueue and revision-add refuse another user's customized image and disallowed-registry images, with tests asserting the refusal; the 26.4 backport needs the label-based check.

Written by the indexing model from the issue text.

Description

Summary

POST /v2/sessions/enqueue (and the enqueueSession GraphQL mutation) accepts any image_id whose row exists and is ALIVE. It does not apply the two rules that legacy POST /session and check_available_image apply: a customized image is usable only by the user it was committed for, and a non-local image is usable only when its registry is allowed for the caller's domain.

Reproduction

Reproduced on Manager 26.4.8 (PyPI wheel) with two regular users A and B in the same domain.

  • With an image row labelled ai.backend.customized-image.owner=user:<B>, POST /session signed as A returns 404 image_read_not-found, while POST /v2/sessions/enqueue signed as A with that image's UUID returns 201 and the session proceeds to PREPARING.
  • The same holds for an image whose registry is not in domains.allowed_docker_registries: legacy create returns 404 "unknown alias or disallowed registry", v2 enqueue returns 201.

The check was run against a dummy agent row, so no kernel was actually started.

Cause

SessionService.enqueue_session (src/ai/backend/manager/services/session/service.py, the block commented "Keep the image resolve so callers passing a stale UUID get a sharp error here") calls only SessionRepository.resolve_image_by_id and then SchedulingController.enqueue_session_from_draft. No rule in the draft preparer or validator chain checks image access.

ScheduleDBSource.check_available_image is reached only through SchedulingController.validate_session_spec, which only DeploymentController.build_creator_from_legacy_draft and update_deployment call. DeploymentController.add_revision (v2 deployment revision add, revision presets, model card deploy) has no image access check either, and the route sessions it produces also go through enqueue_session_from_draft.

The path has had this shape since it was introduced in #10599 and kept it through #11250, #14276 and #17151. By reading the code, it is present in 26.4.0 through 26.4.20, 26.9.8, 26.10.0a11 and current main; only 26.4.8 was exercised live.

Expected

Every session-creating path refuses an image the caller may not use, as #14276 states ("A session start reaches its own customized image, and reads another user's as absent") and as BEP-1077 states ("Committed images stay personal-only as today"). #11390 fixed a comparable missing resource-group access check on the same enqueue path.

Suggested fix

Call check_available_image(image_id, domain, user_uuid) with the owner-resolved identity in SessionService.enqueue_session and in DeploymentController.add_revision, or move it into the session spec validator chain as the TODO: Refactor to use ValidationRule on validate_session_spec suggests. Add tests asserting refusal on the v2 enqueue and revision-add paths. The 26.4 backport needs the label-based form of the check; 26.9 and later use images.customized / images.creator_id.

Context

Found while fixing lablup/backend.ai-fasttrack#7144, where FastTrack resolves an image reference to a UUID before calling the v2 enqueue and therefore has to apply the owner rule itself.

Dominant language
Python
Stars
683
Forks
187
Avg merge
23h 18m
Merged PRs (30d)
760

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lablup/backend.ai

All issues in lablup/backend.ai

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.