Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f94ca37
fix(keystone): authorize the identity management surface
Oct 13, 2026
ec7fe60
fix(glance): image-poisoning, checksum-of-stored-bytes, task/cache au…
Oct 13, 2026
4f4ff3a
fix(nova): flavor admin surface, port lifecycle, attach/detach atomicity
Oct 13, 2026
b4ad7ff
fix(cinder): admin-gate volume types, QoS specs and the manage surfac…
Oct 13, 2026
e2ff794
fix(neutron,metadata): collision-free IP allocation, shared-network g…
Oct 13, 2026
28e87f3
docs(changelog): record the 2026-10-13 security and correctness fixes
Oct 13, 2026
64c9c97
fix: round-1 review findings on the authz-and-correctness PR
Oct 13, 2026
0e14680
fix: round-2 review findings — os-interface port_id path, upload-cap 413
Oct 13, 2026
8018c61
fix(nova): round-3 review follow-ups — os-interface list and detach
Oct 13, 2026
c914bd5
test(nova): assert the empty fixed_ips serialization in the os-interf…
Oct 13, 2026
fa43d45
test(nova): skip the success-path boot test when qemu-img is absent
Oct 13, 2026
6f52ba5
fix(neutron): close the JSON-null allocation DoS; align allocation wi…
Nov 2, 2026
e026de8
ci: move to Go 1.27.3 (GO-2026-6809) and pin Helm 3.22.1
Nov 2, 2026
d051348
fix(keystone): bind S3 credentials to authorized project scope
senolcolak Nov 6, 2026
879ecfc
fix: serialize IP and volume device allocation
senolcolak Nov 6, 2026
6378f11
fix(glance): bound staging memory and fail incomplete uploads
senolcolak Nov 6, 2026
83f8b07
fix: align guest network metadata and flavor bounds with Flamingo
senolcolak Nov 6, 2026
c03a598
docs: record PR 104 follow-up review and validation
senolcolak Nov 6, 2026
a61140e
Merge origin/main into PR #104 and resolve database conflicts
senolcolak Nov 10, 2026
100b6de
fix: correct merge adaptations for SQLite and Helm CI
senolcolak Nov 10, 2026
11084a0
fix(nova): use database unique violation helper
senolcolak Nov 10, 2026
695021a
refactor(nova): remove obsolete IP allocator
senolcolak Nov 10, 2026
b4e3602
fix: repair PR 104 unit test failures
senolcolak Nov 10, 2026
760acb1
fix: address PR 104 review feedback
senolcolak Nov 10, 2026
98fb905
fix(keystone): normalize authorized uuid path params
senolcolak Nov 10, 2026
5615b71
fix: resolve remaining PR 104 review threads
senolcolak Nov 12, 2026
00554e1
fix(neutron): remove unused bytes import
senolcolak Nov 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ jobs:
restore-keys: |
${{ runner.os }}-go-

- name: Install qemu-img for image normalization tests
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends qemu-utils

- name: Run unit tests with race detector
run: go test -race -coverprofile=coverage.txt -covermode=atomic $(go list ./... | grep -v '/test/contract')
env:
Expand Down
31 changes: 28 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

---

## [Unreleased]

### 🔒 Security — identity & service authorization
- **Keystone management surface authorized**: the identity API was authentication-only, so any member could reset any user's password (including the admin's) via `PATCH /users/:id`, self-grant the admin role via role assignment, dump every tenant's recoverable EC2/S3 secret via the credentials API, mint application credentials for other users, and enumerate users/projects/roles/groups/domains/catalog. User/project/role/group/domain/service/endpoint management is now admin-only; user-scoped subresources are self-or-admin; PATCH of one's own password/enabled stays admin-only so ChangePassword keeps its original-password contract. Role assignment also 404s on nonexistent project/user/role ids instead of silently recording garbage.
- **Glance image upload ownership**: uploading bytes to a public image was allowed for any project that could *see* it — image poisoning of an operator-staged base every tenant boots. Upload now follows the same owner-or-admin rule as delete (403 visible-but-foreign, 404 invisible).
- **Glance tasks & cache**: tasks are owner-scoped and no longer echo internal errors; cache management (prefetch/evict/clear) is admin-only.
- **Nova flavor catalog**: flavor create/delete, extra-specs and tenant-access grants are admin-only; flavor limits match Flamingo's signed 32-bit range, including zero root disk for boot-from-volume.
- **Nova deployment views**: `os-hypervisors` (index/detail/statistics), `os-services` and `os-console-auth-tokens` require the admin role because they expose deployment-wide state.
- **Cinder operator surfaces**: volume types (incl. project-access grants), QoS specs and manage/unmanage are admin-only; volume-type reads stay open for tenants.
- **Neutron shared networks**: `shared=true` on create is admin-only, like `router:external`.
- **S3 credential scope and revocation**: editable credential blobs cannot override the recorded project, and S3/EC2 authentication refuses missing or revoked project roles and failed role lookups.
- **Identity self-service UUIDs**: uppercase and compact UUIDs identify the same user for authorization, including credentials and profile updates.
- **Volume-transfer auth keys** are compared in constant time.

### 🐛 Correctness
- **Glance checksums describe the stored bytes**: normalizing backends rewrite a qcow2 upload to a raw base, but the recorded checksum hashed the upload stream, so `EnsureLocalBase` failed on every node without the local base and boot-from-image errored. The checksum is now taken from the stored object; unreadable stored data or failed state writes fail the upload instead of returning success. Concurrent uploads atomically claim the queued image, and failed uploads reset it for retry.
- **Neutron IP allocation is collision-free**: allocation drew purely at random, so ports in one subnet could land on the same address; allocation and insertion share a subnet lock across port creation, server boot and interface attach. Canonical IPv6 comparisons prevent duplicate spellings, a complete fallback finds the last free address, and tiny subnets (≤ /29) no longer panic `crypto/rand.Int`.
- **Metadata `network_data.json` works**: the query selected a nonexistent `fixed_ip` column and answered 500 to every guest; it now resolves each port's JSONB addresses with their own subnets: one link per port, unique network IDs, correct IPv4/IPv6 masks, routes and DNS services, and empty arrays instead of null.
- **Nova volume attach/detach are atomic**: single transactions keep attachments and volume state consistent. Attach serializes device assignment per server and uses the existing transaction connection, avoiding pool deadlock and device collisions.
- **Nova boot port lifecycle**: a failed multi-network boot releases the ports it already allocated; server delete deletes only the ports Nova created and *detaches* tenant-created ports instead of destroying them.
- **Keypair name races** map the unique-constraint violation to the same 409 as the pre-check.
- **Request bodies bounded**: glance upload/stage enforce the 10 GiB cap with bounded memory; staging accepts OpenStack's PUT method; imported SSH public keys are capped at 64 KiB.

---

## [0.6.1] - 2026-04-22

### 📋 v0.7.0 Planning & Specifications
Expand Down Expand Up @@ -59,11 +84,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### 📊 Observability
- **Zerolog migration**: Replace remaining `log.Printf` calls with structured `zerolog` logging (M-1)
- **Scan error logging**: Add warnings for previously silent `rows.Scan` failures across all list handlers (M-4)
- **Scan error logging**: Add warnings for previously silent `rows.Scan` failures across all list handlers
- **Swallowed error propagation**: Log or propagate 15 instances of silently discarded errors (M-6)

### 🛠️ Utilities & Fixes
- **Shared pagination helper**: `common.ParsePagination()` extracts duplicated limit/offset/marker parsing (M-3)
- **Shared pagination helper**: `common.ParsePagination()` extracts duplicated limit/offset/marker parsing
- **Version consistency**: Fix Placement (1.39→1.40) and Nova (2.79→2.90) version mismatches with constants (H-10, L-4)
- **Quota queries**: `GetLimits` reads project quotas from database instead of hardcoded values (H-12)
- **Flavor pagination**: Replace UUID-based cursor with `created_at` for deterministic ordering (M-10)
Expand All @@ -85,7 +110,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **Updated INDEX.md**: Add Testing & Quality section with links to all moved files

### Deferred to v0.7.0
- Database dependency injection (H-3) — 665 call sites, needs dedicated design
- Database dependency injection — 665 call sites, needs dedicated design
- Rate limiting (H-6) — needs design spec for per-project limits
- Re-enable CI linting (H-4) — needs lint error cleanup first

Expand Down
30 changes: 30 additions & 0 deletions docs/review/pr-104-follow-up-2026-11-06.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# PR #104 follow-up review — 2026-11-06

Reviewed the authorization and correctness changes at `e026de8`, including their failure and concurrency paths. The following additional findings are fixed on the same PR.

| Area | Reproduced failure | Fix |
|---|---|---|
| S3 credentials | Editing one's own generic credential blob changed the project returned by S3 authentication. | Authenticate against the recorded project; use the blob's tenant only for legacy rows without a project column. EC2 credential views use the same precedence. |
| S3 role revocation | A correctly signed request still returned 200 after the user's project role was removed. | Require a current project role and fail closed on role-query errors. |
| Identity self-service | Uppercase and compact UUID spellings returned 403 for the user's own profile and application credentials. | Compare parsed UUID values while preserving authorization-before-validation ordering. |
| Volume attachment | One database connection caused a timeout; concurrent attachments to different volumes collided on the device uniqueness constraint. | Lock the instance before choosing a device and use the transaction's connection for the device query. |
| Concurrent port allocation | Twelve concurrent requests through Neutron create, Nova boot allocation and Nova interface attach created eight ports holding one address. | Hold a shared subnet row lock across address selection and insertion in all three paths. |
| Dense subnets and IPv6 | A subnet with one free address falsely reported exhaustion; expanded and compressed IPv6 addresses were treated as different claims. | Complete the random search with a bounded sequential scan and canonicalize addresses. Gateway lookup errors now fail allocation. |
| Image staging | OpenStack's PUT route returned 404; an 8 MiB body caused a growing read buffer of over 2 MiB despite the upload cap. | Register PUT, stream with bounded memory, preserve 413, and prevent staging from overwriting a concurrently changed image state. |
| Image upload finalization | Injected database write failures still returned 204, sometimes leaving the image in saving. The normalized-checksum error branch substituted the original stream hash. | Atomically claim queued images, fail unsuccessful activation, require the stored checksum and reset unsuccessful uploads using a bounded cleanup context. |
| Guest network metadata | Multiple addresses on one port shared a network ID; addressless ports returned null networks; IPv6 was labeled IPv4. Routes and DNS lacked the fields consumed by cloud-init. | Unique IDs, proper IPv4/IPv6 masks, routes and DNS services, and empty arrays. |
| Flavor validation | Valid zero-disk and large flavors were rejected by arbitrary limits. | Match Flamingo's signed 32-bit bounds, positive RAM/vCPU requirements and nonnegative disk sizes. |

The metadata shape and flavor bounds were checked against OpenStack Nova's `stable/2025.2` implementations in [netutils.py](https://github.com/openstack/nova/blob/stable/2025.2/nova/virt/netutils.py) and [parameter_types.py](https://github.com/openstack/nova/blob/stable/2025.2/nova/api/validation/parameter_types.py).

## Validation

- Linux, Go 1.27.3 and isolated PostgreSQL 18.3.
- Full unit suite with the race detector and database tests enabled passed. Packages changed afterward were rerun with the race detector.
- Pinned `make lint`: zero issues. Linux binary build passed.
- Horizon create-UI API probe: 85 passed, zero failed. This is an API probe, not a browser test.
- Live contract suite: 308 passed, 12 skipped, five failed. Running the original PR head in a separate database produced exactly the same counts and failing tests. These fixtures invoke a hardcoded `docker exec lightstack-postgres`; the isolated test container does not provide that command or access to the user's Docker containers.

The five unchanged fixture failures are `TestCinderUnmanageVolume_Contract`, `TestNeutronGetAgent_Contract`, `TestNeutronAddL3AgentToRouter_Contract`, `TestTrunkBasicCRUD`, and `TestTrunkSubports`. The Cinder fixture panics when parsing the missing command's output. This local contract run is not a complete pass; the repository's CI environment remains the full contract gate.

No real libvirt VM, host networking or Ceph RGW deployment was exercised locally. PostgreSQL-backed handler tests cover the authorization, transaction and error paths above; existing storage tests cover the real qemu-img conversion.
35 changes: 35 additions & 0 deletions internal/cinder/manage.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ import (

// ManageVolume handles POST /v3/os-volume-manage
func (svc *Service) ManageVolume(c *gin.Context) {
// Admin-only: volume types, QoS specs and the
// manage/unmanage surface shape storage for every tenant and address
// host-level backends (upstream: volume_extension:* and
// volume_extension:volume_admin_actions:*, all admin_api). Checked before
// the body is bound so a non-admin gets 403, not a 400.
if !common.RequireAdmin(c, "cinder:ManageVolume") {
return
}

projectID := c.GetString("project_id")

var req struct {
Expand Down Expand Up @@ -74,6 +83,15 @@ func (svc *Service) ManageVolume(c *gin.Context) {

// ListManageableVolumes handles GET /v3/manageable_volumes
func (svc *Service) ListManageableVolumes(c *gin.Context) {
// Admin-only: volume types, QoS specs and the
// manage/unmanage surface shape storage for every tenant and address
// host-level backends (upstream: volume_extension:* and
// volume_extension:volume_admin_actions:*, all admin_api). Checked before
// the body is bound so a non-admin gets 403, not a 400.
if !common.RequireAdmin(c, "cinder:ListManageableVolumes") {
return
}

host := c.Query("host")

if host == "" {
Expand All @@ -90,6 +108,15 @@ func (svc *Service) ListManageableVolumes(c *gin.Context) {

// UnmanageVolume handles volume action: os-unmanage
func (svc *Service) UnmanageVolume(c *gin.Context, volumeID string) {
// Admin-only: volume types, QoS specs and the
// manage/unmanage surface shape storage for every tenant and address
// host-level backends (upstream: volume_extension:* and
// volume_extension:volume_admin_actions:*, all admin_api). Checked before
// the body is bound so a non-admin gets 403, not a 400.
if !common.RequireAdmin(c, "cinder:UnmanageVolume") {
return
}

projectID := c.GetString("project_id")

// Verify volume exists and belongs to project
Expand Down Expand Up @@ -136,6 +163,14 @@ func (svc *Service) UnmanageVolume(c *gin.Context, volumeID string) {

// ManageSnapshot handles POST /v3/os-snapshot-manage
func (svc *Service) ManageSnapshot(c *gin.Context) {
// Admin-only: like os-volume-manage, this imports
// an operator's existing backing into the API — upstream gates it
// volume_admin_actions:snapshot_manage. Checked before the body is bound
// so a non-admin gets 403, not a 400.
if !common.RequireAdmin(c, "cinder:ManageSnapshot") {
return
}

projectID := c.GetString("project_id")

var req struct {
Expand Down
84 changes: 84 additions & 0 deletions internal/cinder/manage_authz_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package cinder

import (
"context"
"net/http"
"strings"
"testing"

"github.com/google/uuid"
)

// TestOperatorSurfacesAdminOnly pins the admin gates on volume types, QoS
// specs and the manage/unmanage surface shape storage for every tenant (and
// manage addresses host-level backends). They were authentication-only — a
// plain member could create volume types every tenant then booted from, add
// its project to a private type, and import host backings into its quota.
// Reads of volume types stay open: tenants need them to pick one at create.
func TestOperatorSurfacesAdminOnly(t *testing.T) {
requireDB(t)
r := newCinderTestRouter()

const project = "00000000-0000-0000-0000-000000000002" // seeded default project
member := map[string]string{"X-Test-Project": project, "X-Test-Roles": "member"}
admin := map[string]string{"X-Test-Project": project, "X-Test-Roles": "admin"}

memberDenied := []struct{ name, method, path, body string }{
{"create volume type", http.MethodPost, "/v3/types", `{"volume_type":{"name":"member-type"}}`},
{"manage a volume", http.MethodPost, "/v3/os-volume-manage", `{"volume":{"host":"h1","ref":{"source-name":"x"}}}`},
{"manage a snapshot", http.MethodPost, "/v3/os-snapshot-manage", `{"snapshot":{"volume_id":"00000000-0000-0000-0000-000000000000","ref":{"source-name":"x"}}}`},
{"list manageable volumes", http.MethodGet, "/v3/manageable_volumes", ""},
{"create a QoS spec", http.MethodPost, "/v3/qos-specs", `{"qos_specs":{"name":"member-qos"}}`},
}
for _, tc := range memberDenied {
t.Run(tc.name, func(t *testing.T) {
if code, body := doReq(r, tc.method, tc.path, tc.body, member); code != http.StatusForbidden {
t.Errorf("%s %s as member: code=%d body=%s; want 403", tc.method, tc.path, code, body)
}
})
}

// The type catalog stays readable for members (they pick a type at create).
if code, body := doReq(r, http.MethodGet, "/v3/types", "", member); code != http.StatusOK {
t.Errorf("GET /v3/types as member: code=%d body=%s; want 200 (reads stay open)", code, body)
}

// And the admin keeps the write paths. Unique name + cleanup: the volume
// types table is shared across runs of the shared test database.
typeName := "authz-admin-type-" + uuid.NewString()[:8]
if code, body := doReq(r, http.MethodPost, "/v3/types", `{"volume_type":{"name":"`+typeName+`"}}`, admin); code != http.StatusCreated && code != http.StatusOK {
t.Fatalf("create volume type as admin: code=%d body=%s; want 2xx", code, body)
}
t.Cleanup(func() {
_, _ = testPool.Exec(context.Background(), `DELETE FROM volume_types WHERE name = $1`, typeName)
})
}

// Round 2 of this review: a volume type created without a description has a
// NULL one, and ListVolumeTypes scanned it into a plain string — the row
// failed to scan and the type silently vanished from the catalog (and
// GetVolumeType 500'd). The list must serve both descriptions and their
// absence.
func TestListVolumeTypesServesNullDescription(t *testing.T) {
requireDB(t)
r := newCinderTestRouter()

const project = "00000000-0000-0000-0000-000000000002"
admin := map[string]string{"X-Test-Project": project, "X-Test-Roles": "admin"}

typeName := "authz-undescribed-" + uuid.NewString()[:8]
code, body := doReq(r, http.MethodPost, "/v3/types", `{"volume_type":{"name":"`+typeName+`"}}`, admin)
if code != http.StatusCreated && code != http.StatusOK {
t.Fatalf("create undescribed volume type: code=%d body=%s", code, body)
}
t.Cleanup(func() {
_, _ = testPool.Exec(context.Background(), `DELETE FROM volume_types WHERE name = $1`, typeName)
})

if code, body := doReq(r, http.MethodGet, "/v3/types", "", admin); code != http.StatusOK {
t.Fatalf("list volume types: code=%d body=%s", code, body)
}
if !strings.Contains(body, typeName) {
t.Errorf("a volume type created without a description is missing from GET /v3/types (the NULL-description scan drop): %s", body)
}
}
Loading
Loading