v2 session enqueue and deployment revision skip the image availability check (customized-image owner, registry allow-list)
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
- Domain
- authorization, backend, security
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 /sessionsigned as A returns 404image_read_not-found, whilePOST /v2/sessions/enqueuesigned as A with that image's UUID returns 201 and the session proceeds toPREPARING. - 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
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lablup/backend.ai
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
lablup/backend.ai#17416 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
lablup/backend.ai#15274 ·
Maintainers usually reply within 1 day
-
[ModelDeploy] Guard the preset-derived replica count and strategy fallbacksMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
lablup/backend.ai#13394 ·
Maintainers usually reply within 1 day
-
[ModelDeploy] Runtime variants created through the API can never be deployedMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
lablup/backend.ai#13393 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
lablup/backend.ai#12348 · 1 comment ·
Maintainers usually reply within 1 day
All issues in lablup/backend.ai
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
enhancement good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 89/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
smk762/argus-atlas#97 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
xdslproject/xdsl#6842 ·
Maintainers usually reply within 1 day