From 6e42ff3d6b2ea203fc22f5905ae6132a4be58287 Mon Sep 17 00:00:00 2001 From: Uwe Schwaeke Date: Mon, 12 Oct 2026 18:56:32 +0000 Subject: [PATCH 01/12] =?UTF-8?q?feat(release):=20v0.7.0=20release=20found?= =?UTF-8?q?ation=20=E2=80=94=20version=20stamping,=20secret=20guard,=20rel?= =?UTF-8?q?ease=20pipeline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements the top action items from docs/review/comprehensive-review-report-2026-10-12.md: R1 — version stamping (was: CRITICAL, every shipped binary unidentifiable): - main.Version var + lightstack --version flag + startup log - Dockerfile passes the VERSION build-arg into the binary via ldflags - the Makefile's existing -X main.Version injection now actually works - verified: make build -> --version round-trips the git-describe stamp; explicit -X stamps round-trip exactly; linux/arm64 cross-builds CGO-free S2 — refuse well-known/empty JWT secrets (was: HIGH, forged-admin takeover): - LoadConfig refuses the two literals shipped in config/lightstack.yaml and .env.example, and the empty secret, with an actionable error - LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1 is the documented escape hatch for isolated dev/test stacks - the stub-mode dev compose stack and 'make run' opt in explicitly with comments; the Horizon stack and Helm chart already require a real secret - unit tests: refusal pinned for all three values, escape hatch pinned, positive control for a random secret R3 — release pipeline (.github/workflows/release.yml): - tag-triggered (v*): test gate -> linux/amd64+arm64 binaries with checksums -> --version round-trip check -> multi-arch image to ghcr.io -> draft GitHub Release -> Helm chart published as OCI artifact with appVersion pinned to the tag R2 — chart version 0.3.0 -> 0.4.0 (annotated); appVersion 0.7.0 target Also: Horizon OPENSTACK_KEYSTONE_DEFAULT_ROLE _member_ -> member (matches the seeded admin/member/reader roles; _member_ matched nothing). make test: PASS (all unit tests, race detector) Signed-off-by: Uwe Schwaeke --- .github/workflows/release.yml | 124 ++++++++++++++++++++++ CHANGELOG.md | 30 ++++++ CLAUDE.md | 5 +- Makefile | 7 +- build/package/Dockerfile | 2 +- charts/lightstack/Chart.yaml | 3 +- cmd/lightstack/config_test.go | 3 +- cmd/lightstack/main.go | 18 ++++ deployments/docker-compose.yml | 6 ++ deployments/horizon-config/local_settings | 2 +- internal/common/config.go | 41 ++++++- internal/common/config_test.go | 89 ++++++++++++++++ 12 files changed, 321 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..7bdf8e7b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,124 @@ +# Release pipeline — triggered by pushing a v* tag. +# +# Produces, from the tagged commit and nothing else: +# 1. linux/amd64 + linux/arm64 binaries (CGO_ENABLED=0 — the Ceph RBD backend +# sits behind the `ceph` build tag, so cross-compilation needs no cgo) +# 2. a multi-arch container image pushed to ghcr.io +# 3. a GitHub Release with the binaries and their checksums +# 4. the Helm chart published as an OCI artifact (appVersion = the tag) +# +# Version stamping contract (review R1): the tag is injected with +# `-ldflags "-X main.Version="` and round-tripped through +# `lightstack --version` before anything is published. +name: Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + packages: write + +env: + GO_VERSION: '1.27.2' + +jobs: + test: + name: Test gate + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + - name: Run unit tests + run: make test + + release: + name: Build and publish + runs-on: ubuntu-latest + needs: test + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Build binaries + run: | + VERSION="${GITHUB_REF_NAME}" + mkdir -p dist + for GOOS_GOARCH in linux/amd64 linux/arm64; do + GOOS="${GOOS_GOARCH%/*}" + GOARCH="${GOOS_GOARCH#*/}" + CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" \ + go build -trimpath \ + -ldflags "-s -w -X main.Version=${VERSION}" \ + -o "dist/lightstack-${VERSION}-${GOOS}-${GOARCH}" ./cmd/lightstack + CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" \ + go build -trimpath -s -w \ + -o "dist/lightstack-migrate-${VERSION}-${GOOS}-${GOARCH}" ./cmd/lightstack-migrate + done + + - name: Verify version stamping + # R1 regression guard: the Makefile used to inject -X main.Version + # into a variable that did not exist, which Go silently ignored. + run: | + VERSION="${GITHUB_REF_NAME}" + GOT="$(./dist/lightstack-${VERSION}-linux-amd64 --version)" + if [ "$GOT" != "$VERSION" ]; then + echo "::error::--version reported '${GOT}', expected '${VERSION}'" + exit 1 + fi + + - name: Checksums + run: cd dist && sha256sum * > "checksums-${GITHUB_REF_NAME}.txt" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push multi-arch image + uses: docker/build-push-action@v6 + with: + context: . + file: build/package/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ghcr.io/${{ github.repository }}:${GITHUB_REF_NAME} + build-args: | + VERSION=${{ github.ref_name }} + VCS_REF=${{ github.sha }} + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + draft: true + generate_release_notes: true + files: | + dist/lightstack-* + dist/checksums-* + + - name: Publish Helm chart + env: + GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # The chart's own version (Chart.yaml `version`) is bumped per chart + # change in the repo; the app version is pinned to this release tag + # (and the image tag matches it, including the leading "v"). + CHART_VERSION="$(awk '/^version:/ {print $2}' charts/lightstack/Chart.yaml)" + helm package charts/lightstack --app-version "${GITHUB_REF_NAME}" -d dist/ + echo "${GHCR_TOKEN}" | helm registry login ghcr.io \ + -u "${{ github.actor }}" --password-stdin + helm push "dist/lightstack-${CHART_VERSION}.tgz" \ + "oci://ghcr.io/${{ github.repository_owner }}/charts" diff --git a/CHANGELOG.md b/CHANGELOG.md index b26f2fbf..d62c0ce9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 --- +## [Unreleased] + +### 🚀 Release Engineering +- **Version stamping** (review R1, `docs/review/comprehensive-review-report-2026-10-12.md`): + `main.Version` now exists and is injected via `-ldflags "-X main.Version=..."` by + the Makefile, the Dockerfile (`VERSION` build-arg) and the release workflow; + `lightstack --version` prints it and it is logged at startup. Previously the + ldflags injection targeted a nonexistent variable and was silently ignored — + every shipped binary was unidentifiable. +- **Release pipeline** (`.github/workflows/release.yml`, review R3): pushing a `v*` + tag runs the test gate, builds linux/amd64 + linux/arm64 binaries (CGO-free) with + checksums and a `--version` round-trip check, pushes the multi-arch image to + `ghcr.io`, creates a draft GitHub Release and publishes the Helm chart as an OCI + artifact with `appVersion` pinned to the tag. +- **Chart version** 0.3.0 → 0.4.0 (appVersion 0.7.0, matching the target release). + +### 🔒 Security +- **Refuse well-known/empty JWT secrets at startup** (review S2): the defaults + shipped in `config/lightstack.yaml` and `.env.example` are public, and with + stateless tokens knowing one is enough to mint an admin token. `LoadConfig` now + refuses them; `LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1` is the documented + escape hatch for isolated dev/test stacks (the plain docker-compose dev stack + and `make run` opt in explicitly; the Horizon stack and the Helm chart already + require a real secret). +- **Horizon default role** corrected: `OPENSTACK_KEYSTONE_DEFAULT_ROLE` is `member` + (matches the seeded admin/member/reader roles) — was `_member_`, which matches + nothing in the seed. + +--- + ## [0.6.1] - 2026-04-22 ### 📋 v0.7.0 Planning & Specifications diff --git a/CLAUDE.md b/CLAUDE.md index 95724641..578d53fb 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -80,9 +80,12 @@ openstack token issue ### Building and Running ```bash -# Build the main binary +# Build the main binary (version-stamped from git describe) make build # Outputs to bin/lightstack +# Check the build version +./bin/lightstack --version + # Run with configuration make run # Builds and starts with config/lightstack.yaml diff --git a/Makefile b/Makefile index 8c5915d5..3c49710e 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,12 @@ build-with-ebpf: build-ebpf build # Run the application run: build @echo "Starting lightstack..." - ./$(BUILD_DIR)/$(BINARY_NAME) --config config/lightstack.yaml --migrations migrations + # The dev escape hatch: the shipped config carries the well-known default + # JWT secret, which the binary refuses without this (review S2). `make run` + # is a local-development target only — production deployments set a real + # keystone.jwt_secret (or LIGHTSTACK_JWT_SECRET) and never set this. + LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1 \ + ./$(BUILD_DIR)/$(BINARY_NAME) --config config/lightstack.yaml --migrations migrations # Install dependencies install-deps: diff --git a/build/package/Dockerfile b/build/package/Dockerfile index 969e9c9a..83ec59ff 100644 --- a/build/package/Dockerfile +++ b/build/package/Dockerfile @@ -20,7 +20,7 @@ COPY . . # Build the binary for target architecture RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ - go build -ldflags="-w -s" -o lightstack ./cmd/lightstack + go build -ldflags="-w -s -X main.Version=${VERSION}" -o lightstack ./cmd/lightstack # Build the migration tool for target architecture RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ diff --git a/charts/lightstack/Chart.yaml b/charts/lightstack/Chart.yaml index b79fbce6..f092424a 100644 --- a/charts/lightstack/Chart.yaml +++ b/charts/lightstack/Chart.yaml @@ -4,7 +4,8 @@ description: Deploy lightstack (lightweight OpenStack-compatible cloud) on Kuber type: application # Chart version (SemVer). Bumped independently of the product. # 0.3.0: adds the noVNC console proxy + console-token settings (SPEC-021). -version: 0.3.0 +# 0.4.0: release-engineering alignment — appVersion 0.7.0 target, OCI publish via the tag-triggered release workflow. +version: 0.4.0 # Default product image tag when image.tag is unset (image.repository is REQUIRED, no default — FR-018). appVersion: "0.7.0" kubeVersion: ">=1.25.0-0" diff --git a/cmd/lightstack/config_test.go b/cmd/lightstack/config_test.go index fc351e16..fbd0580c 100644 --- a/cmd/lightstack/config_test.go +++ b/cmd/lightstack/config_test.go @@ -14,7 +14,8 @@ import ( // wrong directory, console-tokens would list and purge nothing. func TestLoadConfigAppliesStatePath(t *testing.T) { path := filepath.Join(t.TempDir(), "lightstack.yaml") - if err := os.WriteFile(path, []byte("state_path: /data/lightstack\n"), 0o600); err != nil { + if err := os.WriteFile(path, []byte( + "state_path: /data/lightstack\nkeystone:\n jwt_secret: test-secret-not-a-default\n"), 0o600); err != nil { t.Fatal(err) } t.Cleanup(func() { paths.SetBase(paths.DefaultBase) }) diff --git a/cmd/lightstack/main.go b/cmd/lightstack/main.go index ae52860e..bf051047 100644 --- a/cmd/lightstack/main.go +++ b/cmd/lightstack/main.go @@ -42,8 +42,17 @@ import ( var ( configPath = flag.String("config", "config/lightstack.yaml", "Path to configuration file") migrationsPath = flag.String("migrations", "migrations", "Path to migrations directory") + printVersion = flag.Bool("version", false, "Print the build version and exit") ) +// Version identifies the running build in the field: it is stamped at build +// time by the Makefile, the Dockerfile and the release workflow via +// `-ldflags "-X main.Version="`, and defaults to "dev" otherwise. +// R1 of docs/review/comprehensive-review-report-2026-10-12.md: without this +// variable the ldflags injection silently did nothing, making every shipped +// binary unidentifiable. +var Version = "dev" + func main() { // Subcommand dispatch: `lightstack cleanup` runs the SPEC-010 teardown and exits, // before flag.Parse (which would otherwise treat the subcommand as a positional). @@ -68,6 +77,15 @@ func main() { flag.Parse() + // `lightstack --version` reports the stamped build version and exits, so a + // node in the field can be identified without its deployment metadata. + if *printVersion { + fmt.Println(Version) + return + } + + log.Printf("lightstack %s starting", Version) + // Load configuration cfg, err := loadConfig(*configPath) if err != nil { diff --git a/deployments/docker-compose.yml b/deployments/docker-compose.yml index 58162781..99964137 100644 --- a/deployments/docker-compose.yml +++ b/deployments/docker-compose.yml @@ -65,6 +65,12 @@ services: LIGHTSTACK_REDIS_URL: "redis://redis:6379/0" LIGHTSTACK_CACHE_ENABLED: "true" LIGHTSTACK_JWT_SECRET: "${LIGHTSTACK_JWT_SECRET:-change-me-in-production}" + # The binary refuses the well-known default secret above unless this is + # set (review S2). This is the stub-mode development stack — no real + # guests, tokens never leave the host — so the escape hatch is + # acceptable here. NEVER set it where real guests or foreign clients + # reach the services: pass a real LIGHTSTACK_JWT_SECRET instead. + LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET: "true" LIGHTSTACK_ENDPOINT_HOST: "localhost" # Use localhost for service catalog URLs (accessible from host) # Why this exists: tests run outside any guest, so they name the instance they ask # the metadata service about with the X-Instance-ID header (test/contract/ws4_*, diff --git a/deployments/horizon-config/local_settings b/deployments/horizon-config/local_settings index 07869b25..362bc4e6 100644 --- a/deployments/horizon-config/local_settings +++ b/deployments/horizon-config/local_settings @@ -62,7 +62,7 @@ STATIC_URL = '/static/' # Lightstack Service Discovery OPENSTACK_HOST = "lightstack" # Docker service name OPENSTACK_KEYSTONE_URL = "http://%s:35357/v3" % OPENSTACK_HOST -OPENSTACK_KEYSTONE_DEFAULT_ROLE = "_member_" +OPENSTACK_KEYSTONE_DEFAULT_ROLE = "member" # matches the seeded roles (admin/member/reader) # API Version Configuration (Lightstack Flamingo Compatible) OPENSTACK_API_VERSIONS = { diff --git a/internal/common/config.go b/internal/common/config.go index f9602ec6..03bc1692 100644 --- a/internal/common/config.go +++ b/internal/common/config.go @@ -375,14 +375,49 @@ func LoadConfig(path string) (*Config, error) { cfg.Nova.ShutdownTimeout = MaxShutdownTimeout } - // Warn if using default JWT secret - if cfg.Keystone.JWTSecret == "change-me-in-production" { - fmt.Fprintln(os.Stderr, "WARNING: Using default JWT secret! Set LIGHTSTACK_JWT_SECRET environment variable in production.") + // Refuse well-known (or empty) JWT secrets unless explicitly overridden. + // The defaults below ship in this repository and in .env.example, so anyone + // can read them — and because tokens are stateless, knowing the secret is + // enough to mint an admin token for every service (review finding S2, + // docs/review/comprehensive-review-report-2026-10-12.md). The chart already + // fails fast on an empty secret; this gives the binary the same stance. + if isInsecureDefaultJWTSecret(cfg.Keystone.JWTSecret) && !allowInsecureDefaultJWTSecret() { + return nil, fmt.Errorf( + "keystone.jwt_secret is empty or a well-known default — refusing to start. " + + "Set keystone.jwt_secret in the config file (or the LIGHTSTACK_JWT_SECRET " + + "environment variable) to a random value, e.g. `openssl rand -base64 32`. " + + "For isolated development or test environments only, " + + "LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1 opts out of this check") } return &cfg, nil } +// insecureDefaultJWTSecrets are values that appear in this repository's shipped +// configuration and examples. An empty secret is equally forgeable (HMAC with a +// known key), so it is refused too. +var insecureDefaultJWTSecrets = map[string]struct{}{ + "": {}, + "change-me-in-production": {}, + "change-me-in-production-use-openssl-rand-base64-32": {}, +} + +func isInsecureDefaultJWTSecret(secret string) bool { + _, known := insecureDefaultJWTSecrets[secret] + return known +} + +// allowInsecureDefaultJWTSecret is the documented escape hatch for stub-mode +// development and test stacks that never validate a foreign token. +func allowInsecureDefaultJWTSecret() bool { + switch os.Getenv("LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET") { + case "1", "true": + return true + default: + return false + } +} + // maxRealModeStatePath keeps a guest's console socket path within QEMU's 108-byte // sun_path: 108 - len("/console-sockets/") - 36 (uuid) - len(".sock") = 50 (SPEC-021 // FR-017). Stub mode creates no sockets, so it is not limited. diff --git a/internal/common/config_test.go b/internal/common/config_test.go index 28427f78..cea62d58 100644 --- a/internal/common/config_test.go +++ b/internal/common/config_test.go @@ -9,6 +9,14 @@ import ( "time" ) +// allowInsecureDefaultSecret opts this test into the development escape hatch: +// these tests exercise unrelated config keys through minimal config files that +// do not set keystone.jwt_secret, which LoadConfig refuses by default (S2). +func allowInsecureDefaultSecret(t *testing.T) { + t.Helper() + t.Setenv("LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET", "1") +} + func TestLoadConfig(t *testing.T) { // Create a temporary config file tmpfile, err := os.CreateTemp("", "lightstack-test-*.yaml") @@ -134,6 +142,7 @@ logging: // keystone.rgw_compat_tenant_ids parses from YAML and defaults to false. func TestLoadConfigKeystoneRGWCompatTenantIDs(t *testing.T) { + allowInsecureDefaultSecret(t) tmp, err := os.CreateTemp("", "lightstack-rgwcompat-*.yaml") if err != nil { t.Fatal(err) @@ -157,6 +166,7 @@ func TestLoadConfigKeystoneRGWCompatTenantIDs(t *testing.T) { // directions (mirroring the Glance S3 boolean override); unrecognized values // keep the file value. func TestLoadConfigKeystoneRGWCompatTenantIDsEnvOverrides(t *testing.T) { + allowInsecureDefaultSecret(t) writeCfg := func(t *testing.T, on bool) string { t.Helper() tmp, err := os.CreateTemp("", "lightstack-rgwcompatenv-*.yaml") @@ -232,6 +242,7 @@ database: // SPEC-014 T031: the S3/RGW backend config (TLS/CA + timeout) parses from YAML. func TestLoadConfigGlanceS3(t *testing.T) { + allowInsecureDefaultSecret(t) tmp, err := os.CreateTemp("", "lightstack-s3-*.yaml") if err != nil { t.Fatal(err) @@ -265,6 +276,7 @@ glance: // SPEC-014 T031: LIGHTSTACK_GLANCE_S3_* env vars override the file config. func TestLoadConfigGlanceS3EnvOverrides(t *testing.T) { + allowInsecureDefaultSecret(t) tmp, err := os.CreateTemp("", "lightstack-s3env-*.yaml") if err != nil { t.Fatal(err) @@ -297,6 +309,7 @@ func TestLoadConfigGlanceS3EnvOverrides(t *testing.T) { // LIGHTSTACK_GLANCE_S3_INSECURE_SKIP_VERIFY=false — otherwise TLS verification stays off // in production with no way to turn it back on from the environment. func TestLoadConfigGlanceS3InsecureEnvCanDisable(t *testing.T) { + allowInsecureDefaultSecret(t) tmp, err := os.CreateTemp("", "lightstack-s3ins-*.yaml") if err != nil { t.Fatal(err) @@ -325,6 +338,7 @@ func TestLoadConfigGlanceS3InsecureEnvCanDisable(t *testing.T) { // node without patching a read-only mounted config. A malformed value is ignored (the // file value stands) rather than silently zeroing the timeout. func TestLoadConfigGlanceS3ConnectTimeoutEnv(t *testing.T) { + allowInsecureDefaultSecret(t) tmp, err := os.CreateTemp("", "lightstack-s3to-*.yaml") if err != nil { t.Fatal(err) @@ -363,6 +377,7 @@ func TestLoadConfigGlanceS3ConnectTimeoutEnv(t *testing.T) { // That is exactly the value upstream Nova's novncproxy_base_url takes, so it must be // refused at load rather than silently accepted or rewritten. func TestLoadConfigConsoleProxyBaseURL(t *testing.T) { + allowInsecureDefaultSecret(t) cases := []struct { value string wantErr bool @@ -425,6 +440,7 @@ func TestLoadConfigConsoleProxyBaseURL(t *testing.T) { // the same string, and a relative root has no meaning on the host. "/" is refused too — // cleanup purges the per-service subdirectories directly under it. func TestLoadConfigStatePath(t *testing.T) { + allowInsecureDefaultSecret(t) cases := []struct { name, yaml, want string wantErr bool @@ -466,6 +482,7 @@ func TestLoadConfigStatePath(t *testing.T) { // and QEMU refuses a socket path longer than 108 bytes, so a longer root would stop every // guest from starting. Stub mode creates no sockets and is not limited (SPEC-021 FR-017). func TestLoadConfigStatePathLengthInRealMode(t *testing.T) { + allowInsecureDefaultSecret(t) root50 := "/" + strings.Repeat("a", 49) root51 := "/" + strings.Repeat("a", 50) for _, tc := range []struct { @@ -504,6 +521,7 @@ func TestLoadConfigStatePathLengthInRealMode(t *testing.T) { // false turns consoles off, which is what the chart renders wherever it deploys no // proxy (multi-node, or consoleProxy.enabled=false). func TestLoadConfigConsoleEnabled(t *testing.T) { + allowInsecureDefaultSecret(t) for _, tc := range []struct { name, yaml string want bool @@ -533,6 +551,7 @@ func TestLoadConfigConsoleEnabled(t *testing.T) { // the interval goes straight to time.NewTicker in the token reconciler, which panics on // a non-positive duration, and a zero TTL would issue tokens that are already expired. func TestLoadConfigConsoleDurations(t *testing.T) { + allowInsecureDefaultSecret(t) for _, tc := range []struct { name, yaml string ttl, interval time.Duration @@ -568,6 +587,7 @@ func TestLoadConfigConsoleDurations(t *testing.T) { // instance's metadata and user-data. Test stacks turn it on from the environment, and // the override works both ways, like every other boolean one. func TestLoadConfigMetadataTrustInstanceHeader(t *testing.T) { + allowInsecureDefaultSecret(t) for _, tc := range []struct { name, file, env string want bool @@ -600,6 +620,7 @@ func TestLoadConfigMetadataTrustInstanceHeader(t *testing.T) { // the console settings — a deployment that never heard of either still reconciles // drift and still bounds its audit growth. func TestLoadConfigComputeIntervalDefaults(t *testing.T) { + allowInsecureDefaultSecret(t) write := func(t *testing.T, body string) string { t.Helper() p := filepath.Join(t.TempDir(), "lightstack.yaml") @@ -684,6 +705,7 @@ nova: // stop had worked; it just could never say so. Which is the exact failure class the // feature exists to remove, reintroduced one layer down. func TestShutdownTimeoutFitsInsideTheWriteDeadline(t *testing.T) { + allowInsecureDefaultSecret(t) // The invariant, as arithmetic on the constants. This is the assertion that would // have caught the defect before it reached a host: a default that cannot answer is // a default that is wrong, and nothing else in the suite compares these two. @@ -770,3 +792,70 @@ func TestShutdownTimeoutFitsInsideTheWriteDeadline(t *testing.T) { } }) } + +// writeTestConfig persists body to a temp config file and returns its path. +func writeTestConfig(t *testing.T, body string) string { + t.Helper() + tmp, err := os.CreateTemp("", "lightstack-cfg-*.yaml") + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { os.Remove(tmp.Name()) }) + if _, err := tmp.WriteString(body); err != nil { + t.Fatal(err) + } + if err := tmp.Close(); err != nil { + t.Fatal(err) + } + return tmp.Name() +} + +// TestLoadConfigRefusesInsecureDefaultJWTSecret pins the S2 guard: the secrets +// shipped in this repository's config and examples are public, and tokens are +// stateless — knowing one is enough to mint an admin token for every service. +func TestLoadConfigRefusesInsecureDefaultJWTSecret(t *testing.T) { + for _, secret := range []string{ + "", // omitted from the file + "change-me-in-production", // config/lightstack.yaml + "change-me-in-production-use-openssl-rand-base64-32", // .env.example + } { + body := "keystone:\n jwt_secret: \"" + secret + "\"\n" + _, err := LoadConfig(writeTestConfig(t, body)) + if err == nil { + t.Errorf("LoadConfig accepted jwt_secret %q; want refusal", secret) + continue + } + if !strings.Contains(err.Error(), "refusing to start") { + t.Errorf("LoadConfig(%q) error does not explain the refusal: %v", secret, err) + } + } +} + +// TestLoadConfigAllowsInsecureDefaultSecretWithOverride pins the documented +// escape hatch for isolated development and test stacks. +func TestLoadConfigAllowsInsecureDefaultSecretWithOverride(t *testing.T) { + for _, opt := range []string{"1", "true"} { + t.Run("opt="+opt, func(t *testing.T) { + t.Setenv("LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET", opt) + cfg, err := LoadConfig(writeTestConfig(t, "keystone:\n jwt_secret: \"change-me-in-production\"\n")) + if err != nil { + t.Fatalf("LoadConfig with override %q: %v", opt, err) + } + if cfg.Keystone.JWTSecret != "change-me-in-production" { + t.Errorf("JWTSecret = %q; want it passed through unchanged", cfg.Keystone.JWTSecret) + } + }) + } +} + +// TestLoadConfigAcceptsARandomSecret is the positive control for the guard: a +// non-default secret loads without any opt-in. +func TestLoadConfigAcceptsARandomSecret(t *testing.T) { + cfg, err := LoadConfig(writeTestConfig(t, "keystone:\n jwt_secret: \"k4FNxqKmLwW3ZRFvMscJ0d1oO5gYhN\"\n")) + if err != nil { + t.Fatalf("LoadConfig: %v", err) + } + if cfg.Keystone.JWTSecret != "k4FNxqKmLwW3ZRFvMscJ0d1oO5gYhN" { + t.Errorf("JWTSecret = %q; want it preserved", cfg.Keystone.JWTSecret) + } +} From 0233ca2df3d3e61ff3d905097b9a1a72f6f72ed6 Mon Sep 17 00:00:00 2001 From: Uwe Schwaeke Date: Mon, 12 Oct 2026 19:13:28 +0000 Subject: [PATCH 02/12] =?UTF-8?q?fix(release):=20address=20review=20round?= =?UTF-8?q?=201=20=E2=80=94=20C1/H1/H2/M1/L1-L4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit C1 (CRITICAL): release.yml migrate build passed -s -w as top-level go build flags — 'flag provided but not defined: -s' — and bash -e killed the loop on the first iteration, so the pipeline could never produce anything. Now -ldflags "-s -w" like the lightstack line. H1: Dockerfile declared ARG VERSION only in the runtime stage, so the builder stage's ${VERSION} expanded to empty and the image would carry an unidentifiable binary — the exact failure class R1 exists to remove. ARG VERSION=dev is now declared in the builder stage (annotated). H2: the JWT-secret guard gated lightstack-migrate, breaking shipped deployment paths that run it against the canned config before any secret is wired in (image entrypoint CMD, the documented Kubernetes init container, test/migration_test.sh). LoadConfig now delegates to a shared loadConfig(path, enforceSecretGuard); the new common.LoadConfigForMigration skips the guard — the tool never signs or validates a token (it reads database.url and logging only). Pinned by TestLoadConfigForMigrationSkipsSecretGuard. M1: image was pushed as :v0.7.0 while the in-repo chart's appVersion (0.7.0, no v) is what image.tag defaults to — a repo-direct helm install would ImagePullBackOff forever. The workflow now computes IMAGE_TAG=${GITHUB_REF_NAME#v} for the image tag and the chart's --app-version; the binary keeps the full v-prefixed tag (consistent with git describe stamps). L1: deployments/docker/docker-compose.yaml also uses the default secret without the escape hatch — added (with the same dev-only warning comment). L2: docs/review/comprehensive-review-report-2026-10-12.md was referenced from the new code/comments but only existed on the docs branch — landed in-tree (identical content on both branches; merges cleanly with PR #101). L3: release.yml action versions aligned with ci.yml (checkout@v6, setup-go@v6). L4: GitHub Release file glob narrowed to dist/lightstack--*-* + dist/checksums-* so the chart tarball can never be absorbed by step reordering. make test: PASS (all unit tests, race detector) Signed-off-by: Uwe Schwaeke --- .github/workflows/release.yml | 34 ++- CHANGELOG.md | 12 +- build/package/Dockerfile | 5 + cmd/lightstack-migrate/main.go | 7 +- deployments/docker/docker-compose.yaml | 5 + .../comprehensive-review-report-2026-10-12.md | 206 ++++++++++++++++++ internal/common/config.go | 25 ++- internal/common/config_test.go | 14 ++ 8 files changed, 290 insertions(+), 18 deletions(-) create mode 100644 docs/review/comprehensive-review-report-2026-10-12.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7bdf8e7b..8099adb8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,8 +29,8 @@ jobs: name: Test gate runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 with: go-version: ${{ env.GO_VERSION }} - name: Run unit tests @@ -41,12 +41,19 @@ jobs: runs-on: ubuntu-latest needs: test steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - - uses: actions/setup-go@v5 + - uses: actions/setup-go@v6 with: go-version: ${{ env.GO_VERSION }} + - name: Compute image tag + # Container tags and the chart's appVersion carry the bare version + # (0.7.0) — matching Chart.yaml's appVersion and therefore the + # image.tag the in-repo chart defaults to. The binary itself reports + # the full tag (v0.7.0), consistent with `git describe` stamps. + run: echo "IMAGE_TAG=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV" + - name: Build binaries run: | VERSION="${GITHUB_REF_NAME}" @@ -59,7 +66,7 @@ jobs: -ldflags "-s -w -X main.Version=${VERSION}" \ -o "dist/lightstack-${VERSION}-${GOOS}-${GOARCH}" ./cmd/lightstack CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" \ - go build -trimpath -s -w \ + go build -trimpath -ldflags "-s -w" \ -o "dist/lightstack-migrate-${VERSION}-${GOOS}-${GOARCH}" ./cmd/lightstack-migrate done @@ -94,8 +101,11 @@ jobs: file: build/package/Dockerfile platforms: linux/amd64,linux/arm64 push: true + # IMAGE_TAG is the bare version (no leading "v") — the same value + # the in-repo chart's appVersion defaults image.tag to, so a + # repo-direct `helm install` pulls an image that actually exists. tags: | - ghcr.io/${{ github.repository }}:${GITHUB_REF_NAME} + ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }} build-args: | VERSION=${{ github.ref_name }} VCS_REF=${{ github.sha }} @@ -105,8 +115,11 @@ jobs: with: draft: true generate_release_notes: true + # Version-scoped globs only: a bare `dist/lightstack-*` would also + # absorb the chart tarball if the publish step ever moved above + # this one. files: | - dist/lightstack-* + dist/lightstack-${{ github.ref_name }}-*-* dist/checksums-* - name: Publish Helm chart @@ -114,10 +127,11 @@ jobs: GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | # The chart's own version (Chart.yaml `version`) is bumped per chart - # change in the repo; the app version is pinned to this release tag - # (and the image tag matches it, including the leading "v"). + # change in the repo; the app version is the bare release version + # (no leading "v"), matching Chart.yaml's appVersion and the image + # tag pushed above. CHART_VERSION="$(awk '/^version:/ {print $2}' charts/lightstack/Chart.yaml)" - helm package charts/lightstack --app-version "${GITHUB_REF_NAME}" -d dist/ + helm package charts/lightstack --app-version "${IMAGE_TAG}" -d dist/ echo "${GHCR_TOKEN}" | helm registry login ghcr.io \ -u "${{ github.actor }}" --password-stdin helm push "dist/lightstack-${CHART_VERSION}.tgz" \ diff --git a/CHANGELOG.md b/CHANGELOG.md index d62c0ce9..21dcb2cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,8 +19,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **Release pipeline** (`.github/workflows/release.yml`, review R3): pushing a `v*` tag runs the test gate, builds linux/amd64 + linux/arm64 binaries (CGO-free) with checksums and a `--version` round-trip check, pushes the multi-arch image to - `ghcr.io`, creates a draft GitHub Release and publishes the Helm chart as an OCI - artifact with `appVersion` pinned to the tag. + `ghcr.io` (tagged with the bare version — `0.7.0` — matching the chart's + `appVersion` and the `image.tag` default), creates a draft GitHub Release and + publishes the Helm chart as an OCI artifact with `appVersion` pinned to the + release version. - **Chart version** 0.3.0 → 0.4.0 (appVersion 0.7.0, matching the target release). ### 🔒 Security @@ -28,9 +30,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 shipped in `config/lightstack.yaml` and `.env.example` are public, and with stateless tokens knowing one is enough to mint an admin token. `LoadConfig` now refuses them; `LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1` is the documented - escape hatch for isolated dev/test stacks (the plain docker-compose dev stack + escape hatch for isolated dev/test stacks (the plain docker-compose dev stacks and `make run` opt in explicitly; the Horizon stack and the Helm chart already - require a real secret). + require a real secret). `lightstack-migrate` is exempt — it never signs or + validates a token, and the image entrypoint and the documented Kubernetes init + container run it against the canned config before any secret is wired in. - **Horizon default role** corrected: `OPENSTACK_KEYSTONE_DEFAULT_ROLE` is `member` (matches the seeded admin/member/reader roles) — was `_member_`, which matches nothing in the seed. diff --git a/build/package/Dockerfile b/build/package/Dockerfile index 83ec59ff..73c92b04 100644 --- a/build/package/Dockerfile +++ b/build/package/Dockerfile @@ -4,6 +4,11 @@ FROM --platform=$BUILDPLATFORM golang:1.27.2-alpine3.24 AS builder # Build arguments for cross-compilation ARG TARGETOS ARG TARGETARCH +# Version stamp for the binary. Declared HERE, in the builder stage: an ARG +# only visible in a later stage is invisible to this stage's RUN, and Docker +# silently expands it to empty — the image would then carry an unidentifiable +# binary (-X main.Version= with an empty value), the exact failure R1 fixed. +ARG VERSION=dev # Install build dependencies RUN apk add --no-cache git make diff --git a/cmd/lightstack-migrate/main.go b/cmd/lightstack-migrate/main.go index 5daaf867..592d7bab 100644 --- a/cmd/lightstack-migrate/main.go +++ b/cmd/lightstack-migrate/main.go @@ -26,8 +26,11 @@ func main() { // failure and never returns a non-nil error here in practice. _ = flag.CommandLine.Parse(os.Args[2:]) - // Load configuration - cfg, err := common.LoadConfig(*configPath) + // Load configuration. The migration tool never signs or validates a token + // (it reads database.url and logging only), so it loads without the + // server's JWT-secret guard — shipped deployment paths run it against the + // canned config before any secret is wired in (see LoadConfigForMigration). + cfg, err := common.LoadConfigForMigration(*configPath) if err != nil { fmt.Fprintf(os.Stderr, "Failed to load config: %v\n", err) os.Exit(1) diff --git a/deployments/docker/docker-compose.yaml b/deployments/docker/docker-compose.yaml index 12dce4d6..968de50a 100644 --- a/deployments/docker/docker-compose.yaml +++ b/deployments/docker/docker-compose.yaml @@ -37,6 +37,11 @@ services: environment: LIGHTSTACK_DB_URL: "postgres://${POSTGRES_USER:-lightstack}:${POSTGRES_PASSWORD:-secret}@postgres:5432/${POSTGRES_DB:-lightstack}?sslmode=disable" LIGHTSTACK_JWT_SECRET: "${LIGHTSTACK_JWT_SECRET:-change-me-in-production}" + # Dev-only escape hatch: the binary refuses the well-known default + # secret above unless this is set (review S2). This stack is for local + # stub-mode development — NEVER set it where real guests or foreign + # clients reach the services: pass a real LIGHTSTACK_JWT_SECRET instead. + LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET: "true" volumes: # For libvirt access (if running on same host) - /var/run/libvirt:/var/run/libvirt:ro diff --git a/docs/review/comprehensive-review-report-2026-10-12.md b/docs/review/comprehensive-review-report-2026-10-12.md new file mode 100644 index 00000000..6567d31f --- /dev/null +++ b/docs/review/comprehensive-review-report-2026-10-12.md @@ -0,0 +1,206 @@ +# Comprehensive Code Review — 2026-10-12 + +**Reviewed at**: HEAD `e909227` (`v0.6.1-63-ge909227`) +**Scope**: all of `internal/`, `pkg/`, `cmd/`, `charts/`, CI, release/deployment readiness +**Companion**: documentation audit applied the same day (README/CLAUDE/STATUS corrections) + +--- + +## Executive Summary + +Lightstack is in unusually good shape for a single-binary OpenStack reimplementation. +The most recent work (tenant scoping, Neutron fidelity, Nova gaps, quota enforcement) +shows disciplined engineering: + +- The SQL placeholder helper (`common.SQLArgs`) genuinely eliminates the class of drift + bugs it was built for — **no SQL-injection sites found** (the two `fmt.Sprintf`-into-SQL + sites interpolate only identifiers/pre-rendered assignments). +- Quota enforcement holds an advisory lock across check *and* write in one transaction. +- Every reconciler (instance state, network, console tokens, node heartbeat, VXLAN + coordinator) is a clean ticker/`ctx` loop wired into shutdown; sweeps use compare-and-set. +- Migrations 060–073 are idempotent, transactional, and have rollback-aware down files. +- CORS is allow-list only; all HTTP servers set read/write/idle timeouts; tenant isolation + is consistent and carefully documented. + +**No "will not start / data loss on the normal path" defects were found.** The problems +that remain are concentrated in four places: a chain of JWT/identity weaknesses, several +shutdown/goroutine races, release-process debt, and a few correctness loose ends. + +## Release verdict for v0.7.0 + +| Must fix before release | Can ship as documented known-issues | +|---|---| +| **R1** version stamping broken | S3/S4, C1–C4, P1–P5, A1–A4 | +| **R2** tag/chart/README version drift | R3 (no release CI — but see below) | +| **S2** well-known default JWT secret | R4 (auto-migration caveat) | +| **S1** token revocation is a no-op | R5 (postgres pin drift) | + +--- + +## 1. Security + +### S1 — HIGH — Token revocation is a no-op; disabled users keep working until expiry +- `internal/keystone/handlers.go:311-316` — `RevokeToken` returns `204` and does nothing. +- `internal/keystone/auth.go:836-862` — `ValidateToken` (gates every service) checks only + signature + expiry; never re-checks user existence/`enabled` or role liveness. +- Consequence: `DELETE /v3/auth/tokens` answers success while doing nothing; disabling a + user or stripping the admin grant does not stop already-issued tokens (default TTL 24h). +- Inconsistency: `BuildTokenResponse` (auth.go:709-787) *does* fail closed on disabled + users/projects — RGW clients get fail-closed semantics while the API middleware does not. +- **Fix:** add a `jti` claim + revocation list (table or Redis `revoked:`); check + user `enabled` in `ValidateToken`; make `RevokeToken` honest. + +### S2 — HIGH — Well-known default JWT secret ⇒ forged-admin-token takeover +- `config/lightstack.yaml:15` (`jwt_secret: "change-me-in-production"`), + `deployments/docker-compose.yml:67` (same literal as compose default), + `.env.example:7` (yet another distinct public literal). +- `internal/common/config.go:378-381` warns only for the exact string + `"change-me-in-production"` — the `.env.example` value trips nothing. +- Combined with S1 (no DB cross-check), anyone who knows the public secret can mint a + token with `roles:["admin"]` and get full admin over every API. +- **Fix:** refuse to start on empty/known-default secrets (the Helm chart already + fail-fasts on empty `secrets.jwtSecret` — `charts/lightstack/templates/_helpers.tpl:70-74`; + mirror that in the binary); generate a random secret in docker-compose. + +### S3 — MEDIUM — Project-scoped `admin` role is honored as deployment-wide authority +- Roles are scoped to the token's project at issue (`auth.go:341-367`), yet `admin` + widens `?all_tenants` (`internal/nova/server_filter.go:69`), cross-project instance + access (`internal/nova/authz.go:51-61`), quotas (`internal/common/project.go:90`) and + deployment-wide surfaces (`authz.go:119-131`). +- Mirrors upstream Nova's `admin_or_owner` permissiveness, but real Keystone separates + system scope; here it does not. +- **Fix:** document the model as a deliberate tradeoff, or introduce a system scope. + +### S4 — MEDIUM — Rate limiting configured and ADR-accepted, but entirely unimplemented +- `config/lightstack.yaml:166-172` ships a `rate_limiting` block; + `docs/adr/ADR-002-rate-limiting-architecture.md` is **Accepted**. +- Zero code wires it (`internal/nova/handlers.go:3156`, `internal/cinder/volumes.go:2554` + return `"rate": []gin.H{} // No rate limiting implemented`). +- Consequence: unthrottled brute-force on public `POST /v3/auth/tokens` (bcrypt per + attempt) and dead config. +- **Fix:** implement ADR-002 (a minimal IP limiter on `/auth/tokens` is the highest-value + slice) or delete the config + retract the ADR. + +### S5 — LOW — Metadata service binds all interfaces, unauthenticated by design +- `cmd/lightstack/main.go:332-341`; identity is TCP peer IP; `X-Instance-ID` trusted from + loopback only unless `trust_instance_header`. +- **Fix:** document the trust model; warn when binding publicly in stub mode. + +### S6 — LOW — No minimum secret-length guard; no `jti` claim (ties into S1/S2). + +### S7 — INFO — CORS allow-list only, no wildcard (lives in `internal/middleware/logging.go:313-316` — odd placement). + +## 2. Concurrency & Lifecycle + +### C1 — MEDIUM — WaitGroup Add-after-Wait race during shutdown +- `main.go:421` calls `nova.Shutdown()` (cancel + `wg.Wait()`) *before* the HTTP servers + drain (`main.go:448`); in-flight requests can still `svc.wg.Add(1)` + (`nova/handlers.go:1092,3429`, `advanced_actions.go:89,162,254`, `cinder/volumes.go:1621`). +- **Fix:** drain HTTP servers first, then cancel + wait service workers. + +### C2 — MEDIUM — Unbounded `wg.Wait()` can hang the drain +- `nova/handlers.go:94-97` waits without a timeout, blocking the documented + `LIGHTSTACK_DRAIN_SECONDS` guarantee. +- **Fix:** bound the wait with `select` + `time.After`. + +### C3 — LOW — `WithTx` leaks the transaction on a panic in `fn` +- `internal/database/tx.go:13-27` has no `defer tx.Rollback`. +- **Fix:** committed-flag + `defer tx.Rollback(ctx)`. + +### C4 — LOW — Cinder async state transitions have no reconciler or state guard +- `cinder/volumes.go:1621-1639` flips snapshot → `available` in a fire-and-forget + goroutine; a DB error leaves it stuck in `creating` forever. Same stub-mode pattern in + Nova. +- **Fix:** CAS transitions (like `applyVerdict`, `state_reconciler.go:209-218`) or a sweep. + +### C5 — INFO — `context.Background()` in `BuildServiceCatalog` (`keystone/auth.go:885`). + +### C6 — POSITIVE — Background lifecycle otherwise clean (all reconcilers ctx-aware, stopped on shutdown, intervals clamped). + +## 3. Correctness + +### P1 — MEDIUM — `UpdateQuotaSet` not atomic, accepts arbitrary resource keys +- `internal/cinder/quotas.go:204-238` upserts each resource separately (partial + application on failure); caller-controlled resource names persist. +- **Fix:** wrap in `database.WithTx`; validate resource keys. + +### P2 — LOW — Advisory-lock key hashing can collide +- `quotas.go:418` — `pg_advisory_xact_lock(hashtext($1))` is 32-bit. +- **Fix:** two-int4 advisory lock on a 64-bit hash. + +### P3 — LOW — Unbounded `limit` in listings (`glance/images.go:282-288` accepts `limit=1e9`). +- **Fix:** clamp to an absolute max like upstream. + +### P4 — POSITIVE — `(created_at, id)` total-order marker pagination with visibility-scoped marker resolution is done right (`images.go:328-358`). + +### P5 — MEDIUM (release-note) — Placement is a pure stub (`internal/placement/placement.go:82-101`) +- Always-empty `resource_providers`/`resource_classes`/`traits` while advertising max + microversion `1.40`. Fine for Horizon; **must be documented as not-implemented**. + +### P6 — Migration safety (060–073): all additive/idempotent; data-changing ones have justified downs. +- **Rollback caveat for v0.7.0 release notes:** a v0.6.x binary against a DB at 065+ + would write the dropped console columns — the documented rollback must be + *migrate-down first, then roll back the binary*. Worth an explicit line in + `docs/UPGRADING.md`. + +## 4. Architecture / Code Health + +- **A1 — MEDIUM** — `NetworkNamespaceManager` is dead except teardown + (`pkg/networking/netns.go:22-24`, `neutron/network.go:28,48`, `teardown.go:87`). + Intentional (legacy reclaim) but a divergence risk; document as legacy-only. +- **A2 — INFO** — `internal/nova` is ~20k lines across ~10.4k code + ~9.9k test (near 1:1 — + good); the maintenance lever is splitting `handlers.go`. +- **A3 — INFO** — Stub mode simulates async transitions with hard timers; stub tests can + pass while real mode fails. Compensated by real-mode bash tests; keep documenting. +- **A4 — INFO** — Coverage shape: unit (`-race`, DB-backed) + contract (hard 85% gate) + + bash integration + helm-unittest. No e2e job (explicit TODO `ci.yml:318`); `placement`, + `compute`, `database` have no unit tests. + +## 5. Release / Deployment Readiness + +### R1 — CRITICAL — Version stamping is broken +- `Makefile:7` passes `-ldflags "-X main.Version=$(VERSION)"` but **no `var Version` + exists** in `cmd/lightstack/main.go`. Go silently ignores `-X` for an undefined symbol — + every shipped binary is unidentifiable (no `--version`, no startup log, no + `debug.ReadBuildInfo`). +- **Fix:** declare `var Version = "dev"`, add `lightstack --version`, log at startup, + add a CI round-trip check. + +### R2 — HIGH — Tag/chart/README version drift +- `charts/lightstack/Chart.yaml`: `version: 0.3.0`, `appVersion: "0.7.0"` — no v0.7.0 + release exists; tags stop at `v0.6.1`; `v1.0.0` sits 451 commits behind HEAD as a + misleading "latest". +- **Fix:** cut a real `v0.7.0`, delete/re-aim the stale `v1.0.0`, sync README/STATUS, + bump chart `version` with appVersion aligned. + +### R3 — MEDIUM — No release CI/CD; no published image +- Only `ci.yml` + `security.yml`. Nothing builds/pushes an image or a release; + `values.yaml` `image.repository: ""` is fail-fast by design (good), but nothing + publishes an image to satisfy it. +- **Fix:** tag-triggered release workflow (goreleaser or buildx multi-arch → ghcr, + checksums/SBOM, GitHub Release, chart publish as OCI). + +### R4 — MEDIUM — Auto-migration on startup with `log.Fatalf` (`main.go:104-107`) +- Multi-replica startup can race; a dirty migration = CrashLoopBackOff. Readiness gates + until migrations finish, stretching probe windows. +- **Fix (later):** init-container/job migration in the chart; wire the existing + `MigrateDown`/force functions (`internal/database/migrate.go:81-209`) into a subcommand. + +### R5 — LOW — Postgres pin drift: CI `18.3-alpine` vs compose `18.4-alpine` vs `18-alpine`. Unify on 18.4. + +### R6 — POSITIVE — Chart hygiene is a strength (schema validation, render-time `fail()` gates, drainSeconds < terminationGracePeriod). + +## Top-10 Action List + +| # | Severity | Item | +|---|----------|------| +| 1 | Critical | R1: declare `main.Version`, expose `--version`/startup log | +| 2 | High | S2: refuse-to-start on empty/known-default JWT secret | +| 3 | High | S1: real revocation (jti + blacklist) + user-enabled check | +| 4 | High | R2: cut v0.7.0, remove stale v1.0.0, align Chart.yaml | +| 5 | Medium | R3: release CI (image publish, SBOM, chart release) | +| 6 | Medium | C1+C2: drain HTTP before service workers; bound `wg.Wait()` | +| 7 | Medium | S4: auth-endpoint rate limiter or remove dead config | +| 8 | Medium | P1: atomic + validated `UpdateQuotaSet` | +| 9 | Medium | S3: document the admin-scope model | +| 10 | Low | P3 (clamp limits), C3 (WithTx rollback), C4 (cinder state guard), R5 (pg pin), A1 (netns doc) | diff --git a/internal/common/config.go b/internal/common/config.go index 03bc1692..28bfe598 100644 --- a/internal/common/config.go +++ b/internal/common/config.go @@ -253,8 +253,27 @@ type CacheConfig struct { TTL map[string]time.Duration `yaml:"ttl"` // Per-resource TTL overrides } -// LoadConfig loads configuration from file and applies environment variable overrides +// LoadConfig loads configuration from file, applies environment variable +// overrides, and enforces the JWT-secret guard (S2): the caller runs in the +// server's trust domain — it signs or validates tokens — so a well-known or +// empty secret must be refused rather than warned about. func LoadConfig(path string) (*Config, error) { + return loadConfig(path, true) +} + +// LoadConfigForMigration loads configuration for the migration tool, which +// never signs or validates a token — it reads database.url and logging only. +// The secret guard protects against token forgery, not database access, so it +// must not gate `lightstack-migrate`: shipped deployment paths (the image +// entrypoint and the documented Kubernetes init container) run +// `lightstack-migrate up` against the canned config before any secret is +// wired into the environment. +func LoadConfigForMigration(path string) (*Config, error) { + return loadConfig(path, false) +} + +// loadConfig is the shared loader; enforceSecretGuard selects the S2 check. +func loadConfig(path string, enforceSecretGuard bool) (*Config, error) { data, err := os.ReadFile(path) if err != nil { return nil, fmt.Errorf("failed to read config file: %w", err) @@ -381,7 +400,9 @@ func LoadConfig(path string) (*Config, error) { // enough to mint an admin token for every service (review finding S2, // docs/review/comprehensive-review-report-2026-10-12.md). The chart already // fails fast on an empty secret; this gives the binary the same stance. - if isInsecureDefaultJWTSecret(cfg.Keystone.JWTSecret) && !allowInsecureDefaultJWTSecret() { + // Skipped by LoadConfigForMigration (the migration tool is outside the + // token trust domain). + if enforceSecretGuard && isInsecureDefaultJWTSecret(cfg.Keystone.JWTSecret) && !allowInsecureDefaultJWTSecret() { return nil, fmt.Errorf( "keystone.jwt_secret is empty or a well-known default — refusing to start. " + "Set keystone.jwt_secret in the config file (or the LIGHTSTACK_JWT_SECRET " + diff --git a/internal/common/config_test.go b/internal/common/config_test.go index cea62d58..ccd8795e 100644 --- a/internal/common/config_test.go +++ b/internal/common/config_test.go @@ -859,3 +859,17 @@ func TestLoadConfigAcceptsARandomSecret(t *testing.T) { t.Errorf("JWTSecret = %q; want it preserved", cfg.Keystone.JWTSecret) } } + +// TestLoadConfigForMigrationSkipsSecretGuard pins the migration tool's +// exemption: it never signs or validates a token, and shipped deployment +// paths (image entrypoint, Kubernetes init container) run it against the +// canned config before any secret is wired in. +func TestLoadConfigForMigrationSkipsSecretGuard(t *testing.T) { + cfg, err := LoadConfigForMigration(writeTestConfig(t, "database:\n url: postgres://u:p@h/l\n")) + if err != nil { + t.Fatalf("LoadConfigForMigration: %v", err) + } + if cfg.Database.URL != "postgres://u:p@h/l" { + t.Errorf("Database.URL = %q; want it preserved", cfg.Database.URL) + } +} From b504a33219442409da6c66aee49b5315b1265e97 Mon Sep 17 00:00:00 2001 From: Uwe Schwaeke Date: Mon, 12 Oct 2026 19:38:45 +0000 Subject: [PATCH 03/12] =?UTF-8?q?fix(release):=20address=20review=20round?= =?UTF-8?q?=202=20=E2=80=94=20F1/F2/F3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit F1 (HIGH, merge-blocker): the Horizon chart's bundled copy of local_settings (charts/horizon/files/) was left with _member_ — only the compose-path source was fixed. That both breaks 'make chart-test' (the horizon-chart-check step re-renders and diffs the bundled copy, so the helm-check CI job fails) and leaves the Helm/Kubernetes Horizon path unfixed entirely: the chart's ConfigMap mounts files/local_settings verbatim. Synced via 'make horizon-chart-sync' (the sync seds don't touch the role line; the only diff is _member_ -> member) and verified 'make chart-test' passes end to end (both charts lint+render+unittest, horizon files in sync). F2 (MEDIUM): the GitHub Release files glob dist/lightstack--*-* does not match the lightstack-migrate--* binaries — they were built and checksummed but never attached, and the checksums file would reference assets absent from the release. Added the migrate pattern. F3 (LOW): a bare 'docker run' of the image now requires LIGHTSTACK_JWT_SECRET (the server refuses the canned config's default — fail-closed by design). Documented above the Dockerfile CMD and in the CHANGELOG; lightstack-migrate in the entrypoint is exempt (never signs or validates a token). Verified: make chart-test PASS (helm 3.19 + helm-unittest), release.yml valid YAML; Go unit tests unaffected by this round (no Go changes). Signed-off-by: Uwe Schwaeke --- .github/workflows/release.yml | 5 ++++- CHANGELOG.md | 2 ++ build/package/Dockerfile | 8 +++++++- charts/horizon/files/local_settings | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8099adb8..c523b659 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -117,9 +117,12 @@ jobs: generate_release_notes: true # Version-scoped globs only: a bare `dist/lightstack-*` would also # absorb the chart tarball if the publish step ever moved above - # this one. + # this one. The migrate tool needs its own pattern — its files are + # prefixed lightstack-migrate--, which the main pattern does + # not match. files: | dist/lightstack-${{ github.ref_name }}-*-* + dist/lightstack-migrate-${{ github.ref_name }}-*-* dist/checksums-* - name: Publish Helm chart diff --git a/CHANGELOG.md b/CHANGELOG.md index 21dcb2cb..9f855b8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 require a real secret). `lightstack-migrate` is exempt — it never signs or validates a token, and the image entrypoint and the documented Kubernetes init container run it against the canned config before any secret is wired in. + Consequently a bare `docker run` of the image now requires `LIGHTSTACK_JWT_SECRET` + (fail-closed by design; see the comment above the Dockerfile `CMD`). - **Horizon default role** corrected: `OPENSTACK_KEYSTONE_DEFAULT_ROLE` is `member` (matches the seeded admin/member/reader roles) — was `_member_`, which matches nothing in the seed. diff --git a/build/package/Dockerfile b/build/package/Dockerfile index 73c92b04..beb25df2 100644 --- a/build/package/Dockerfile +++ b/build/package/Dockerfile @@ -100,5 +100,11 @@ LABEL org.opencontainers.image.title="Lightstack" \ org.opencontainers.image.revision=$VCS_REF \ org.opencontainers.image.version=$VERSION -# Run migrations and start Lightstack +# Run migrations and start Lightstack. +# +# Note on the JWT-secret guard (S2): the server refuses the canned config's +# well-known default secret, so a bare `docker run` of this image needs +# LIGHTSTACK_JWT_SECRET set (or LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1 +# for an isolated dev container). lightstack-migrate above is exempt — it +# never signs or validates a token. CMD ["/bin/sh", "-c", "/app/lightstack-migrate up && /app/lightstack --config /app/config/lightstack.yaml"] diff --git a/charts/horizon/files/local_settings b/charts/horizon/files/local_settings index b5604818..d26f2e4e 100644 --- a/charts/horizon/files/local_settings +++ b/charts/horizon/files/local_settings @@ -62,7 +62,7 @@ STATIC_URL = '/static/' # Lightstack Service Discovery OPENSTACK_HOST = os.environ.get("OPENSTACK_HOST", "lightstack") OPENSTACK_KEYSTONE_URL = "http://%s:35357/v3" % OPENSTACK_HOST -OPENSTACK_KEYSTONE_DEFAULT_ROLE = "_member_" +OPENSTACK_KEYSTONE_DEFAULT_ROLE = "member" # matches the seeded roles (admin/member/reader) # API Version Configuration (Lightstack Flamingo Compatible) OPENSTACK_API_VERSIONS = { From 5c423acdbc697500e92e22c1cb579adb72961f52 Mon Sep 17 00:00:00 2001 From: Uwe Schwaeke Date: Mon, 12 Oct 2026 19:44:24 +0000 Subject: [PATCH 04/12] =?UTF-8?q?fix(release):=20address=20review=20round?= =?UTF-8?q?=203=20=E2=80=94=20M-1/L-1/L-2=20+=20hardening?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit M-1 (MEDIUM): the release test gate ran 'make test' on a bare runner — no postgres service, no LIGHTSTACK_TEST_DB_URL, no -race — so every DB-backed unit test silently t.Skip()-ed, and (ci.yml triggering only on branches, not tags) the gate was the only test executed on a tag push. The test job now mirrors ci.yml's unit job: postgres:18.3-alpine service, LIGHTSTACK_TEST_DB_URL, 'go test -race', timeout-minutes 10. L-1: the dev compose stacks enabled the escape hatch unconditionally — even an operator passing a real LIGHTSTACK_JWT_SECRET ran with the guard off. Now ${LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET:-true}: still ON by default for dev UX, but settable to false/0 to re-arm the guard. L-2: dist/ (release workflow output) was in neither .gitignore nor .dockerignore — host-built binaries were dragged into the docker build context and at risk of being committed. Added to both. Hardening from the review's INFO items: - job-scoped permissions: test gate now contents:read only; the publishing job keeps contents+packages write - concurrency group per tag (cancel-in-progress) so a re-pushed tag cannot run two release pipelines in parallel - timeout-minutes 30 on the release job - corrected the release-files glob comment (checksums-* is not tag-scoped, though it can only match checksum files) make test: PASS (all unit tests, race detector); all three touched YAML files parse cleanly. Signed-off-by: Uwe Schwaeke --- .dockerignore | 2 + .github/workflows/release.yml | 52 +++++++++++++++++++++----- .gitignore | 2 + deployments/docker-compose.yml | 4 +- deployments/docker/docker-compose.yaml | 4 +- 5 files changed, 53 insertions(+), 11 deletions(-) diff --git a/.dockerignore b/.dockerignore index be8ccb1e..f464dcf5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -8,6 +8,8 @@ .git/ .gitignore bin/ +# Release workflow output — built fresh inside the image, never from context +dist/ *.exe *.test *.out diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c523b659..a22f3ddc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,9 +17,15 @@ on: tags: - 'v*' +# A re-pushed tag must not run two release pipelines in parallel. +concurrency: + group: release-${{ github.ref }} + cancel-in-progress: true + +# Least privilege: the test gate only needs to read the repo; only the +# publishing job needs to write releases and packages. permissions: - contents: write - packages: write + contents: read env: GO_VERSION: '1.27.2' @@ -28,18 +34,44 @@ jobs: test: name: Test gate runs-on: ubuntu-latest + timeout-minutes: 10 + # Parity with the CI unit job (ci.yml): the same postgres service and + # LIGHTSTACK_TEST_DB_URL, so DB-backed unit tests run instead of + # silently t.Skip()-ing — this gate is the only test executed on a tag + # push (ci.yml triggers on branches, not tags), so it must not be weaker + # than what protected the branch the tag was cut from. -race likewise. + services: + postgres: + image: postgres:18.3-alpine + env: + POSTGRES_USER: lightstack + POSTGRES_PASSWORD: secret + POSTGRES_DB: lightstack_test + ports: + - 5432:5432 + options: >- + --health-cmd "pg_isready -U lightstack -d lightstack_test" + --health-interval 5s + --health-timeout 5s + --health-retries 10 steps: - uses: actions/checkout@v6 - uses: actions/setup-go@v6 with: go-version: ${{ env.GO_VERSION }} - - name: Run unit tests - run: make test + - name: Run unit tests with race detector + run: go test -race $(go list ./... | grep -v '/test/contract') + env: + LIGHTSTACK_TEST_DB_URL: postgres://lightstack:secret@localhost:5432/lightstack_test?sslmode=disable release: name: Build and publish runs-on: ubuntu-latest needs: test + timeout-minutes: 30 + permissions: + contents: write + packages: write steps: - uses: actions/checkout@v6 @@ -115,11 +147,13 @@ jobs: with: draft: true generate_release_notes: true - # Version-scoped globs only: a bare `dist/lightstack-*` would also - # absorb the chart tarball if the publish step ever moved above - # this one. The migrate tool needs its own pattern — its files are - # prefixed lightstack-migrate--, which the main pattern does - # not match. + # Scoped globs: the binary patterns carry the tag so a bare + # `dist/lightstack-*` (which would also absorb the chart tarball if + # the publish step ever moved above this one) is avoided. The + # migrate tool needs its own pattern — its files are prefixed + # lightstack-migrate--, which the main pattern does not match. + # The checksums glob is not tag-scoped, but checksums- files are the + # only things it can match. files: | dist/lightstack-${{ github.ref_name }}-*-* dist/lightstack-migrate-${{ github.ref_name }}-*-* diff --git a/.gitignore b/.gitignore index 3ac69b33..6bd5b419 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ # Binaries bin/ +# Release workflow output (binaries, checksums, packaged chart) +dist/ *.exe *.dll *.so diff --git a/deployments/docker-compose.yml b/deployments/docker-compose.yml index 99964137..6fc8c620 100644 --- a/deployments/docker-compose.yml +++ b/deployments/docker-compose.yml @@ -70,7 +70,9 @@ services: # guests, tokens never leave the host — so the escape hatch is # acceptable here. NEVER set it where real guests or foreign clients # reach the services: pass a real LIGHTSTACK_JWT_SECRET instead. - LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET: "true" + # Defaults ON for dev but is overridable: when you pass a real + # LIGHTSTACK_JWT_SECRET, set this to false/0 to re-arm the guard. + LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET: "${LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET:-true}" LIGHTSTACK_ENDPOINT_HOST: "localhost" # Use localhost for service catalog URLs (accessible from host) # Why this exists: tests run outside any guest, so they name the instance they ask # the metadata service about with the X-Instance-ID header (test/contract/ws4_*, diff --git a/deployments/docker/docker-compose.yaml b/deployments/docker/docker-compose.yaml index 968de50a..fe3572ad 100644 --- a/deployments/docker/docker-compose.yaml +++ b/deployments/docker/docker-compose.yaml @@ -41,7 +41,9 @@ services: # secret above unless this is set (review S2). This stack is for local # stub-mode development — NEVER set it where real guests or foreign # clients reach the services: pass a real LIGHTSTACK_JWT_SECRET instead. - LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET: "true" + # Defaults ON for dev but is overridable: when you pass a real + # LIGHTSTACK_JWT_SECRET, set this to false/0 to re-arm the guard. + LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET: "${LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET:-true}" volumes: # For libvirt access (if running on same host) - /var/run/libvirt:/var/run/libvirt:ro From 44ab8938d6e546f27f4a16c048ac9df486fcaf51 Mon Sep 17 00:00:00 2001 From: Uwe Schwaeke Date: Mon, 12 Oct 2026 19:49:07 +0000 Subject: [PATCH 05/12] docs(release): clarify two workflow comments from final review round MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - header: chart appVersion is the bare version (no leading v), matching the image tag — the inline comment already said so, the header didn't - chart publish step: note that the chart lands in the org-level charts OCI namespace and relies on GITHUB_TOKEN packages:write covering it Final review round verdict: CLEAN (no Critical/High/Medium/Low correctness findings; these were informational notes on comment wording). Signed-off-by: Uwe Schwaeke --- .github/workflows/release.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a22f3ddc..1ebfd00c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,8 @@ # sits behind the `ceph` build tag, so cross-compilation needs no cgo) # 2. a multi-arch container image pushed to ghcr.io # 3. a GitHub Release with the binaries and their checksums -# 4. the Helm chart published as an OCI artifact (appVersion = the tag) +# 4. the Helm chart published as an OCI artifact (appVersion = the bare +# release version, no leading "v" — same as the image tag) # # Version stamping contract (review R1): the tag is injected with # `-ldflags "-X main.Version="` and round-tripped through @@ -173,3 +174,7 @@ jobs: -u "${{ github.actor }}" --password-stdin helm push "dist/lightstack-${CHART_VERSION}.tgz" \ "oci://ghcr.io/${{ github.repository_owner }}/charts" + # Note: the chart lands in the org-level `charts` OCI namespace + # (ghcr.io//charts/lightstack), not the repo-scoped image + # namespace — the GITHUB_TOKEN's packages:write covers it as long + # as the org allows this repo to write org packages. From 62cc2c4e07d045631ccffa8795a1fdfff96cdd64 Mon Sep 17 00:00:00 2001 From: Uwe Schwaeke Date: Tue, 13 Oct 2026 12:56:43 +0000 Subject: [PATCH 06/12] fix(release): address review round on the release foundation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Comprehensive-review follow-ups on this branch's own diff: - Secret guard: case-insensitive, whitespace-trimmed matching — the uppercase 'CHANGE-ME-IN-PRODUCTION' shipped in README-KVM.md was accepted (that example now generates a per-deployment secret, and its placeholder string is denylisted too). - Secret guard: also refuse a well-known/empty keystone.admin_password whenever an admin account is configured — admin/secret is public and authenticates as the bootstrap admin directly. New LIGHTSTACK_ADMIN_PASSWORD env override (mirroring LIGHTSTACK_JWT_SECRET) keeps the bare 'docker run' path workable; the Dockerfile CMD comment and the docs env-var table now say so. - CLI subcommands (cleanup, console-tokens) route through the unguarded loader like lightstack-migrate: they run on the server's host, whose config is only valid because the server's own process carries the escape hatch. - 'lightstack migrate' subcommand: deploy/upgrade scripts have always called it; the positional previously fell through to flag parsing and started the server instead of migrating. --dry-run prints 'No migrations to run' — the exact string upgrade-lightstack.sh greps. - Release workflow: lint, render and unit-test the charts (make chart-test — the same gate CI runs on PRs) before 'helm push', which cannot be undone. - Makefile .PHONY covers every target; guard tests are hermetic against a developer shell's exported LIGHTSTACK_JWT_SECRET / hatch, and pin the new admin-password behavior and the CLI exemption. Signed-off-by: Uwe Schwaeke --- .github/workflows/release.yml | 20 ++++++ CHANGELOG.md | 28 ++++++-- Makefile | 2 +- build/package/Dockerfile | 8 ++- cmd/lightstack/main.go | 89 ++++++++++++++++++++++-- deployments/README-KVM.md | 4 +- docs/CONFIGURATION.md | 1 + internal/common/config.go | 101 ++++++++++++++++++++++------ internal/common/config_test.go | 108 +++++++++++++++++++++++++++++- internal/database/migrate.go | 32 +++++++++ internal/database/migrate_test.go | 40 +++++++++++ 11 files changed, 394 insertions(+), 39 deletions(-) create mode 100644 internal/database/migrate_test.go diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1ebfd00c..2c50af39 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -160,6 +160,26 @@ jobs: dist/lightstack-migrate-${{ github.ref_name }}-*-* dist/checksums-* + # The same validation CI runs on every PR (the helm-check job): lint, + # render and unit-test both charts. The release must not publish a + # chart that CI would have rejected — helm push cannot be undone. + - name: Install Helm and the helm-unittest plugin + run: | + if ! command -v helm >/dev/null 2>&1; then + # Downloaded, not piped: the default run shell is `bash -e` without + # pipefail, so `curl ... | bash` would swallow a failed download. + curl -fsSL -o "$RUNNER_TEMP/get-helm-3" \ + https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 + bash "$RUNNER_TEMP/get-helm-3" + fi + if ! helm plugin list 2>/dev/null | grep -q '^unittest'; then + helm plugin install https://github.com/helm-unittest/helm-unittest + fi + helm version --short + + - name: Validate Helm charts before publishing + run: make chart-test + - name: Publish Helm chart env: GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f855b8e..6cfa0541 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,19 +22,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 `ghcr.io` (tagged with the bare version — `0.7.0` — matching the chart's `appVersion` and the `image.tag` default), creates a draft GitHub Release and publishes the Helm chart as an OCI artifact with `appVersion` pinned to the - release version. + release version. The charts are linted, rendered and unit-tested (`make + chart-test`, the same gate CI runs on PRs) before `helm push` — a published + chart cannot be unpublished. +- **`lightstack migrate` subcommand** (review round follow-up): applies pending + database migrations and exits, with `--dry-run` reporting pending ones + ("No migrations to run" when current). `scripts/deploy-single-node.sh` and + `scripts/upgrade-lightstack.sh` have always called it — previously the + positional fell through to flag parsing and started the server instead of + migrating. - **Chart version** 0.3.0 → 0.4.0 (appVersion 0.7.0, matching the target release). ### 🔒 Security - **Refuse well-known/empty JWT secrets at startup** (review S2): the defaults shipped in `config/lightstack.yaml` and `.env.example` are public, and with stateless tokens knowing one is enough to mint an admin token. `LoadConfig` now - refuses them; `LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1` is the documented + refuses them — case-insensitively and ignoring surrounding whitespace, so the + uppercase spelling in `deployments/README-KVM.md` is caught too (that example + now generates a per-deployment secret instead). It also refuses a well-known + or empty `keystone.admin_password` whenever an admin account is configured — + `admin`/`secret` authenticates as the bootstrap admin directly. A + `LIGHTSTACK_ADMIN_PASSWORD` environment override (mirroring + `LIGHTSTACK_JWT_SECRET`) lets `docker run` inject the real password without + mounting a config. + `LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1` is the documented escape hatch for isolated dev/test stacks (the plain docker-compose dev stacks and `make run` opt in explicitly; the Horizon stack and the Helm chart already - require a real secret). `lightstack-migrate` is exempt — it never signs or - validates a token, and the image entrypoint and the documented Kubernetes init - container run it against the canned config before any secret is wired in. + require a real secret). `lightstack-migrate` and the operational CLI + subcommands (`cleanup`, `console-tokens`, `migrate`) are exempt — they never + sign or validate a token, and the image entrypoint and the documented + Kubernetes init container run migrations against the canned config before any + secret is wired in. Consequently a bare `docker run` of the image now requires `LIGHTSTACK_JWT_SECRET` (fail-closed by design; see the comment above the Dockerfile `CMD`). - **Horizon default role** corrected: `OPENSTACK_KEYSTONE_DEFAULT_ROLE` is `member` diff --git a/Makefile b/Makefile index 3c49710e..c6262a23 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build run test lint chart-test test-endpoint-migration test-compose-identity clean install-deps install-tools migrate db-up db-down build-ebpf bench bench-quick horizon-chart-sync horizon-chart-check test-horizon-ui +.PHONY: build build-with-ebpf run test test-contract test-integration test-multi-tenant test-performance test-errors test-all lint chart-test test-endpoint-migration test-compose-identity clean dev fmt install-deps install-tools migrate db-up db-down build-ebpf bench bench-quick horizon-chart-sync horizon-chart-check test-horizon-ui install-ebpf-tools help # Build variables BINARY_NAME=lightstack diff --git a/build/package/Dockerfile b/build/package/Dockerfile index beb25df2..3844c8c3 100644 --- a/build/package/Dockerfile +++ b/build/package/Dockerfile @@ -102,9 +102,11 @@ LABEL org.opencontainers.image.title="Lightstack" \ # Run migrations and start Lightstack. # -# Note on the JWT-secret guard (S2): the server refuses the canned config's -# well-known default secret, so a bare `docker run` of this image needs -# LIGHTSTACK_JWT_SECRET set (or LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1 +# Note on the secret guard (S2): the server refuses the canned config's +# well-known defaults — both the JWT secret and the bootstrap admin password +# ("admin"/"secret", which is public and authenticates as the admin directly). +# A bare `docker run` of this image therefore needs LIGHTSTACK_JWT_SECRET and +# LIGHTSTACK_ADMIN_PASSWORD set (or LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1 # for an isolated dev container). lightstack-migrate above is exempt — it # never signs or validates a token. CMD ["/bin/sh", "-c", "/app/lightstack-migrate up && /app/lightstack --config /app/config/lightstack.yaml"] diff --git a/cmd/lightstack/main.go b/cmd/lightstack/main.go index bf051047..45feb2ed 100644 --- a/cmd/lightstack/main.go +++ b/cmd/lightstack/main.go @@ -67,6 +67,15 @@ func main() { os.Exit(runHealthcheck(os.Args[2:])) } + // `lightstack migrate` applies pending database migrations and exits. The + // deploy and upgrade scripts call exactly this (scripts/deploy-single-node.sh, + // scripts/upgrade-lightstack.sh) — before it existed, the "migrate" + // positional fell through to flag parsing and silently started the server + // instead of migrating. + if len(os.Args) > 1 && os.Args[1] == "migrate" { + os.Exit(runMigrate(os.Args[2:])) + } + // `lightstack console-tokens list|purge` inspects and revokes noVNC console tokens // (SPEC-021). The projection files under /var/lib/lightstack/console-tokens are // readable by hand, but they carry no expiry or ownership — both live in the @@ -472,13 +481,71 @@ func main() { log.Println("Lightstack stopped") } +// runMigrate executes the `lightstack migrate` subcommand: apply pending +// database migrations and exit, without starting the server — the entry point +// the deploy and upgrade scripts use. `--dry-run` reports pending migrations +// on stdout (printing "No migrations to run" when the schema is current, the +// exact string scripts/upgrade-lightstack.sh greps for). Exit codes: 0 +// success or nothing to do, 1 migration or status failure, 2 usage or config +// error. +func runMigrate(args []string) int { + fs := flag.NewFlagSet("migrate", flag.ContinueOnError) + cfgPath := fs.String("config", "config/lightstack.yaml", "Path to configuration file") + migrationsDir := fs.String("migrations", "migrations", "Path to migrations directory") + dryRun := fs.Bool("dry-run", false, "Report pending migrations without applying them") + if err := fs.Parse(args); err != nil { + if errors.Is(err, flag.ErrHelp) { + return 0 + } + return 2 + } + + cfg, err := loadConfigForCLI(*cfgPath) + if err != nil { + fmt.Fprintf(os.Stderr, "migrate: failed to load config: %v\n", err) + return 2 + } + middleware.InitLogger(&cfg.Logging) + + if *dryRun { + status, err := database.GetMigrationStatus(cfg.Database.URL, *migrationsDir) + if err != nil { + fmt.Fprintf(os.Stderr, "migrate: %v\n", err) + return 1 + } + if status.Dirty { + fmt.Fprintln(os.Stderr, "migrate: database is dirty; manual intervention required") + return 1 + } + latest, err := database.LatestSourceMigrationVersion(*migrationsDir) + if err != nil { + fmt.Fprintf(os.Stderr, "migrate: %v\n", err) + return 1 + } + if status.Version >= latest { + fmt.Println("No migrations to run") + return 0 + } + fmt.Printf("%d pending migration(s) (current %d, latest %d)\n", latest-status.Version, status.Version, latest) + return 0 + } + + if err := database.MigrateUp(cfg.Database.URL, *migrationsDir); err != nil { + fmt.Fprintf(os.Stderr, "migrate: %v\n", err) + return 1 + } + return 0 +} + // runCleanup executes the `lightstack cleanup` subcommand: the SPEC-010 release teardown // (issue #53). Exit codes: 0 success, 1 a required class could not be purged // (fail-closed — the blocking pre-delete hook then aborts uninstall), 2 usage or // config error. -// loadConfig loads the config and applies state_path as the node-local root. Every -// entry point goes through here — the server, cleanup and console-tokens — so a -// subcommand can never act on a different root than the server it serves. +// loadConfig loads the config and applies state_path as the node-local root. +// The server goes through here — the guarded path, since it signs and +// validates tokens. Every subcommand goes through loadConfigForCLI, which +// applies the same root so it can never act on a different root than the +// server it serves. func loadConfig(path string) (*common.Config, error) { cfg, err := common.LoadConfig(path) if err != nil { @@ -488,6 +555,18 @@ func loadConfig(path string) (*common.Config, error) { return cfg, nil } +// loadConfigForCLI is loadConfig without the secret guard: the CLI +// subcommands (cleanup, console-tokens, migrate) neither sign nor validate +// tokens (see common.LoadConfigForCLI). +func loadConfigForCLI(path string) (*common.Config, error) { + cfg, err := common.LoadConfigForCLI(path) + if err != nil { + return nil, err + } + paths.SetBase(cfg.StatePath) + return cfg, nil +} + // newPoolConfig builds the pgx pool settings, substituting defaults for anything // the config file omits or sets to a non-positive value. // @@ -556,7 +635,7 @@ func runConsoleTokens(args []string) int { return console.RunCLI(context.Background(), nil, rest, os.Stdout, os.Stderr) } - cfg, err := loadConfig(*cfgPath) + cfg, err := loadConfigForCLI(*cfgPath) if err != nil { fmt.Fprintf(os.Stderr, "console-tokens: failed to load config: %v\n", err) return 2 @@ -592,7 +671,7 @@ func runCleanup(args []string) { os.Exit(2) } - cfg, err := loadConfig(*cfgPath) + cfg, err := loadConfigForCLI(*cfgPath) if err != nil { fmt.Fprintf(os.Stderr, "cleanup: failed to load config: %v\n", err) os.Exit(2) diff --git a/deployments/README-KVM.md b/deployments/README-KVM.md index 553c4269..c1e0764a 100644 --- a/deployments/README-KVM.md +++ b/deployments/README-KVM.md @@ -36,7 +36,9 @@ database: keystone: host: "0.0.0.0" port: 35357 - jwt_secret: "CHANGE-ME-IN-PRODUCTION" + # Generate per deployment: `openssl rand -base64 32`. A well-known default + # (including this comment's old placeholder) is refused at startup. + jwt_secret: "PASTE-OUTPUT-OF-openssl-rand-base64-32" token_ttl: 24h nova: diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index a26bf783..ba48df7b 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -140,6 +140,7 @@ The binary honors exactly **fourteen** environment variables: |----------|----------------------|------------------| | `LIGHTSTACK_DB_URL` | `database.url` | `internal/common/config.go` (`LoadConfig`) | | `LIGHTSTACK_JWT_SECRET` | `keystone.jwt_secret` | `internal/common/config.go` (`LoadConfig`) | +| `LIGHTSTACK_ADMIN_PASSWORD` | `keystone.admin_password` (the bootstrap admin's password; refused when left at a well-known default — see the S2 secret guard) | `internal/common/config.go` (`LoadConfig`) | | `LIGHTSTACK_KEYSTONE_RGW_COMPAT_TENANT_IDS` | `keystone.rgw_compat_tenant_ids`. Two-way boolean: `true`/`1` turns it **on** over a config file that shipped it off; `false`/`0` turns it **off** against a config file that shipped it on. Renders `token.project.id` in OpenStack's dash-free form in the `/v3/auth/tokens` responses; `/v3/s3tokens` already uses that historical form. The EC2 mint accepts dash-free or alternate UUID encodings as input and stores the canonical database id. Enabling the flag therefore unifies Swift with the existing S3 tenant namespace without re-keying S3 data. | `internal/common/config.go` (`LoadConfig`) | | `LIGHTSTACK_ENDPOINT_HOST` | advertised catalog / self-link host — a **fallback**, see below | request time (`internal/keystone/auth.go`, `internal/common/baseurl.go`) | | `LIGHTSTACK_ENDPOINT_SCHEME` | advertised URL scheme: `http` (default) or `https` | request time (`internal/common/scheme.go`) | diff --git a/internal/common/config.go b/internal/common/config.go index 28bfe598..aed51479 100644 --- a/internal/common/config.go +++ b/internal/common/config.go @@ -272,6 +272,15 @@ func LoadConfigForMigration(path string) (*Config, error) { return loadConfig(path, false) } +// LoadConfigForCLI loads configuration for the operational CLI subcommands +// (cleanup, console-tokens, migrate). Like the migration tool they neither +// sign nor validate tokens, and they are typically run on the same host as +// the server — whose own config is only valid because the server's process +// carries the escape hatch. The guard must not refuse them there. +func LoadConfigForCLI(path string) (*Config, error) { + return loadConfig(path, false) +} + // loadConfig is the shared loader; enforceSecretGuard selects the S2 check. func loadConfig(path string, enforceSecretGuard bool) (*Config, error) { data, err := os.ReadFile(path) @@ -291,6 +300,13 @@ func loadConfig(path string, enforceSecretGuard bool) (*Config, error) { if jwtSecret := os.Getenv("LIGHTSTACK_JWT_SECRET"); jwtSecret != "" { cfg.Keystone.JWTSecret = jwtSecret } + // The bootstrap admin password (seeds the admin account on first start; + // see internal/keystone BootstrapAdmin). Same read-only-mount rationale + // as LIGHTSTACK_JWT_SECRET — the container image ships the canned config, + // so `docker run` needs to inject both secrets through the environment. + if adminPassword := os.Getenv("LIGHTSTACK_ADMIN_PASSWORD"); adminPassword != "" { + cfg.Keystone.AdminPassword = adminPassword + } // Ceph RGW compatibility (keystone.rgw_compat_tenant_ids). Two-way override: // an operator must be able to flip it from the env in either direction when // the config file is mounted read-only, matching the Glance S3 boolean @@ -394,21 +410,39 @@ func loadConfig(path string, enforceSecretGuard bool) (*Config, error) { cfg.Nova.ShutdownTimeout = MaxShutdownTimeout } - // Refuse well-known (or empty) JWT secrets unless explicitly overridden. - // The defaults below ship in this repository and in .env.example, so anyone - // can read them — and because tokens are stateless, knowing the secret is - // enough to mint an admin token for every service (review finding S2, - // docs/review/comprehensive-review-report-2026-10-12.md). The chart already - // fails fast on an empty secret; this gives the binary the same stance. - // Skipped by LoadConfigForMigration (the migration tool is outside the - // token trust domain). - if enforceSecretGuard && isInsecureDefaultJWTSecret(cfg.Keystone.JWTSecret) && !allowInsecureDefaultJWTSecret() { - return nil, fmt.Errorf( - "keystone.jwt_secret is empty or a well-known default — refusing to start. " + - "Set keystone.jwt_secret in the config file (or the LIGHTSTACK_JWT_SECRET " + - "environment variable) to a random value, e.g. `openssl rand -base64 32`. " + - "For isolated development or test environments only, " + - "LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1 opts out of this check") + // Refuse well-known (or empty) JWT secrets and admin passwords unless + // explicitly overridden. The defaults below ship in this repository and in + // .env.example, so anyone can read them — and because tokens are stateless, + // knowing the JWT secret is enough to mint an admin token for every service + // (review finding S2, docs/review/comprehensive-review-report-2026-10-12.md), + // while knowing the bootstrap admin password authenticates as that admin + // directly. The chart already fails fast on an empty secret; this gives the + // binary the same stance. Matching is case-insensitive and whitespace- + // trimmed: a "CHANGE-ME-IN-PRODUCTION" in deployments/README-KVM.md must be + // caught just like the lowercase original. Skipped by LoadConfigForMigration + // and LoadConfigForCLI (both are outside the token trust domain). + if enforceSecretGuard && !insecureDefaultSecretOptOut() { + if isInsecureDefaultSecret(cfg.Keystone.JWTSecret, insecureDefaultJWTSecrets) { + return nil, fmt.Errorf( + "keystone.jwt_secret is empty or a well-known default — refusing to start. " + + "Set keystone.jwt_secret in the config file (or the LIGHTSTACK_JWT_SECRET " + + "environment variable) to a random value, e.g. `openssl rand -base64 32`. " + + "For isolated development or test environments only, " + + "LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1 opts out of this check") + } + // Only enforced when an admin account is actually configured: minimal + // test fixtures legitimately omit both fields (no account is seeded). + if cfg.Keystone.AdminUser != "" || cfg.Keystone.AdminPassword != "" { + if isInsecureDefaultSecret(cfg.Keystone.AdminPassword, insecureDefaultAdminPasswords) { + return nil, fmt.Errorf( + "keystone.admin_password is empty or a well-known default — refusing to start. " + + "Set keystone.admin_password in the config file (or the " + + "LIGHTSTACK_ADMIN_PASSWORD environment variable) to a random value " + + "(it seeds the bootstrap admin account). For isolated development or " + + "test environments only, LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1 " + + "opts out of this check") + } + } } return &cfg, nil @@ -421,16 +455,41 @@ var insecureDefaultJWTSecrets = map[string]struct{}{ "": {}, "change-me-in-production": {}, "change-me-in-production-use-openssl-rand-base64-32": {}, + // deployments/README-KVM.md's example placeholder — copy-pasting the doc + // verbatim must be caught like the config file's own default. + "paste-output-of-openssl-rand-base64-32": {}, } -func isInsecureDefaultJWTSecret(secret string) bool { - _, known := insecureDefaultJWTSecrets[secret] - return known +// insecureDefaultAdminPasswords are the well-known bootstrap-admin passwords +// shipped in this repository (config/lightstack.yaml: "secret") and left by +// operators who never changed it. Empty is refused when an admin user is +// configured — the seeded account would authenticate with an empty password. +var insecureDefaultAdminPasswords = map[string]struct{}{ + "": {}, + "secret": {}, +} + +// isInsecureDefaultSecret reports whether secret is in the well-known-default +// denylist, ignoring case and surrounding whitespace (docs have shipped the +// uppercase spelling of the same placeholders). +func isInsecureDefaultSecret(secret string, known map[string]struct{}) bool { + trimmed := strings.ToLower(strings.TrimSpace(secret)) + if _, ok := known[trimmed]; ok { + return true + } + for candidate := range known { + if strings.ToLower(candidate) == trimmed { + return true + } + } + return false } -// allowInsecureDefaultJWTSecret is the documented escape hatch for stub-mode -// development and test stacks that never validate a foreign token. -func allowInsecureDefaultJWTSecret() bool { +// insecureDefaultSecretOptOut is the documented escape hatch for stub-mode +// development and test stacks that never validate a foreign token and never +// face an untrusted network. It opts out of both the JWT-secret and the +// admin-password checks. +func insecureDefaultSecretOptOut() bool { switch os.Getenv("LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET") { case "1", "true": return true diff --git a/internal/common/config_test.go b/internal/common/config_test.go index ccd8795e..f26003aa 100644 --- a/internal/common/config_test.go +++ b/internal/common/config_test.go @@ -35,7 +35,7 @@ keystone: jwt_secret: "test-secret" token_ttl: 24h admin_user: "admin" - admin_password: "secret" + admin_password: "test-admin-password" nova: port: 8774 @@ -810,14 +810,28 @@ func writeTestConfig(t *testing.T, body string) string { return tmp.Name() } +// hermeticGuardEnv neutralizes secret-related environment a developer shell +// may carry (LIGHTSTACK_JWT_SECRET, the opt-out hatch), so the guard tests +// observe the config file and nothing else. +func hermeticGuardEnv(t *testing.T) { + t.Helper() + t.Setenv("LIGHTSTACK_JWT_SECRET", "") + t.Setenv("LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET", "") +} + // TestLoadConfigRefusesInsecureDefaultJWTSecret pins the S2 guard: the secrets // shipped in this repository's config and examples are public, and tokens are // stateless — knowing one is enough to mint an admin token for every service. +// Case variants and surrounding whitespace are refused too: the uppercase +// spelling shipped in deployments/README-KVM.md is the same placeholder. func TestLoadConfigRefusesInsecureDefaultJWTSecret(t *testing.T) { + hermeticGuardEnv(t) for _, secret := range []string{ "", // omitted from the file "change-me-in-production", // config/lightstack.yaml "change-me-in-production-use-openssl-rand-base64-32", // .env.example + "CHANGE-ME-IN-PRODUCTION", // deployments/README-KVM.md + " change-me-in-production ", } { body := "keystone:\n jwt_secret: \"" + secret + "\"\n" _, err := LoadConfig(writeTestConfig(t, body)) @@ -831,19 +845,73 @@ func TestLoadConfigRefusesInsecureDefaultJWTSecret(t *testing.T) { } } +// TestLoadConfigRefusesInsecureDefaultAdminPassword pins the admin half of +// the guard: config/lightstack.yaml ships admin_password "secret", which is +// public and authenticates as the bootstrap admin directly. Empty is refused +// whenever an admin account is configured (the seeded account would accept an +// empty password); a config that omits both admin fields seeds no account and +// must keep loading (the minimal fixtures above the guard tests rely on it). +func TestLoadConfigRefusesInsecureDefaultAdminPassword(t *testing.T) { + hermeticGuardEnv(t) + const goodSecret = "k4FNxqKmLwW3ZRFvMscJ0d1oO5gYhN" + for _, tc := range []struct { + name string + password string + }{ + {"shipped default", "secret"}, + {"uppercase default", "SECRET"}, + {"padded default", " secret "}, + {"empty with a user", ""}, + } { + t.Run(tc.name, func(t *testing.T) { + body := "keystone:\n jwt_secret: \"" + goodSecret + "\"\n admin_user: admin\n admin_password: \"" + tc.password + "\"\n" + _, err := LoadConfig(writeTestConfig(t, body)) + if err == nil { + t.Fatalf("LoadConfig accepted admin_password %q; want refusal", tc.password) + } + if !strings.Contains(err.Error(), "admin_password") { + t.Errorf("error does not name admin_password: %v", err) + } + }) + } + + // Both admin fields omitted: no account is seeded, no credentials to + // guard — must keep loading (this is what every minimal fixture looks + // like). + if _, err := LoadConfig(writeTestConfig(t, "keystone:\n jwt_secret: \""+goodSecret+"\"\n")); err != nil { + t.Errorf("LoadConfig without admin fields: %v; want acceptance", err) + } + + // A random password with a random secret: the positive control. + body := "keystone:\n jwt_secret: \"" + goodSecret + "\"\n admin_user: admin\n admin_password: \"T3st-Not-The-Shipped-Default\"\n" + cfg, err := LoadConfig(writeTestConfig(t, body)) + if err != nil { + t.Fatalf("LoadConfig with a random admin password: %v", err) + } + if cfg.Keystone.AdminPassword != "T3st-Not-The-Shipped-Default" { + t.Errorf("AdminPassword = %q; want it preserved", cfg.Keystone.AdminPassword) + } +} + // TestLoadConfigAllowsInsecureDefaultSecretWithOverride pins the documented -// escape hatch for isolated development and test stacks. +// escape hatch for isolated development and test stacks — for both halves of +// the guard. func TestLoadConfigAllowsInsecureDefaultSecretWithOverride(t *testing.T) { + hermeticGuardEnv(t) // a developer shell's LIGHTSTACK_JWT_SECRET must not leak in for _, opt := range []string{"1", "true"} { t.Run("opt="+opt, func(t *testing.T) { t.Setenv("LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET", opt) - cfg, err := LoadConfig(writeTestConfig(t, "keystone:\n jwt_secret: \"change-me-in-production\"\n")) + cfg, err := LoadConfig(writeTestConfig(t, + "keystone:\n jwt_secret: \"change-me-in-production\"\n admin_user: admin\n admin_password: \"secret\"\n")) if err != nil { t.Fatalf("LoadConfig with override %q: %v", opt, err) } if cfg.Keystone.JWTSecret != "change-me-in-production" { t.Errorf("JWTSecret = %q; want it passed through unchanged", cfg.Keystone.JWTSecret) } + if cfg.Keystone.AdminPassword != "secret" { + t.Errorf("AdminPassword = %q; want it passed through unchanged", cfg.Keystone.AdminPassword) + } }) } } @@ -851,6 +919,7 @@ func TestLoadConfigAllowsInsecureDefaultSecretWithOverride(t *testing.T) { // TestLoadConfigAcceptsARandomSecret is the positive control for the guard: a // non-default secret loads without any opt-in. func TestLoadConfigAcceptsARandomSecret(t *testing.T) { + hermeticGuardEnv(t) cfg, err := LoadConfig(writeTestConfig(t, "keystone:\n jwt_secret: \"k4FNxqKmLwW3ZRFvMscJ0d1oO5gYhN\"\n")) if err != nil { t.Fatalf("LoadConfig: %v", err) @@ -865,6 +934,7 @@ func TestLoadConfigAcceptsARandomSecret(t *testing.T) { // paths (image entrypoint, Kubernetes init container) run it against the // canned config before any secret is wired in. func TestLoadConfigForMigrationSkipsSecretGuard(t *testing.T) { + hermeticGuardEnv(t) cfg, err := LoadConfigForMigration(writeTestConfig(t, "database:\n url: postgres://u:p@h/l\n")) if err != nil { t.Fatalf("LoadConfigForMigration: %v", err) @@ -873,3 +943,35 @@ func TestLoadConfigForMigrationSkipsSecretGuard(t *testing.T) { t.Errorf("Database.URL = %q; want it preserved", cfg.Database.URL) } } + +// TestLoadConfigAdminPasswordEnvOverride pins the container path: the image +// ships the canned config (admin_password "secret"), so `docker run` injects +// the real password through the environment like the JWT secret. +func TestLoadConfigAdminPasswordEnvOverride(t *testing.T) { + hermeticGuardEnv(t) + t.Setenv("LIGHTSTACK_ADMIN_PASSWORD", "injected-through-env") + body := "keystone:\n jwt_secret: \"k4FNxqKmLwW3ZRFvMscJ0d1oO5gYhN\"\n admin_user: admin\n admin_password: \"secret\"\n" + cfg, err := LoadConfig(writeTestConfig(t, body)) + if err != nil { + t.Fatalf("LoadConfig with LIGHTSTACK_ADMIN_PASSWORD: %v", err) + } + if cfg.Keystone.AdminPassword != "injected-through-env" { + t.Errorf("AdminPassword = %q; want the env value", cfg.Keystone.AdminPassword) + } +} + +// TestLoadConfigForCLISkipsSecretGuard pins the CLI subcommands' exemption +// (cleanup, console-tokens, migrate): they run on the same host as the +// server, whose config is only valid because the server's own process +// carries the escape hatch — the guard must not refuse them there. +func TestLoadConfigForCLISkipsSecretGuard(t *testing.T) { + hermeticGuardEnv(t) + body := "database:\n url: postgres://u:p@h/l\nkeystone:\n jwt_secret: \"change-me-in-production\"\n admin_user: admin\n admin_password: \"secret\"\n" + cfg, err := LoadConfigForCLI(writeTestConfig(t, body)) + if err != nil { + t.Fatalf("LoadConfigForCLI: %v", err) + } + if cfg.Keystone.JWTSecret != "change-me-in-production" { + t.Errorf("JWTSecret = %q; want it preserved", cfg.Keystone.JWTSecret) + } +} diff --git a/internal/database/migrate.go b/internal/database/migrate.go index b5caede0..b9823ca3 100644 --- a/internal/database/migrate.go +++ b/internal/database/migrate.go @@ -3,6 +3,8 @@ package database import ( "fmt" "os" + "strconv" + "strings" "github.com/golang-migrate/migrate/v4" _ "github.com/golang-migrate/migrate/v4/database/postgres" @@ -28,6 +30,36 @@ func CreateMigrator(dbURL, migrationsPath string) (*migrate.Migrate, error) { return m, nil } +// LatestSourceMigrationVersion returns the highest migration version present +// in migrationsPath, read from the _.up.sql file names — the +// `lightstack migrate --dry-run` backing. Files that do not match the naming +// scheme are ignored, matching the file source driver's behavior. +func LatestSourceMigrationVersion(migrationsPath string) (uint, error) { + entries, err := os.ReadDir(migrationsPath) + if err != nil { + return 0, fmt.Errorf("failed to read migrations directory: %w", err) + } + var latest uint + for _, entry := range entries { + name := entry.Name() + if !strings.HasSuffix(name, ".up.sql") { + continue + } + underscore := strings.IndexByte(name, '_') + if underscore <= 0 { + continue + } + version, err := strconv.ParseUint(name[:underscore], 10, 32) + if err != nil { + continue + } + if uint(version) > latest { + latest = uint(version) + } + } + return latest, nil +} + // GetMigrationStatus returns current migration version and dirty state func GetMigrationStatus(dbURL, migrationsPath string) (*MigrationInfo, error) { m, err := CreateMigrator(dbURL, migrationsPath) diff --git a/internal/database/migrate_test.go b/internal/database/migrate_test.go new file mode 100644 index 00000000..7a27d915 --- /dev/null +++ b/internal/database/migrate_test.go @@ -0,0 +1,40 @@ +package database + +import ( + "os" + "path/filepath" + "testing" +) + +// TestLatestSourceMigrationVersion pins the `lightstack migrate --dry-run` +// backing: the highest .up.sql version wins, and files that do not follow the +// _.up.sql naming scheme are ignored like the file source +// driver ignores them. +func TestLatestSourceMigrationVersion(t *testing.T) { + dir := t.TempDir() + files := map[string]string{ + "001_initial.up.sql": "", + "002_add_servers.up.sql": "", + "002_add_servers.down.sql": "", // down migrations do not count + "10_add_ports.up.sql": "", // no zero padding required + "README.md": "", // not a migration + "not-a-number_rename.up.sql": "", // malformed version prefix + } + for name, body := range files { + if err := os.WriteFile(filepath.Join(dir, name), []byte(body), 0o644); err != nil { + t.Fatal(err) + } + } + + latest, err := LatestSourceMigrationVersion(dir) + if err != nil { + t.Fatalf("LatestSourceMigrationVersion: %v", err) + } + if latest != 10 { + t.Errorf("LatestSourceMigrationVersion = %d; want 10", latest) + } + + if _, err := LatestSourceMigrationVersion(filepath.Join(dir, "does-not-exist")); err == nil { + t.Error("LatestSourceMigrationVersion accepted a missing directory; want error") + } +} From 302555a613824f2d6f04d8ef958134699bed3f0c Mon Sep 17 00:00:00 2001 From: Uwe Schwaeke Date: Tue, 13 Oct 2026 13:09:41 +0000 Subject: [PATCH 07/12] =?UTF-8?q?fix(release):=20round-2=20review=20?= =?UTF-8?q?=E2=80=94=20tighten=20the=20admin=20guard,=20wire=20every=20boo?= =?UTF-8?q?t=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Round 2 of the comprehensive review on this branch: - F1 (HIGH): the admin-password guard had an omit-both-fields escape, but migrations/002 seeds an enabled admin/secret account in EVERY deployment and BootstrapAdmin only warns on an empty configured password — omitting the field is precisely how the public credential stays live. The guard now refuses empty/well-known admin_password unconditionally. The deploy scripts (deploy-single-node.sh, deploy-turnkey.sh) generate a real admin password (openssl rand) and carry it through the rendered config, the CLI env file and the summary; README-KVM's example documents both generated secrets (its placeholders are denylisted too). - F2 (HIGH): the CI rgw-integration stack booted the image's canned admin/secret with a real JWT secret and no opt-out — the new guard crash-looped it (job already red on the previous commit). The stack now arms the documented hatch, matching the dev-stack policy. - F3: docker-compose-horizon.yml requires LIGHTSTACK_ADMIN_PASSWORD like it requires the JWT secret; start_validation.sh and compose_db_identity_test.sh supply it; docker-compose.test.yml takes OS_PASSWORD from the environment instead of a hardcoded 'secret'. - F4: test/vxlan_multinode_test.sh arms the hatch (both fixture nodes boot admin/secret by design). - F5: 'lightstack migrate' rejects positional arguments — Go's flag parsing stops at the first one, so 'migrate up --config X --dry-run' silently ran a REAL migration against the DEFAULT config. - F6: runCleanup's doc comment reattached to runCleanup (it had drifted onto loadConfig). - F7: CONFIGURATION.md env-var table gains LIGHTSTACK_ADMIN_PASSWORD and the hatch variable; brittle 'exactly fourteen' count dropped. - F8: release concurrency queues (cancel-in-progress: false) — a cancelled in-flight publish between image and chart push is exactly the partial state the pipeline warns about. Signed-off-by: Uwe Schwaeke --- .github/workflows/release.yml | 7 ++++-- CHANGELOG.md | 10 +++++--- cmd/lightstack/config_test.go | 11 +++++---- cmd/lightstack/main.go | 17 ++++++++++--- deployments/README-KVM.md | 5 ++++ deployments/docker-compose-horizon.yml | 4 +++ deployments/docker-compose.rgw-test.yml | 5 ++++ deployments/docker-compose.test.yml | 7 +++++- docs/CONFIGURATION.md | 5 ++-- internal/common/config.go | 33 ++++++++++++++----------- internal/common/config_test.go | 18 ++++++++------ scripts/deploy-single-node.sh | 13 ++++++++-- scripts/deploy-turnkey.sh | 12 +++++++-- scripts/start_validation.sh | 1 + test/compose_db_identity_test.sh | 6 +++-- test/vxlan_multinode_test.sh | 5 ++++ 16 files changed, 113 insertions(+), 46 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2c50af39..edda091e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,10 +18,13 @@ on: tags: - 'v*' -# A re-pushed tag must not run two release pipelines in parallel. +# A re-pushed tag must not run two release pipelines in parallel — but a +# cancellation can also kill an in-flight publish between steps (e.g. after +# the image push, before the chart push), leaving exactly the partial state +# this pipeline warns about. Queue instead of cancelling. concurrency: group: release-${{ github.ref }} - cancel-in-progress: true + cancel-in-progress: false # Least privilege: the test gate only needs to read the repo; only the # publishing job needs to write releases and packages. diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cfa0541..334e1d4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,15 +40,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 refuses them — case-insensitively and ignoring surrounding whitespace, so the uppercase spelling in `deployments/README-KVM.md` is caught too (that example now generates a per-deployment secret instead). It also refuses a well-known - or empty `keystone.admin_password` whenever an admin account is configured — - `admin`/`secret` authenticates as the bootstrap admin directly. A + or empty `keystone.admin_password` — unconditionally: migrations/002 seeds an + enabled `admin` account with bcrypt(`secret`) in every deployment, so a config + that omits the field boots with the public credential live. A `LIGHTSTACK_ADMIN_PASSWORD` environment override (mirroring `LIGHTSTACK_JWT_SECRET`) lets `docker run` inject the real password without mounting a config. `LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1` is the documented escape hatch for isolated dev/test stacks (the plain docker-compose dev stacks - and `make run` opt in explicitly; the Horizon stack and the Helm chart already - require a real secret). `lightstack-migrate` and the operational CLI + and `make run` opt in explicitly; the Horizon stack now requires a real + `LIGHTSTACK_ADMIN_PASSWORD` alongside its JWT secret, and the Helm chart + already fails fast on both). `lightstack-migrate` and the operational CLI subcommands (`cleanup`, `console-tokens`, `migrate`) are exempt — they never sign or validate a token, and the image entrypoint and the documented Kubernetes init container run migrations against the canned config before any diff --git a/cmd/lightstack/config_test.go b/cmd/lightstack/config_test.go index fbd0580c..d8faf507 100644 --- a/cmd/lightstack/config_test.go +++ b/cmd/lightstack/config_test.go @@ -8,14 +8,15 @@ import ( "github.com/cobaltcore-dev/lightstack/pkg/paths" ) -// loadConfig is where every entry point — the server, cleanup and console-tokens — -// turns state_path into the node-local root. A subcommand that skipped it would act on -// the default root while the server used the configured one: cleanup would purge the -// wrong directory, console-tokens would list and purge nothing. +// loadConfig and loadConfigForCLI are where the entry points — the server via +// the former, the CLI subcommands via the latter — turn state_path into the +// node-local root. A subcommand that skipped it would act on the default root +// while the server used the configured one: cleanup would purge the wrong +// directory, console-tokens would list and purge nothing. func TestLoadConfigAppliesStatePath(t *testing.T) { path := filepath.Join(t.TempDir(), "lightstack.yaml") if err := os.WriteFile(path, []byte( - "state_path: /data/lightstack\nkeystone:\n jwt_secret: test-secret-not-a-default\n"), 0o600); err != nil { + "state_path: /data/lightstack\nkeystone:\n jwt_secret: test-secret-not-a-default\n admin_password: test-admin-password-not-a-default\n"), 0o600); err != nil { t.Fatal(err) } t.Cleanup(func() { paths.SetBase(paths.DefaultBase) }) diff --git a/cmd/lightstack/main.go b/cmd/lightstack/main.go index 45feb2ed..40dd2ff9 100644 --- a/cmd/lightstack/main.go +++ b/cmd/lightstack/main.go @@ -499,6 +499,15 @@ func runMigrate(args []string) int { } return 2 } + // Go's flag parsing stops at the first positional, so + // `migrate up --config X --dry-run` would silently run a REAL migration + // against the DEFAULT config with the flags dropped (round-2 review F5). + // Reject positionals instead; the sibling tool's `lightstack-migrate up` + // style has no equivalent here. + if fs.NArg() > 0 { + fmt.Fprintf(os.Stderr, "migrate: unexpected argument %q (flags only — no subcommand; see `lightstack migrate --help`)\n", fs.Arg(0)) + return 2 + } cfg, err := loadConfigForCLI(*cfgPath) if err != nil { @@ -537,10 +546,6 @@ func runMigrate(args []string) int { return 0 } -// runCleanup executes the `lightstack cleanup` subcommand: the SPEC-010 release teardown -// (issue #53). Exit codes: 0 success, 1 a required class could not be purged -// (fail-closed — the blocking pre-delete hook then aborts uninstall), 2 usage or -// config error. // loadConfig loads the config and applies state_path as the node-local root. // The server goes through here — the guarded path, since it signs and // validates tokens. Every subcommand goes through loadConfigForCLI, which @@ -660,6 +665,10 @@ func runConsoleTokens(args []string) int { return console.RunCLI(ctx, store, rest, os.Stdout, os.Stderr) } +// runCleanup executes the `lightstack cleanup` subcommand: the SPEC-010 release teardown +// (issue #53). Exit codes: 0 success, 1 a required class could not be purged +// (fail-closed — the blocking pre-delete hook then aborts uninstall), 2 usage or +// config error. func runCleanup(args []string) { fs := flag.NewFlagSet("cleanup", flag.ContinueOnError) cfgPath := fs.String("config", "config/lightstack.yaml", "Path to configuration file") diff --git a/deployments/README-KVM.md b/deployments/README-KVM.md index c1e0764a..b421fa51 100644 --- a/deployments/README-KVM.md +++ b/deployments/README-KVM.md @@ -40,6 +40,11 @@ keystone: # (including this comment's old placeholder) is refused at startup. jwt_secret: "PASTE-OUTPUT-OF-openssl-rand-base64-32" token_ttl: 24h + # The bootstrap admin account's password — also generate per deployment + # (`openssl rand -base64 24`); the shipped `secret` default is public and + # refused at startup. + admin_user: admin + admin_password: "PASTE-OUTPUT-OF-openssl-rand-base64-24" nova: host: "0.0.0.0" diff --git a/deployments/docker-compose-horizon.yml b/deployments/docker-compose-horizon.yml index 22d84775..ed7af6e0 100644 --- a/deployments/docker-compose-horizon.yml +++ b/deployments/docker-compose-horizon.yml @@ -51,6 +51,10 @@ services: environment: - LIGHTSTACK_DB_URL=postgres://${POSTGRES_USER:-lightstack}:${POSTGRES_PASSWORD:-secret}@postgres:5432/${POSTGRES_DB:-lightstack}?sslmode=disable - LIGHTSTACK_JWT_SECRET=${LIGHTSTACK_JWT_SECRET:?LIGHTSTACK_JWT_SECRET must be set} + # The bootstrap admin password: the image's canned config ships the + # public admin/secret default, which the secret guard refuses. Provide + # a real one (openssl rand -base64 24). + - LIGHTSTACK_ADMIN_PASSWORD=${LIGHTSTACK_ADMIN_PASSWORD:?LIGHTSTACK_ADMIN_PASSWORD must be set} - LIGHTSTACK_ENDPOINT_HOST=lightstack volumes: - lightstack-data:/var/lib/lightstack diff --git a/deployments/docker-compose.rgw-test.yml b/deployments/docker-compose.rgw-test.yml index 774de0f1..34d33f84 100644 --- a/deployments/docker-compose.rgw-test.yml +++ b/deployments/docker-compose.rgw-test.yml @@ -64,6 +64,11 @@ services: environment: LIGHTSTACK_DB_URL: "postgres://lightstack:secret@postgres:5432/lightstack?sslmode=disable" LIGHTSTACK_JWT_SECRET: "rgwtest-secret" + # Isolated CI fixture: the image's canned config ships the public + # admin/secret bootstrap credential, which the secret guard refuses — + # same opt-in the plain dev stacks use. The test scripts authenticate + # with that public credential deliberately. + LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET: "true" # Glance -> Ceph RGW (S3). Credentials are env-only; match the demo user above. LIGHTSTACK_GLANCE_STORAGE_MODE: "s3" LIGHTSTACK_GLANCE_S3_ENDPOINT: "http://rgw:8080" diff --git a/deployments/docker-compose.test.yml b/deployments/docker-compose.test.yml index 78f78bae..929f8fae 100644 --- a/deployments/docker-compose.test.yml +++ b/deployments/docker-compose.test.yml @@ -1,5 +1,10 @@ version: '3.8' +# Manual helper: a container on the Horizon stack's network with the +# OpenStack CLI preconfigured. Pair with deployments/docker-compose-horizon.yml +# (docker compose -f deployments/docker-compose-horizon.yml up -d first) and +# pass the same admin password that stack got: +# OS_PASSWORD="$(...)" docker compose -f deployments/docker-compose.test.yml run --rm test-runner services: test-runner: image: golang:1.27.2 @@ -12,7 +17,7 @@ services: environment: OS_AUTH_URL: "http://lightstack:35357/v3" OS_USERNAME: "admin" - OS_PASSWORD: "secret" + OS_PASSWORD: "${OS_PASSWORD:?OS_PASSWORD must match the horizon stack's LIGHTSTACK_ADMIN_PASSWORD}" OS_PROJECT_NAME: "default" OS_USER_DOMAIN_NAME: "Default" OS_PROJECT_DOMAIN_NAME: "Default" diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index ba48df7b..a81f91bd 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -131,16 +131,17 @@ logging: > **Correction (SPEC-008).** Earlier versions of this page documented a generic > `lightstack_
_` convention (e.g. `LIGHTSTACK_DATABASE_URL`, `LIGHTSTACK_KEYSTONE_ADMIN_PASSWORD`, > `LIGHTSTACK_NOVA_LIBVIRT_MODE`). **The binary does not implement that layer** — those variables -> are silently ignored. Everything else (admin password, service modes, VXLAN, cache, +> are silently ignored. Everything else (service modes, VXLAN, cache, > logging, ports, …) takes effect **only from the YAML config file** passed via `--config`. -The binary honors exactly **fourteen** environment variables: +The binary honors the following environment variables: | Variable | Overrides / controls | Where it is read | |----------|----------------------|------------------| | `LIGHTSTACK_DB_URL` | `database.url` | `internal/common/config.go` (`LoadConfig`) | | `LIGHTSTACK_JWT_SECRET` | `keystone.jwt_secret` | `internal/common/config.go` (`LoadConfig`) | | `LIGHTSTACK_ADMIN_PASSWORD` | `keystone.admin_password` (the bootstrap admin's password; refused when left at a well-known default — see the S2 secret guard) | `internal/common/config.go` (`LoadConfig`) | +| `LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET` | **Test/dev-only escape hatch** (`1`/`true`): opts out of the secret guard that refuses well-known JWT secrets and admin passwords. Never set on anything reachable by an untrusted network. | `internal/common/config.go` (`LoadConfig`) | | `LIGHTSTACK_KEYSTONE_RGW_COMPAT_TENANT_IDS` | `keystone.rgw_compat_tenant_ids`. Two-way boolean: `true`/`1` turns it **on** over a config file that shipped it off; `false`/`0` turns it **off** against a config file that shipped it on. Renders `token.project.id` in OpenStack's dash-free form in the `/v3/auth/tokens` responses; `/v3/s3tokens` already uses that historical form. The EC2 mint accepts dash-free or alternate UUID encodings as input and stores the canonical database id. Enabling the flag therefore unifies Swift with the existing S3 tenant namespace without re-keying S3 data. | `internal/common/config.go` (`LoadConfig`) | | `LIGHTSTACK_ENDPOINT_HOST` | advertised catalog / self-link host — a **fallback**, see below | request time (`internal/keystone/auth.go`, `internal/common/baseurl.go`) | | `LIGHTSTACK_ENDPOINT_SCHEME` | advertised URL scheme: `http` (default) or `https` | request time (`internal/common/scheme.go`) | diff --git a/internal/common/config.go b/internal/common/config.go index aed51479..c7e2178b 100644 --- a/internal/common/config.go +++ b/internal/common/config.go @@ -430,18 +430,19 @@ func loadConfig(path string, enforceSecretGuard bool) (*Config, error) { "For isolated development or test environments only, " + "LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1 opts out of this check") } - // Only enforced when an admin account is actually configured: minimal - // test fixtures legitimately omit both fields (no account is seeded). - if cfg.Keystone.AdminUser != "" || cfg.Keystone.AdminPassword != "" { - if isInsecureDefaultSecret(cfg.Keystone.AdminPassword, insecureDefaultAdminPasswords) { - return nil, fmt.Errorf( - "keystone.admin_password is empty or a well-known default — refusing to start. " + - "Set keystone.admin_password in the config file (or the " + - "LIGHTSTACK_ADMIN_PASSWORD environment variable) to a random value " + - "(it seeds the bootstrap admin account). For isolated development or " + - "test environments only, LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1 " + - "opts out of this check") - } + // The admin half has no omit-both escape: migrations/002 seeds an + // enabled `admin` account with bcrypt("secret") in EVERY deployment, + // and BootstrapAdmin only warns when no password is configured — so + // a config that omits the field boots with the public credential + // live. An empty or well-known admin_password is always refused. + if isInsecureDefaultSecret(cfg.Keystone.AdminPassword, insecureDefaultAdminPasswords) { + return nil, fmt.Errorf( + "keystone.admin_password is empty or a well-known default — refusing to start. " + + "Set keystone.admin_password in the config file (or the " + + "LIGHTSTACK_ADMIN_PASSWORD environment variable) to a random value " + + "(it seeds the bootstrap admin account). For isolated development or " + + "test environments only, LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1 " + + "opts out of this check") } } @@ -455,15 +456,17 @@ var insecureDefaultJWTSecrets = map[string]struct{}{ "": {}, "change-me-in-production": {}, "change-me-in-production-use-openssl-rand-base64-32": {}, - // deployments/README-KVM.md's example placeholder — copy-pasting the doc + // deployments/README-KVM.md's example placeholders — copy-pasting the doc // verbatim must be caught like the config file's own default. "paste-output-of-openssl-rand-base64-32": {}, + "paste-output-of-openssl-rand-base64-24": {}, } // insecureDefaultAdminPasswords are the well-known bootstrap-admin passwords // shipped in this repository (config/lightstack.yaml: "secret") and left by -// operators who never changed it. Empty is refused when an admin user is -// configured — the seeded account would authenticate with an empty password. +// operators who never changed it. Empty is refused unconditionally — the +// migrations/002 seed leaves admin/secret live when no password is +// configured, so "omitted" is exactly as dangerous as the public default. var insecureDefaultAdminPasswords = map[string]struct{}{ "": {}, "secret": {}, diff --git a/internal/common/config_test.go b/internal/common/config_test.go index f26003aa..ba56035b 100644 --- a/internal/common/config_test.go +++ b/internal/common/config_test.go @@ -875,11 +875,14 @@ func TestLoadConfigRefusesInsecureDefaultAdminPassword(t *testing.T) { }) } - // Both admin fields omitted: no account is seeded, no credentials to - // guard — must keep loading (this is what every minimal fixture looks - // like). - if _, err := LoadConfig(writeTestConfig(t, "keystone:\n jwt_secret: \""+goodSecret+"\"\n")); err != nil { - t.Errorf("LoadConfig without admin fields: %v; want acceptance", err) + // Both admin fields omitted: REFUSED. migrations/002 seeds an enabled + // admin/secret account in every deployment and BootstrapAdmin only warns + // on an empty configured password — omitting the field is how the public + // credential stays live (round-2 review F1). + if _, err := LoadConfig(writeTestConfig(t, "keystone:\n jwt_secret: \""+goodSecret+"\"\n")); err == nil { + t.Error("LoadConfig without admin fields: accepted; want refusal (the seeded admin/secret stays live)") + } else if !strings.Contains(err.Error(), "admin_password") { + t.Errorf("error does not name admin_password: %v", err) } // A random password with a random secret: the positive control. @@ -917,10 +920,11 @@ func TestLoadConfigAllowsInsecureDefaultSecretWithOverride(t *testing.T) { } // TestLoadConfigAcceptsARandomSecret is the positive control for the guard: a -// non-default secret loads without any opt-in. +// non-default secret (and non-default admin password) loads without any +// opt-in. func TestLoadConfigAcceptsARandomSecret(t *testing.T) { hermeticGuardEnv(t) - cfg, err := LoadConfig(writeTestConfig(t, "keystone:\n jwt_secret: \"k4FNxqKmLwW3ZRFvMscJ0d1oO5gYhN\"\n")) + cfg, err := LoadConfig(writeTestConfig(t, "keystone:\n jwt_secret: \"k4FNxqKmLwW3ZRFvMscJ0d1oO5gYhN\"\n admin_password: \"T3st-Not-The-Shipped-Default\"\n")) if err != nil { t.Fatalf("LoadConfig: %v", err) } diff --git a/scripts/deploy-single-node.sh b/scripts/deploy-single-node.sh index c61fa981..d8a4b244 100755 --- a/scripts/deploy-single-node.sh +++ b/scripts/deploy-single-node.sh @@ -172,6 +172,13 @@ get_configuration() { JWT_SECRET=$(openssl rand -base64 32) log_info "Generated JWT secret for Keystone" + # Bootstrap admin password — the seeded admin account (migrations/002) + # starts with the public default; the secret guard refuses to boot on it, + # so the deploy generates a real one. Passed through to the config file, + # the CLI environment file and the summary below. + ADMIN_PASSWORD=$(openssl rand -base64 24) + log_info "Generated bootstrap admin password" + # Node-local state root: images, volumes, instances, cloud-init, dhcp and console # tokens all live under it (the binary's state_path, which refuses anything else). read -p "Enter node-local state root [/var/lib/lightstack]: " STORAGE_DIR @@ -539,6 +546,8 @@ keystone: port: 35357 jwt_secret: "$JWT_SECRET" token_ttl: 24h + admin_user: admin + admin_password: "$ADMIN_PASSWORD" nova: host: "0.0.0.0" @@ -831,7 +840,7 @@ create_env_file() { export OS_AUTH_URL=http://$HOST_IP:35357/v3 export OS_PROJECT_NAME=default export OS_USERNAME=admin -export OS_PASSWORD=secret +export OS_PASSWORD=$ADMIN_PASSWORD export OS_USER_DOMAIN_NAME=Default export OS_PROJECT_DOMAIN_NAME=Default export OS_IDENTITY_API_VERSION=3 @@ -911,7 +920,7 @@ show_completion() { echo " Horizon Dashboard: http://$HOST_IP" echo " - Domain: Default" echo " - Username: admin" - echo " - Password: secret" + echo " - Password: $ADMIN_PASSWORD" echo "" fi diff --git a/scripts/deploy-turnkey.sh b/scripts/deploy-turnkey.sh index 5e8f8132..272a01ed 100755 --- a/scripts/deploy-turnkey.sh +++ b/scripts/deploy-turnkey.sh @@ -66,6 +66,7 @@ NETMASK="${LIGHTSTACK_NETMASK:-24}" # so the workers get PermissionError on read and Horizon fails to start. DB_PASSWORD="${LIGHTSTACK_DB_PASSWORD:-}" JWT_SECRET="" +ADMIN_PASSWORD="" HORIZON_SECRET_KEY="" INSTALL_DIR="${LIGHTSTACK_INSTALL_DIR:-/opt/lightstack}" CONFIG_DIR="$INSTALL_DIR/config" @@ -343,6 +344,11 @@ validate_config() { generate_secrets() { JWT_SECRET="$(openssl rand -hex 32)" + # The seeded admin account (migrations/002) starts with the public + # default; the secret guard refuses to boot on it, so a real one is + # generated here and flows into the config, the CLI env file, Horizon's + # deployment and the summary. + ADMIN_PASSWORD="$(openssl rand -hex 24)" HORIZON_SECRET_KEY="$(openssl rand -hex 32)" if [ -z "$DB_PASSWORD" ]; then DB_PASSWORD="$(openssl rand -hex 16)" @@ -637,6 +643,8 @@ keystone: port: 35357 jwt_secret: "$JWT_SECRET" token_ttl: 24h + admin_user: admin + admin_password: "$ADMIN_PASSWORD" nova: host: "0.0.0.0" @@ -888,7 +896,7 @@ create_cli_env() { export OS_AUTH_URL=http://$HOST_IP:35357/v3 export OS_PROJECT_NAME=default export OS_USERNAME=admin -export OS_PASSWORD=secret +export OS_PASSWORD=$ADMIN_PASSWORD export OS_USER_DOMAIN_NAME=Default export OS_PROJECT_DOMAIN_NAME=Default export OS_IDENTITY_API_VERSION=3 @@ -913,7 +921,7 @@ show_completion() { echo "🌐 Horizon Dashboard:" echo " URL: http://$HOST_IP/dashboard" echo " Username: admin" - echo " Password: secret" + echo " Password: $ADMIN_PASSWORD" echo " Domain: Default" echo "" echo "🖥️ Instance Console (noVNC):" diff --git a/scripts/start_validation.sh b/scripts/start_validation.sh index f27296e2..399a8505 100755 --- a/scripts/start_validation.sh +++ b/scripts/start_validation.sh @@ -30,6 +30,7 @@ echo "" # Start Lightstack + Horizon stack echo -e "${YELLOW}[2/5]${NC} Starting Lightstack + Horizon stack..." export LIGHTSTACK_JWT_SECRET="${LIGHTSTACK_JWT_SECRET:-validation-only-secret}" +export LIGHTSTACK_ADMIN_PASSWORD="${LIGHTSTACK_ADMIN_PASSWORD:-validation-only-admin-password}" docker compose -f deployments/docker-compose-horizon.yml down &> /dev/null || true docker compose -f deployments/docker-compose-horizon.yml up -d --build echo -e "${GREEN}✓ Lightstack services started${NC}" diff --git a/test/compose_db_identity_test.sh b/test/compose_db_identity_test.sh index 30c2eee7..31e72c17 100755 --- a/test/compose_db_identity_test.sh +++ b/test/compose_db_identity_test.sh @@ -95,9 +95,11 @@ print("DSN=%s" % dsn) } render() { - # docker-compose-horizon.yml declares LIGHTSTACK_JWT_SECRET as mandatory; supply a value - # so rendering does not fail for an unrelated reason. + # docker-compose-horizon.yml declares LIGHTSTACK_JWT_SECRET and + # LIGHTSTACK_ADMIN_PASSWORD as mandatory; supply values so rendering + # does not fail for an unrelated reason. LIGHTSTACK_JWT_SECRET="${LIGHTSTACK_JWT_SECRET:-render-only}" \ + LIGHTSTACK_ADMIN_PASSWORD="${LIGHTSTACK_ADMIN_PASSWORD:-render-only}" \ timeout 120 docker compose -f "$1" config 2>/dev/null } diff --git a/test/vxlan_multinode_test.sh b/test/vxlan_multinode_test.sh index 521b51cd..92c8e2ab 100755 --- a/test/vxlan_multinode_test.sh +++ b/test/vxlan_multinode_test.sh @@ -4,6 +4,11 @@ set -e +# Isolated test fixture: both nodes boot with the public admin/secret +# bootstrap credential (the auth payloads below use it), which the secret +# guard refuses without this opt-in — same policy as the dev compose stacks. +export LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET="${LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET:-1}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" TEST_DIR="$PROJECT_ROOT/test/tmp" From 04f968d4fe742b91ea7317f0be95a052cdace663 Mon Sep 17 00:00:00 2001 From: Uwe Schwaeke Date: Tue, 13 Oct 2026 13:22:32 +0000 Subject: [PATCH 08/12] =?UTF-8?q?fix(release):=20round-3=20review=20?= =?UTF-8?q?=E2=80=94=20denylist=20doc=20placeholders,=20validation=20stack?= =?UTF-8?q?=20auth,=20boot-path=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - F1: the denylists missed repo-shipped placeholders in boot-path docs — docs/SINGLE_NODE_DEPLOYMENT.md and docs/SCALING.md JWT secrets, and the admin placeholder this branch itself added to README-KVM (its JWT sibling was denylisted, the admin one was not — a user who fixes only the JWT after the first refusal would boot with the repo-published admin credential). All three added, with test coverage. - F2: start_validation.sh boots the stack with a generated admin password (BootstrapAdmin replaces the seeded admin/secret hash), so the validation suite it runs must authenticate with the same password — OS_PASSWORD now defaults from LIGHTSTACK_ADMIN_PASSWORD, and the printed login lines no longer claim 'secret'. - F3: the copy-paste boot paths for docker-compose-horizon.yml now export both required secrets (README, QUICK_REFERENCE, UNIFIED_, HORIZON_SETUP); admin/secret login claims replaced with the actual source (the env var or /root/.lightstack-env, which the deploy script writes); .env.example gains the LIGHTSTACK_ADMIN_PASSWORD entry; the horizon compose SECRET_KEY comment no longer claims every caller drives the file without exporting anything. - F4: scripts/start-lightstack-background.sh boots the canned config with no opt-out — dead since the guard. Arms the documented hatch (same policy as make run), and documents that 'serve' is an ignored positional. Signed-off-by: Uwe Schwaeke --- .env.example | 5 +++++ README.md | 9 ++++++--- deployments/docker-compose-horizon.yml | 7 ++++--- docs/HORIZON_SETUP.md | 3 +++ docs/QUICK_REFERENCE.md | 10 ++++++---- docs/SINGLE_NODE_DEPLOYMENT.md | 11 ++++++----- docs/UNIFIED_DEPLOYMENT.md | 10 ++++++++-- internal/common/config.go | 13 ++++++++++--- internal/common/config_test.go | 3 +++ scripts/start-lightstack-background.sh | 8 +++++++- scripts/start_validation.sh | 8 ++++++-- 11 files changed, 64 insertions(+), 23 deletions(-) diff --git a/.env.example b/.env.example index b01e0a2d..d7065ca4 100644 --- a/.env.example +++ b/.env.example @@ -8,6 +8,11 @@ # JWT secret for token signing (CHANGE THIS IN PRODUCTION!) LIGHTSTACK_JWT_SECRET=change-me-in-production-use-openssl-rand-base64-32 +# Bootstrap admin password — required by docker-compose-horizon.yml and by +# the secret guard (admin/secret is public and refused). Generate one: +# openssl rand -base64 24 +LIGHTSTACK_ADMIN_PASSWORD= + # Ceph RGW (Swift) compatibility: render the token payload's project id # (token.project.id) in OpenStack's established dash-free form in the # /v3/auth/tokens responses (password issue, token re-scope and GET validation). diff --git a/README.md b/README.md index 8f4a7931..a6d0117b 100644 --- a/README.md +++ b/README.md @@ -175,12 +175,15 @@ sudo ./deploy-single-node.sh git clone https://github.com/cobaltcore-dev/lightstack.git cd lightstack/deployments -# 2. Start all services (lightstack + Horizon + PostgreSQL + noVNC) +# 2. Start all services (lightstack + Horizon + PostgreSQL + noVNC). +# Both secrets are required — the stack renders no insecure defaults. +export LIGHTSTACK_JWT_SECRET="$(openssl rand -base64 32)" +export LIGHTSTACK_ADMIN_PASSWORD="$(openssl rand -base64 24)" docker compose -f docker-compose-horizon.yml up -d # 3. Access Horizon Dashboard open http://localhost/dashboard -# Login: Domain=Default, User=admin, Password=secret +# Login: Domain=Default, User=admin, Password=$LIGHTSTACK_ADMIN_PASSWORD ``` **What's included**: @@ -274,7 +277,7 @@ SESSION_TIMEOUT = 14400 # 4 hours (matches lightstack token TTL) CONSOLE_TYPE = 'VNC' # a Horizon CONSOLES key; 'novnc' is not one, and fails without calling Nova ``` -**Login Credentials**: Domain=Default, User=admin, Password=secret +**Login Credentials**: Domain=Default, User=admin, Password=the LIGHTSTACK_ADMIN_PASSWORD you set when starting the stack ### 📖 Installation & Deployment diff --git a/deployments/docker-compose-horizon.yml b/deployments/docker-compose-horizon.yml index ed7af6e0..d0989b66 100644 --- a/deployments/docker-compose-horizon.yml +++ b/deployments/docker-compose-horizon.yml @@ -87,9 +87,10 @@ services: - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS # Django signs CSRF tokens with this; apache runs processes=3, so every worker must get # the SAME value, or a token minted by one worker is rejected by the others. A labelled lab - # default (as with POSTGRES_PASSWORD above, and the chart's horizon.secretKey) keeps every - # caller of this file working — scripts/start_validation.sh, README, QUICK_REFERENCE and - # UNIFIED_DEPLOYMENT all drive it without exporting anything. Override beyond a lab. + # default (as with POSTGRES_PASSWORD above, and the chart's horizon.secretKey) keeps the + # Horizon side of the stack renderable with nothing exported. The lightstack side is + # different: LIGHTSTACK_JWT_SECRET and LIGHTSTACK_ADMIN_PASSWORD are required (:?) + # — its guard refuses the public defaults. Override the SECRET_KEY beyond a lab. - SECRET_KEY=${HORIZON_SECRET_KEY:-lightstack-horizon-lab-only-change-me} # local_settings defaults DEBUG to False; the dev stack opts in so a 500 shows a traceback. - HORIZON_DEBUG=${HORIZON_DEBUG:-True} diff --git a/docs/HORIZON_SETUP.md b/docs/HORIZON_SETUP.md index 2bbd8ae5..ff7c78d6 100644 --- a/docs/HORIZON_SETUP.md +++ b/docs/HORIZON_SETUP.md @@ -38,6 +38,9 @@ Deploy Lightstack and Horizon together using `docker-compose-horizon.yml`: ```bash cd lightstack/deployments +# Both secrets are required — the stack renders no insecure defaults +export LIGHTSTACK_JWT_SECRET="$(openssl rand -base64 32)" +export LIGHTSTACK_ADMIN_PASSWORD="$(openssl rand -base64 24)" docker compose -f docker-compose-horizon.yml up -d ``` diff --git a/docs/QUICK_REFERENCE.md b/docs/QUICK_REFERENCE.md index c2b2e043..b36a54fd 100644 --- a/docs/QUICK_REFERENCE.md +++ b/docs/QUICK_REFERENCE.md @@ -6,13 +6,15 @@ ## Quick Start ```bash -# Start everything +# Start everything (both secrets are required — no insecure defaults render) cd lightstack/deployments +export LIGHTSTACK_JWT_SECRET="$(openssl rand -base64 32)" +export LIGHTSTACK_ADMIN_PASSWORD="$(openssl rand -base64 24)" docker compose -f docker-compose-horizon.yml up -d # Access Horizon open http://localhost/dashboard -# Login: Domain=Default, User=admin, Password=secret +# Login: Domain=Default, User=admin, Password=$LIGHTSTACK_ADMIN_PASSWORD # Check status docker compose -f docker-compose-horizon.yml ps @@ -59,11 +61,11 @@ docker exec -it lightstack-postgres psql -U lightstack # Database ## OpenStack CLI Setup ```bash -# Export environment +# Export environment (the admin password you set when starting the stack) export OS_AUTH_URL=http://localhost:35357/v3 export OS_PROJECT_NAME=default export OS_USERNAME=admin -export OS_PASSWORD=secret +export OS_PASSWORD="${LIGHTSTACK_ADMIN_PASSWORD:?set LIGHTSTACK_ADMIN_PASSWORD (see Quick Start above)}" export OS_USER_DOMAIN_NAME=Default export OS_PROJECT_DOMAIN_NAME=Default export OS_IDENTITY_API_VERSION=3 diff --git a/docs/SINGLE_NODE_DEPLOYMENT.md b/docs/SINGLE_NODE_DEPLOYMENT.md index 3b4b8f62..500fef1c 100644 --- a/docs/SINGLE_NODE_DEPLOYMENT.md +++ b/docs/SINGLE_NODE_DEPLOYMENT.md @@ -574,11 +574,12 @@ sudo systemctl status lightstack.service # Check Horizon docker ps | grep horizon -# Test OpenStack CLI +# Test OpenStack CLI (the deploy script generates the admin password and +# writes the full environment to /root/.lightstack-env) export OS_AUTH_URL=http://192.168.1.100:35357/v3 export OS_PROJECT_NAME=default export OS_USERNAME=admin -export OS_PASSWORD=secret +export OS_PASSWORD="$(sed -n 's/^export OS_PASSWORD=//p' /root/.lightstack-env)" export OS_USER_DOMAIN_NAME=Default export OS_PROJECT_DOMAIN_NAME=Default @@ -735,7 +736,7 @@ openstack keypair list - URL: `http://192.168.1.100` (replace with your host IP) - Domain: `Default` - Username: `admin` - - Password: `secret` + - Password: the generated admin password (printed by the deploy script, saved in `/root/.lightstack-env`) 2. **Launch Instance**: - Navigate: Project → Compute → Instances @@ -1159,8 +1160,8 @@ docker compose up -d - Horizon config: `/opt/horizon/local_settings.py` - Systemd service: `/etc/systemd/system/lightstack.service` -**Default Credentials**: -- OpenStack admin: `admin` / `secret` +**Credentials**: +- OpenStack admin: `admin` / (the generated password in `/root/.lightstack-env`) - PostgreSQL: `lightstack` / (password from config) - CirrOS VM: `cirros` / `gocubsgo` diff --git a/docs/UNIFIED_DEPLOYMENT.md b/docs/UNIFIED_DEPLOYMENT.md index db7fd05d..e29e6cc0 100644 --- a/docs/UNIFIED_DEPLOYMENT.md +++ b/docs/UNIFIED_DEPLOYMENT.md @@ -101,11 +101,14 @@ cat horizon-config/local_settings - Database: PostgreSQL on port 5432 - Lightstack Mode: Stub (no real VMs, suitable for testing) - Horizon: Flamingo (2025.2) on port 80 -- Default Credentials: admin/secret +- Credentials: admin / the LIGHTSTACK_ADMIN_PASSWORD you set below ### Step 3: Start All Services ```bash +# Both secrets are required — the stack renders no insecure defaults +export LIGHTSTACK_JWT_SECRET="$(openssl rand -base64 32)" +export LIGHTSTACK_ADMIN_PASSWORD="$(openssl rand -base64 24)" docker compose -f docker-compose-horizon.yml up -d ``` @@ -187,6 +190,9 @@ export LIGHTSTACK_DB_USER=lightstack # JWT secret for lightstack authentication export LIGHTSTACK_JWT_SECRET=your-secure-jwt-secret-here +# Bootstrap admin password (required — no insecure default renders) +export LIGHTSTACK_ADMIN_PASSWORD=your-secure-admin-password-here + # lightstack modes export LIGHTSTACK_NOVA_MODE=stub # or 'real' for actual VMs (Linux only) export LIGHTSTACK_NEUTRON_MODE=stub # or 'iptables' for real networking @@ -516,7 +522,7 @@ curl -s http://localhost:9292/ | jq ### 3. Horizon Dashboard 1. Open http://localhost/dashboard -2. Login with admin/secret +2. Login with admin / the LIGHTSTACK_ADMIN_PASSWORD you set when starting the stack 3. Check "Overview" page loads 4. Verify "Compute > Instances" shows empty list 5. Click "Launch Instance" to test wizard diff --git a/internal/common/config.go b/internal/common/config.go index c7e2178b..2ba3e19e 100644 --- a/internal/common/config.go +++ b/internal/common/config.go @@ -456,10 +456,13 @@ var insecureDefaultJWTSecrets = map[string]struct{}{ "": {}, "change-me-in-production": {}, "change-me-in-production-use-openssl-rand-base64-32": {}, - // deployments/README-KVM.md's example placeholders — copy-pasting the doc - // verbatim must be caught like the config file's own default. + // Placeholders shipped in boot-path docs — copy-pasting the doc verbatim + // must be caught like the config file's own default. "paste-output-of-openssl-rand-base64-32": {}, - "paste-output-of-openssl-rand-base64-24": {}, + // docs/SINGLE_NODE_DEPLOYMENT.md + "change-this-in-production-min-32-chars-required-for-security": {}, + // docs/SCALING.md + "production-secret-min-32-chars-change-this-immediately": {}, } // insecureDefaultAdminPasswords are the well-known bootstrap-admin passwords @@ -470,6 +473,10 @@ var insecureDefaultJWTSecrets = map[string]struct{}{ var insecureDefaultAdminPasswords = map[string]struct{}{ "": {}, "secret": {}, + // deployments/README-KVM.md's example placeholder — the JWT sibling + // (...-32) is denylisted too; a user who fixes only the JWT after the + // first refusal must not boot with this one. + "paste-output-of-openssl-rand-base64-24": {}, } // isInsecureDefaultSecret reports whether secret is in the well-known-default diff --git a/internal/common/config_test.go b/internal/common/config_test.go index ba56035b..46769e3a 100644 --- a/internal/common/config_test.go +++ b/internal/common/config_test.go @@ -832,6 +832,8 @@ func TestLoadConfigRefusesInsecureDefaultJWTSecret(t *testing.T) { "change-me-in-production-use-openssl-rand-base64-32", // .env.example "CHANGE-ME-IN-PRODUCTION", // deployments/README-KVM.md " change-me-in-production ", + "change-this-in-production-min-32-chars-required-for-security", // docs/SINGLE_NODE_DEPLOYMENT.md + "production-secret-min-32-chars-change-this-immediately", // docs/SCALING.md } { body := "keystone:\n jwt_secret: \"" + secret + "\"\n" _, err := LoadConfig(writeTestConfig(t, body)) @@ -862,6 +864,7 @@ func TestLoadConfigRefusesInsecureDefaultAdminPassword(t *testing.T) { {"uppercase default", "SECRET"}, {"padded default", " secret "}, {"empty with a user", ""}, + {"README-KVM placeholder", "PASTE-OUTPUT-OF-openssl-rand-base64-24"}, } { t.Run(tc.name, func(t *testing.T) { body := "keystone:\n jwt_secret: \"" + goodSecret + "\"\n admin_user: admin\n admin_password: \"" + tc.password + "\"\n" diff --git a/scripts/start-lightstack-background.sh b/scripts/start-lightstack-background.sh index 8db9b014..4032f030 100755 --- a/scripts/start-lightstack-background.sh +++ b/scripts/start-lightstack-background.sh @@ -4,7 +4,13 @@ set +e # Don't exit on error during detachment -# Start Lightstack, capture PID immediately, then disown +# The canned config/lightstack.yaml ships the public well-known secrets the +# guard refuses; this helper targets isolated test runs, so arm the documented +# hatch (same policy as `make run` and the dev compose stacks). +export LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET="${LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET:-1}" + +# Start Lightstack, capture PID immediately, then disown. ("serve" is not a +# subcommand — it is an ignored positional; kept for compatibility.) ./bin/lightstack serve /tmp/lightstack.log 2>&1 & LIGHTSTACK_PID=$! disown diff --git a/scripts/start_validation.sh b/scripts/start_validation.sh index 399a8505..d4f91fcb 100755 --- a/scripts/start_validation.sh +++ b/scripts/start_validation.sh @@ -31,6 +31,10 @@ echo "" echo -e "${YELLOW}[2/5]${NC} Starting Lightstack + Horizon stack..." export LIGHTSTACK_JWT_SECRET="${LIGHTSTACK_JWT_SECRET:-validation-only-secret}" export LIGHTSTACK_ADMIN_PASSWORD="${LIGHTSTACK_ADMIN_PASSWORD:-validation-only-admin-password}" +# BootstrapAdmin replaces the seeded admin/secret hash with the configured +# password on a fresh volume — the validation suite (step 4/5) must +# authenticate with the same password the stack was booted with. +export OS_PASSWORD="${OS_PASSWORD:-$LIGHTSTACK_ADMIN_PASSWORD}" docker compose -f deployments/docker-compose-horizon.yml down &> /dev/null || true docker compose -f deployments/docker-compose-horizon.yml up -d --build echo -e "${GREEN}✓ Lightstack services started${NC}" @@ -88,7 +92,7 @@ echo -e " http://localhost:8776/v3 (Cinder)" echo -e " http://localhost:9292/v2 (Glance)" echo "" echo -e "✓ Horizon UI: ${GREEN}http://localhost${NC}" -echo -e " Login: admin / secret" +echo -e " Login: admin / $OS_PASSWORD" echo "" echo -e "✓ Validation Log: validation_results_*.txt" echo "" @@ -98,7 +102,7 @@ if [ $VALIDATION_EXIT -eq 0 ]; then echo "" echo -e "${BLUE}Next Steps:${NC}" echo "1. Open Horizon in browser: http://localhost" - echo "2. Login with: admin / secret" + echo "2. Login with: admin / $OS_PASSWORD" echo "3. Test these workflows:" echo " - Launch an instance" echo " - Create a network" From 3f5d89b544d3fba1212a155c3036c62b2255e89e Mon Sep 17 00:00:00 2001 From: Uwe Schwaeke Date: Tue, 13 Oct 2026 13:38:13 +0000 Subject: [PATCH 09/12] =?UTF-8?q?fix(release):=20round-4=20review=20?= =?UTF-8?q?=E2=80=94=20remaining=20credential=20claims=20and=20denylist=20?= =?UTF-8?q?gaps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - F1: HORIZON_SETUP and QUICK_REFERENCE still carried 'Default Credentials: admin/secret' blocks — a credential that can no longer log in to the stack their own quick starts boot (the horizon compose requires a real LIGHTSTACK_ADMIN_PASSWORD and the guard refuses admin/secret). Both blocks now point at the exported password. - F2: the horizon test scripts (horizon_compat, horizon_dashboard, horizon_critical, validation_suite) hardcoded admin/secret with no override — they now prefer OS_PASSWORD / LIGHTSTACK_ADMIN_PASSWORD (the pattern spec007_admin_bootstrap_test.sh already uses), so they keep working against the horizon stack and the hatch-armed dev stacks alike. horizon_critical's single-quoted JSON payloads splice the variable correctly. - F3: CONFIGURATION.md claimed 'there is no env override for these' 400 lines after the same file documented LIGHTSTACK_ADMIN_PASSWORD — reworded. - F4: two more repo-shipped example secrets denylisted (dev-secret-do-not-use-in-prod, USE-STRONG-RANDOM-SECRET) with test coverage. Signed-off-by: Uwe Schwaeke --- docs/CONFIGURATION.md | 3 ++- docs/HORIZON_SETUP.md | 10 ++++++---- docs/QUICK_REFERENCE.md | 6 ++---- internal/common/config.go | 4 ++++ internal/common/config_test.go | 2 ++ test/horizon_compat_test.sh | 2 +- test/horizon_critical_test.sh | 10 +++++++--- test/horizon_dashboard_test.sh | 2 +- test/validation_suite.sh | 2 +- 9 files changed, 26 insertions(+), 15 deletions(-) diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index a81f91bd..417678a1 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -566,7 +566,8 @@ keystone: **⚠️ CRITICAL: Change these in production!** -**Change via the config file** (there is no env override for these — see +**Change via the config file** (the admin password also has an environment +override, `LIGHTSTACK_ADMIN_PASSWORD` — see [Environment Variables](#environment-variables)): ```yaml keystone: diff --git a/docs/HORIZON_SETUP.md b/docs/HORIZON_SETUP.md index ff7c78d6..2b5503c9 100644 --- a/docs/HORIZON_SETUP.md +++ b/docs/HORIZON_SETUP.md @@ -179,15 +179,17 @@ CUSTOM_WELCOME_MESSAGE = "Welcome to lightstack - Lightweight OpenStack" --- -## Default Credentials +## Credentials ```text Domain: Default Username: admin -Password: secret +Password: the LIGHTSTACK_ADMIN_PASSWORD you exported before starting the stack ``` -**⚠️ Change these credentials in production!** +There is no default password — the stack requires a real +`LIGHTSTACK_ADMIN_PASSWORD` and the secret guard refuses the public +`admin`/`secret` pair. --- @@ -199,7 +201,7 @@ Open http://localhost/dashboard (or your configured URL) ### Step 2: Login -Use default credentials or your configured credentials. +Use the credentials you configured when starting the stack (see Credentials below). ### Step 3: Test Functionality diff --git a/docs/QUICK_REFERENCE.md b/docs/QUICK_REFERENCE.md index b36a54fd..d51f272a 100644 --- a/docs/QUICK_REFERENCE.md +++ b/docs/QUICK_REFERENCE.md @@ -158,16 +158,14 @@ tar czf config-backup-$(date +%Y%m%d).tar.gz docker-compose-horizon.yml horizon- cat backup-20260313.sql | docker exec -i lightstack-postgres psql -U lightstack lightstack ``` -## Default Credentials +## Credentials - **Horizon URL**: http://localhost/dashboard - **Domain**: Default - **Username**: admin -- **Password**: secret +- **Password**: the `LIGHTSTACK_ADMIN_PASSWORD` you exported before `up -d` (no default — the guard refuses admin/secret) - **Project**: default -⚠️ **Change these in production!** - ## Production Checklist - [ ] Change postgres password diff --git a/internal/common/config.go b/internal/common/config.go index 2ba3e19e..c06b1c3f 100644 --- a/internal/common/config.go +++ b/internal/common/config.go @@ -463,6 +463,10 @@ var insecureDefaultJWTSecrets = map[string]struct{}{ "change-this-in-production-min-32-chars-required-for-security": {}, // docs/SCALING.md "production-secret-min-32-chars-change-this-immediately": {}, + // docs/CONFIGURATION.md (development-setup example) + "dev-secret-do-not-use-in-prod": {}, + // docs/HORIZON_SETUP.md + "use-strong-random-secret": {}, } // insecureDefaultAdminPasswords are the well-known bootstrap-admin passwords diff --git a/internal/common/config_test.go b/internal/common/config_test.go index 46769e3a..57fffedd 100644 --- a/internal/common/config_test.go +++ b/internal/common/config_test.go @@ -834,6 +834,8 @@ func TestLoadConfigRefusesInsecureDefaultJWTSecret(t *testing.T) { " change-me-in-production ", "change-this-in-production-min-32-chars-required-for-security", // docs/SINGLE_NODE_DEPLOYMENT.md "production-secret-min-32-chars-change-this-immediately", // docs/SCALING.md + "dev-secret-do-not-use-in-prod", // docs/CONFIGURATION.md + "USE-STRONG-RANDOM-SECRET", // docs/HORIZON_SETUP.md } { body := "keystone:\n jwt_secret: \"" + secret + "\"\n" _, err := LoadConfig(writeTestConfig(t, body)) diff --git a/test/horizon_compat_test.sh b/test/horizon_compat_test.sh index 227f78a0..0bff8f5a 100755 --- a/test/horizon_compat_test.sh +++ b/test/horizon_compat_test.sh @@ -25,7 +25,7 @@ FAILED=0 LIGHTSTACK_URL="http://localhost:35357" ADMIN_USER="admin" -ADMIN_PASSWORD="secret" +ADMIN_PASSWORD="${OS_PASSWORD:-${LIGHTSTACK_ADMIN_PASSWORD:-secret}}" PROJECT_NAME="default" print_test() { diff --git a/test/horizon_critical_test.sh b/test/horizon_critical_test.sh index 8ca2cc26..2f92e1d0 100755 --- a/test/horizon_critical_test.sh +++ b/test/horizon_critical_test.sh @@ -17,6 +17,10 @@ fail() { echo -e " ${RED}✗ FAIL${NC}${1:+ - $1}"; FAILED=$((FAILED + 1)); } # Host running Lightstack. Defaults to localhost so this works against the docker-compose stack; # override for a remote host, e.g. LIGHTSTACK_HOST=10.2.199.101 (SPEC-018 T032). LIGHTSTACK_HOST="${LIGHTSTACK_HOST:-localhost}" +# Admin credential: the hatch-armed dev stacks keep the seeded admin/secret; +# the horizon stack requires a real LIGHTSTACK_ADMIN_PASSWORD (BootstrapAdmin +# replaces the seeded hash with it), so prefer OS_PASSWORD / that variable. +ADMIN_PASSWORD="${ADMIN_PASSWORD:-${OS_PASSWORD:-${LIGHTSTACK_ADMIN_PASSWORD:-secret}}}" echo "Testing critical Horizon endpoints..." echo "" @@ -29,7 +33,7 @@ TOKEN=$(curl -s -X POST http://${LIGHTSTACK_HOST}:35357/v3/auth/tokens \ "identity": { "methods": ["password"], "password": { - "user": {"name": "admin", "domain": {"name": "Default"}, "password": "secret"} + "user": {"name": "admin", "domain": {"name": "Default"}, "password": "'"${ADMIN_PASSWORD:-${LIGHTSTACK_ADMIN_PASSWORD:-secret}}"'"} } }, "scope": {"project": {"name": "default", "domain": {"name": "Default"}}} @@ -43,7 +47,7 @@ AUTH_TOKEN=$(curl -s -i -X POST http://${LIGHTSTACK_HOST}:35357/v3/auth/tokens \ "identity": { "methods": ["password"], "password": { - "user": {"name": "admin", "domain": {"name": "Default"}, "password": "secret"} + "user": {"name": "admin", "domain": {"name": "Default"}, "password": "'"${ADMIN_PASSWORD:-${LIGHTSTACK_ADMIN_PASSWORD:-secret}}"'"} } }, "scope": {"project": {"name": "default", "domain": {"name": "Default"}}} @@ -62,7 +66,7 @@ PROJECT_ID=$(curl -s -X POST http://${LIGHTSTACK_HOST}:35357/v3/auth/tokens \ "identity": { "methods": ["password"], "password": { - "user": {"name": "admin", "domain": {"name": "Default"}, "password": "secret"} + "user": {"name": "admin", "domain": {"name": "Default"}, "password": "'"${ADMIN_PASSWORD:-${LIGHTSTACK_ADMIN_PASSWORD:-secret}}"'"} } }, "scope": {"project": {"name": "default", "domain": {"name": "Default"}}} diff --git a/test/horizon_dashboard_test.sh b/test/horizon_dashboard_test.sh index c016292b..d1a4e6ff 100755 --- a/test/horizon_dashboard_test.sh +++ b/test/horizon_dashboard_test.sh @@ -16,7 +16,7 @@ TOTAL=0 LIGHTSTACK_URL="http://localhost:35357" ADMIN_USER="admin" -ADMIN_PASSWORD="secret" +ADMIN_PASSWORD="${OS_PASSWORD:-${LIGHTSTACK_ADMIN_PASSWORD:-secret}}" PROJECT_NAME="default" print_test() { diff --git a/test/validation_suite.sh b/test/validation_suite.sh index 8ab4a8f5..ef4d18b0 100755 --- a/test/validation_suite.sh +++ b/test/validation_suite.sh @@ -27,7 +27,7 @@ echo "" AUTH_URL="${OS_AUTH_URL:-http://localhost:35357/v3}" export OS_AUTH_URL="$AUTH_URL" export OS_USERNAME="${OS_USERNAME:-admin}" -export OS_PASSWORD="${OS_PASSWORD:-secret}" +export OS_PASSWORD="${OS_PASSWORD:-${LIGHTSTACK_ADMIN_PASSWORD:-secret}}" export OS_PROJECT_NAME="${OS_PROJECT_NAME:-default}" export OS_USER_DOMAIN_NAME="${OS_USER_DOMAIN_NAME:-Default}" export OS_PROJECT_DOMAIN_NAME="${OS_PROJECT_DOMAIN_NAME:-Default}" From aa3ea624699a12ae574db8e1c39dc846d4ff3624 Mon Sep 17 00:00:00 2001 From: Uwe Schwaeke Date: Tue, 13 Oct 2026 13:49:07 +0000 Subject: [PATCH 10/12] =?UTF-8?q?fix(release):=20round-5=20review=20?= =?UTF-8?q?=E2=80=94=20last=20two=20credential=20residuals?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - UNIFIED_DEPLOYMENT quick-start Step 5 still printed 'Password: secret' between two blocks that (since round 3) point at the exported LIGHTSTACK_ADMIN_PASSWORD — every user completing the quick start failed login at the final step. - horizon_dashboard_test.sh's success banner still instructed admin/secret after round 4 gave the script real-password support — now prints the credential it actually tested with. Signed-off-by: Uwe Schwaeke --- docs/UNIFIED_DEPLOYMENT.md | 2 +- test/horizon_dashboard_test.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/UNIFIED_DEPLOYMENT.md b/docs/UNIFIED_DEPLOYMENT.md index e29e6cc0..d4f1b1dd 100644 --- a/docs/UNIFIED_DEPLOYMENT.md +++ b/docs/UNIFIED_DEPLOYMENT.md @@ -146,7 +146,7 @@ http://localhost/dashboard **Login Credentials**: - Domain: `Default` - User Name: `admin` -- Password: `secret` +- Password: the `LIGHTSTACK_ADMIN_PASSWORD` you exported in Step 3 🎉 **You're done!** You now have a fully functional OpenStack environment with web UI. diff --git a/test/horizon_dashboard_test.sh b/test/horizon_dashboard_test.sh index d1a4e6ff..806e5aae 100755 --- a/test/horizon_dashboard_test.sh +++ b/test/horizon_dashboard_test.sh @@ -471,7 +471,7 @@ main() { echo "Next steps:" echo " 1. Deploy Horizon with Docker: docker-compose up horizon" echo " 2. Access http://localhost/dashboard" - echo " 3. Login with admin/secret" + echo " 3. Login with admin/$ADMIN_PASSWORD" echo " 4. Test all UI interactions" exit 0 else From c993431aa2f5afe893b3d14e6e377f146efd69a4 Mon Sep 17 00:00:00 2001 From: Uwe Schwaeke Date: Mon, 2 Nov 2026 10:26:42 +0000 Subject: [PATCH 11/12] docs(release): document the 0.7.0 admin-password break; harden the release path Review findings (comprehensive review of the open senolcolak PRs): - MEDIUM: 0.6.x configs have no keystone.admin_password, so script-deployed upgrades crash-loop under the new guard with no documented remedy. Add an UPGRADING.md section (exact error, both recovery routes, no-clobber guarantee), a CHANGELOG breaking-change callout, and an idempotent upgrade-script injection that backs up the config and generates a URL-safe password. - MEDIUM: the release workflow never reconciled Chart.yaml version with the tag; OCI tags are immutable, so the next release would fail after the image push and draft release. Add a pre-flight appVersion check before anything is built, and skip (with a warning) an already-published chart version. - MEDIUM: turnkey wrote real admin/JWT/DB secrets into a 0755 dir/0644 file and both scripts wrote 0644 env files. Use 0700/0600. - LOW: three current-state docs still presented admin/secret; scrub them and the other docs that implied it. - LOW: chart validation ran after the irreversible GHCR push and draft release; move it before the build, pin Helm 3.22.1 and helm-unittest 1.2.1 (matching CI), and clear the actionlint warnings. Signed-off-by: Uwe Schwaeke --- .github/workflows/release.yml | 97 ++++++++++++++++++++++++----------- CHANGELOG.md | 8 +++ README.md | 11 ++-- docs/API.md | 6 +-- docs/CONFIGURATION.md | 17 +++--- docs/HORIZON_DEPLOYMENT.md | 6 +-- docs/HORIZON_INTEGRATION.md | 4 +- docs/INSTALLATION.md | 8 +-- docs/KEYSTONE_AUTH_FLOW.md | 2 +- docs/KUBERNETES_DEPLOYMENT.md | 5 +- docs/QUICKSTART.md | 8 +-- docs/UPGRADING.md | 39 ++++++++++++++ scripts/deploy-single-node.sh | 2 + scripts/deploy-turnkey.sh | 9 +++- scripts/upgrade-lightstack.sh | 60 ++++++++++++++++++++++ 15 files changed, 221 insertions(+), 61 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index edda091e..bad5b030 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,6 +33,11 @@ permissions: env: GO_VERSION: '1.27.2' + # Pinned to the same versions as CI (see the helm-check job in ci.yml). The + # release must not let a runner-preinstalled Helm/plugin decide what gets + # published. + HELM_VERSION: 'v3.22.1' + HELM_UNITTEST_VERSION: 'v1.2.1' jobs: test: @@ -64,7 +69,9 @@ jobs: with: go-version: ${{ env.GO_VERSION }} - name: Run unit tests with race detector - run: go test -race $(go list ./... | grep -v '/test/contract') + run: | + mapfile -t packages < <(go list ./... | grep -v '/test/contract') + go test -race "${packages[@]}" env: LIGHTSTACK_TEST_DB_URL: postgres://lightstack:secret@localhost:5432/lightstack_test?sslmode=disable @@ -90,6 +97,47 @@ jobs: # the full tag (v0.7.0), consistent with `git describe` stamps. run: echo "IMAGE_TAG=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV" + - name: Verify chart version is consistent with the release tag + # Fail before anything is built or published when the chart would ship + # the wrong image tag: appVersion is rendered into the chart, so it has + # to be this release's bare version (`v0.7.0` and `0.7.0` are the same + # version — IMAGE_TAG already has the leading `v` stripped). + # + # Chart.yaml `version` is the OCI tag, and OCI tags are immutable. The + # policy is therefore: bump `version` in Chart.yaml for every chart + # change. The publish step below makes a re-run safe by skipping (with + # a warning) when that version already exists, instead of failing after + # the image push and draft release have already happened. + run: | + APP_VERSION="$(awk '/^appVersion:/ {print $2}' charts/lightstack/Chart.yaml | tr -d '"' | sed 's/^v//')" + if [ "$APP_VERSION" != "${IMAGE_TAG#v}" ]; then + echo "::error::charts/lightstack/Chart.yaml appVersion '${APP_VERSION}' does not match release '${IMAGE_TAG}'" + exit 1 + fi + echo "Chart appVersion ${APP_VERSION} matches the release tag." + + - name: Install pinned Helm and helm-unittest + # Installed into an isolated plugin directory, so a preinstalled Helm 4 + # or plugin on the runner cannot win. No cluster is needed: the next + # step only lints, renders and unit-tests the charts. + run: | + export HELM_PLUGINS="$RUNNER_TEMP/helm-plugins" + echo "HELM_PLUGINS=$HELM_PLUGINS" >> "$GITHUB_ENV" + curl -fsSL -o "$RUNNER_TEMP/get-helm-3" \ + https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 + bash "$RUNNER_TEMP/get-helm-3" --version "$HELM_VERSION" + helm plugin install https://github.com/helm-unittest/helm-unittest \ + --version "$HELM_UNITTEST_VERSION" + helm version --short + + - name: Validate Helm charts before publishing + # The same validation CI runs on every PR (the helm-check job): lint, + # render and unit-test both charts. Chart validation needs no image, so + # it runs before the build and the irreversible GHCR push/draft release + # — a chart that CI would reject stops the release while it is still + # possible to fix it, rather than leaving a partial release behind. + run: make chart-test + - name: Build binaries run: | VERSION="${GITHUB_REF_NAME}" @@ -97,11 +145,11 @@ jobs: for GOOS_GOARCH in linux/amd64 linux/arm64; do GOOS="${GOOS_GOARCH%/*}" GOARCH="${GOOS_GOARCH#*/}" - CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" \ + env CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" \ go build -trimpath \ -ldflags "-s -w -X main.Version=${VERSION}" \ -o "dist/lightstack-${VERSION}-${GOOS}-${GOARCH}" ./cmd/lightstack - CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" \ + env CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" \ go build -trimpath -ldflags "-s -w" \ -o "dist/lightstack-migrate-${VERSION}-${GOOS}-${GOARCH}" ./cmd/lightstack-migrate done @@ -111,14 +159,15 @@ jobs: # into a variable that did not exist, which Go silently ignored. run: | VERSION="${GITHUB_REF_NAME}" - GOT="$(./dist/lightstack-${VERSION}-linux-amd64 --version)" + BINARY="./dist/lightstack-${VERSION}-linux-amd64" + GOT="$("$BINARY" --version)" if [ "$GOT" != "$VERSION" ]; then echo "::error::--version reported '${GOT}', expected '${VERSION}'" exit 1 fi - name: Checksums - run: cd dist && sha256sum * > "checksums-${GITHUB_REF_NAME}.txt" + run: cd dist && sha256sum -- * > "checksums-${GITHUB_REF_NAME}.txt" - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -163,38 +212,26 @@ jobs: dist/lightstack-migrate-${{ github.ref_name }}-*-* dist/checksums-* - # The same validation CI runs on every PR (the helm-check job): lint, - # render and unit-test both charts. The release must not publish a - # chart that CI would have rejected — helm push cannot be undone. - - name: Install Helm and the helm-unittest plugin - run: | - if ! command -v helm >/dev/null 2>&1; then - # Downloaded, not piped: the default run shell is `bash -e` without - # pipefail, so `curl ... | bash` would swallow a failed download. - curl -fsSL -o "$RUNNER_TEMP/get-helm-3" \ - https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 - bash "$RUNNER_TEMP/get-helm-3" - fi - if ! helm plugin list 2>/dev/null | grep -q '^unittest'; then - helm plugin install https://github.com/helm-unittest/helm-unittest - fi - helm version --short - - - name: Validate Helm charts before publishing - run: make chart-test - - name: Publish Helm chart env: GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - # The chart's own version (Chart.yaml `version`) is bumped per chart - # change in the repo; the app version is the bare release version - # (no leading "v"), matching Chart.yaml's appVersion and the image - # tag pushed above. + # Chart.yaml `version` is the chart's OCI tag and is bumped per chart + # change in the repo; `appVersion` is the bare release version (no + # leading "v"), verified against IMAGE_TAG above. OCI tags are + # immutable: if this chart version already exists (a re-run of the + # same tag, or a chart change that forgot the bump), skip the push + # with a warning instead of failing after the image and draft release + # were created. CHART_VERSION="$(awk '/^version:/ {print $2}' charts/lightstack/Chart.yaml)" - helm package charts/lightstack --app-version "${IMAGE_TAG}" -d dist/ + CHART_REF="oci://ghcr.io/${{ github.repository_owner }}/charts/lightstack:${CHART_VERSION}" echo "${GHCR_TOKEN}" | helm registry login ghcr.io \ -u "${{ github.actor }}" --password-stdin + if helm show chart "$CHART_REF" >/dev/null 2>&1; then + echo "::warning::${CHART_REF} already exists; skipping chart push (OCI tags are immutable). Bump charts/lightstack/Chart.yaml version before the next release." + exit 0 + fi + helm package charts/lightstack --app-version "${IMAGE_TAG}" -d dist/ helm push "dist/lightstack-${CHART_VERSION}.tgz" \ "oci://ghcr.io/${{ github.repository_owner }}/charts" # Note: the chart lands in the org-level `charts` OCI namespace diff --git a/CHANGELOG.md b/CHANGELOG.md index 334e1d4b..c4c1d84c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 migrating. - **Chart version** 0.3.0 → 0.4.0 (appVersion 0.7.0, matching the target release). +### ⚠️ Breaking Changes +- **0.6.x → 0.7.0 needs an admin password.** `keystone.admin_password` may no + longer be empty or a well-known default (`secret` included), and configs + written by the 0.6.x deploy scripts contain no such key. Add it (or export + `LIGHTSTACK_ADMIN_PASSWORD` in the service environment) before upgrading; + `scripts/upgrade-lightstack.sh` now injects a generated one, after backing up + the config, when the key is missing. See [docs/UPGRADING.md](docs/UPGRADING.md). + ### 🔒 Security - **Refuse well-known/empty JWT secrets at startup** (review S2): the defaults shipped in `config/lightstack.yaml` and `.env.example` are public, and with diff --git a/README.md b/README.md index a6d0117b..b9bb360b 100644 --- a/README.md +++ b/README.md @@ -390,16 +390,17 @@ make fmt make lint ``` -## Default Credentials +## Credentials -The seed data creates: +The seed data creates the `admin` user and `default` project. The admin password is +the value you set in `keystone.admin_password` (or `LIGHTSTACK_ADMIN_PASSWORD`) before +starting the services; there is no usable public default. The deploy scripts generate +one and save it in `/root/.lightstack-env`. - **User:** `admin` -- **Password:** `secret` +- **Password:** the password you configured - **Project:** `default` -**⚠️ Change these in production!** - ## 📊 Project Status ### API Coverage: 104% (342/330 endpoints) ✅ EXCEEDS BASELINE diff --git a/docs/API.md b/docs/API.md index 6e5d1397..c501eed9 100644 --- a/docs/API.md +++ b/docs/API.md @@ -126,7 +126,7 @@ pip install python-openstackclient # Set environment variables export OS_AUTH_URL=http://localhost:5000/v3 export OS_USERNAME=admin -export OS_PASSWORD=secret +export OS_PASSWORD="${LIGHTSTACK_ADMIN_PASSWORD:?set LIGHTSTACK_ADMIN_PASSWORD}" export OS_PROJECT_NAME=default export OS_USER_DOMAIN_NAME=default export OS_PROJECT_DOMAIN_NAME=default @@ -232,10 +232,10 @@ After project-scoped authentication, the token response includes a service catal } ``` -## Default Credentials +## Credentials - **Username:** `admin` -- **Password:** `secret` +- **Password:** the value of `LIGHTSTACK_ADMIN_PASSWORD` (or `keystone.admin_password`); no public default - **Project:** `default` - **Roles:** `admin`, `member`, `reader` diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index 417678a1..f8708159 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -71,7 +71,7 @@ keystone: jwt_secret: "change-me-in-production" token_ttl: 24h admin_user: admin - admin_password: secret + admin_password: "" # Compute node configuration compute: @@ -321,7 +321,7 @@ keystone: jwt_secret: "change-me-in-production" # JWT signing secret token_ttl: 24h # Token lifetime admin_user: admin # Admin username (first-boot seed) - admin_password: secret # Admin password (first-boot seed) — CHANGE for exposed deployments + admin_password: "" # Admin password (first-boot seed) — required; empty/well-known values are refused ``` **Admin bootstrap (first-boot seed):** `admin_password` is applied at startup only @@ -329,9 +329,9 @@ when the admin account is absent or still carries the well-known default `secret once changed it is never overwritten on later starts (rotate via the Identity API, e.g. `openstack user password set`, not config). Setting `admin_user` to a name other than `admin` provisions that user with the admin role and **disables** the -seeded `admin` account. When `admin_password` is unset entirely, Lightstack boots with the -default credential and logs a `WARN` — the Helm chart is responsible for requiring a -password at install time. +seeded `admin` account. An empty or well-known `admin_password` (including `secret`) +is refused at startup; set it in the file or through `LIGHTSTACK_ADMIN_PASSWORD`. +The Helm chart also requires it at install time. `admin_user` is a **first-boot identity**, not a managed one: - If `admin_user` names an account that **already exists**, that account is granted @@ -556,15 +556,16 @@ head -c 32 /dev/urandom | base64 uuidgen | sha256sum | cut -d' ' -f1 ``` -### Default Credentials +### Admin Credentials ```yaml keystone: admin_user: admin - admin_password: secret + admin_password: "" ``` -**⚠️ CRITICAL: Change these in production!** +**⚠️ There is no usable default: an empty or well-known admin password is refused +at startup.** **Change via the config file** (the admin password also has an environment override, `LIGHTSTACK_ADMIN_PASSWORD` — see diff --git a/docs/HORIZON_DEPLOYMENT.md b/docs/HORIZON_DEPLOYMENT.md index e16bf854..d518a63e 100644 --- a/docs/HORIZON_DEPLOYMENT.md +++ b/docs/HORIZON_DEPLOYMENT.md @@ -236,7 +236,7 @@ http://localhost/dashboard **Login Credentials**: - Domain: `Default` - User Name: `admin` -- Password: `secret` +- Password: the `LIGHTSTACK_ADMIN_PASSWORD` you exported before starting the stack ### Option 2: Development/Testing Setup @@ -336,7 +336,7 @@ docker exec lightstack-horizon curl -s http://lightstack:35357/v3 | jq ### 2. Login Test 1. Navigate to `http://localhost/dashboard` -2. Enter credentials (Domain: Default, User: admin, Password: secret) +2. Enter credentials (Domain: Default, User: admin, Password: the `LIGHTSTACK_ADMIN_PASSWORD` you exported before starting the stack) 3. Verify successful login to Overview page ### 3. Feature Testing @@ -455,7 +455,7 @@ docker exec lightstack-horizon ping -c 3 lightstack ```bash export OS_AUTH_URL=http://localhost:35357/v3 export OS_USERNAME=admin - export OS_PASSWORD=secret + export OS_PASSWORD="${LIGHTSTACK_ADMIN_PASSWORD:?set LIGHTSTACK_ADMIN_PASSWORD}" export OS_PROJECT_NAME=default export OS_USER_DOMAIN_NAME=Default export OS_PROJECT_DOMAIN_NAME=Default diff --git a/docs/HORIZON_INTEGRATION.md b/docs/HORIZON_INTEGRATION.md index 9176a619..78aeb5df 100644 --- a/docs/HORIZON_INTEGRATION.md +++ b/docs/HORIZON_INTEGRATION.md @@ -332,7 +332,7 @@ network: **Problem**: "Invalid credentials" on login **Solutions**: -1. Verify default credentials: `admin` / `secret` / `Default` +1. Verify the credentials you configured: `admin` / `LIGHTSTACK_ADMIN_PASSWORD` / `Default` 2. Check user exists: `sudo -u postgres psql lightstack -c "SELECT name FROM users;"` 3. Verify JWT secret consistency in config @@ -417,7 +417,7 @@ openstack network list ``` **Horizon Dashboard**: -1. Login: http://10.2.199.101/dashboard (admin/secret/Default) +1. Login: http://10.2.199.101/dashboard (admin / the `LIGHTSTACK_ADMIN_PASSWORD` you set / Default) 2. Create network: Project → Network → Networks → Create 3. Launch instance: Project → Compute → Instances → Launch 4. Access console: Click instance → Console tab diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index a0de800c..7b42f38f 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -200,16 +200,18 @@ lightstack --config /etc/lightstack/lightstack.yaml ## First Run -### Default Credentials +### Credentials ``` Domain: Default Username: admin -Password: secret +Password: the admin password you configured Project: default ``` -⚠️ **Change these in production!** +Use the `LIGHTSTACK_ADMIN_PASSWORD` you exported before starting the stack, or the +password generated by `deploy-single-node.sh` / `deploy-turnkey.sh` and saved in +`/root/.lightstack-env`. There is no public default on an exposed deployment. ### Environment Setup diff --git a/docs/KEYSTONE_AUTH_FLOW.md b/docs/KEYSTONE_AUTH_FLOW.md index 8e5d5c3d..1b680e3b 100644 --- a/docs/KEYSTONE_AUTH_FLOW.md +++ b/docs/KEYSTONE_AUTH_FLOW.md @@ -55,7 +55,7 @@ Step 1: User Login ────────────────── User enters credentials in Horizon: - Username: admin - - Password: secret + - Password: the configured admin password - Domain: Default - Project: default (optional for scoped token) diff --git a/docs/KUBERNETES_DEPLOYMENT.md b/docs/KUBERNETES_DEPLOYMENT.md index 9a9e4311..6fc81b87 100644 --- a/docs/KUBERNETES_DEPLOYMENT.md +++ b/docs/KUBERNETES_DEPLOYMENT.md @@ -42,7 +42,7 @@ metadata: ### Secret -Sensitive values (database password, JWT secret) belong in a Secret, not a ConfigMap. +Sensitive values (database password, JWT secret, admin password) belong in a Secret, not a ConfigMap. ```yaml apiVersion: v1 @@ -53,6 +53,7 @@ metadata: type: Opaque stringData: jwt-secret: "replace-with-a-random-256-bit-value" + admin-password: "replace-with-a-random-admin-password" db-password: "replace-with-your-db-password" ``` @@ -87,7 +88,7 @@ data: jwt_secret: "overridden-by-env" token_ttl: 24h admin_user: admin - admin_password: secret + admin_password: "replace-with-a-random-admin-password" compute: node_id: auto diff --git a/docs/QUICKSTART.md b/docs/QUICKSTART.md index 534a4d68..f3159a5a 100644 --- a/docs/QUICKSTART.md +++ b/docs/QUICKSTART.md @@ -466,16 +466,18 @@ openstack quota show --compute # Show resource limits | Glance (Images) | 9292 | http://localhost:9292 | | Metadata | 8775 | http://localhost:8775 | -### Default Credentials +### Credentials ``` Domain: Default Username: admin -Password: secret +Password: the admin password you configured Project: default ``` -⚠️ **Change these in production!** +Use the `LIGHTSTACK_ADMIN_PASSWORD` you exported before starting the stack, or the +password generated by `deploy-single-node.sh` / `deploy-turnkey.sh` and saved in +`/root/.lightstack-env`. There is no public default on an exposed deployment. --- diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index ec063c1d..e9e0568e 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -1,5 +1,44 @@ # Upgrading Lightstack +## Upgrading 0.6.x to 0.7.0: supply an admin password + +0.7.0 refuses to start when `keystone.admin_password` is empty or one of the +well-known values (`secret`, or the placeholders published in the guides). A config +written by the 0.6.x deploy scripts has no `keystone.admin_password` key at all, and +`scripts/upgrade-lightstack.sh` used to preserve the config verbatim — so upgrading +such a node stops at startup with: + +```text +Failed to load config: keystone.admin_password is empty or a well-known default — refusing to start. Set keystone.admin_password in the config file (or the LIGHTSTACK_ADMIN_PASSWORD environment variable) to a random value (it seeds the bootstrap admin account). For isolated development or test environments only, LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1 opts out of this check +``` + +Either route fixes it: + +1. **In the config file** — add the key under `keystone:`: + + ```yaml + keystone: + # ... existing keys ... + admin_password: "" + ``` + +2. **In the service environment** — set `LIGHTSTACK_ADMIN_PASSWORD` (for example in + `/etc/lightstack/lightstack.env`, mode `0600`, referenced by the unit's + `EnvironmentFile=`). A non-empty value overrides `keystone.admin_password` from + the file, which is useful when the config is mounted read-only. + +Then restart the service. Adding the password is safe even if the admin password was +already rotated through the Identity API: `BootstrapAdmin` seeds the configured value +only when the admin account is absent or still carries the public `secret` default. +Once the password is non-default it is never overwritten, so the config value is a +first-boot fallback, not a reconcile. + +`scripts/upgrade-lightstack.sh` now performs route 1 automatically: it detects a +missing `keystone.admin_password`, saves the previous config beside it +(`lightstack.yaml.bak..`), inserts a generated URL-safe password +from `openssl rand -base64 24`, and continues. It does not print the value; read it +from the config if the account was still on the default. + ## Upgrading an install created under the previous product name Lightstack was renamed (`cobaltcore-dev/cloud-storage#575`). The rename moved the diff --git a/scripts/deploy-single-node.sh b/scripts/deploy-single-node.sh index d8a4b244..3caa80e7 100755 --- a/scripts/deploy-single-node.sh +++ b/scripts/deploy-single-node.sh @@ -846,6 +846,8 @@ export OS_PROJECT_DOMAIN_NAME=Default export OS_IDENTITY_API_VERSION=3 EOF + chmod 600 /root/.lightstack-env + # Add to .bashrc if ! grep -q ".lightstack-env" /root/.bashrc; then echo "source /root/.lightstack-env" >> /root/.bashrc diff --git a/scripts/deploy-turnkey.sh b/scripts/deploy-turnkey.sh index 272a01ed..82302806 100755 --- a/scripts/deploy-turnkey.sh +++ b/scripts/deploy-turnkey.sh @@ -626,7 +626,10 @@ generate_config() { else record STATE_CONFIG fi - mkdir -p "$CONFIG_DIR" + # The config holds real secrets (admin password, JWT secret, DB password). + # Keep both the directory and the file private to root: the Lightstack + # container reads them through a read-only bind mount as its own process. + install -d -m 700 "$CONFIG_DIR" # Lightstack main configuration cat > "$CONFIG_DIR/lightstack.yaml" <> /root/.bashrc diff --git a/scripts/upgrade-lightstack.sh b/scripts/upgrade-lightstack.sh index 253d69cf..2e2ddb80 100755 --- a/scripts/upgrade-lightstack.sh +++ b/scripts/upgrade-lightstack.sh @@ -223,6 +223,62 @@ EOF log_info "Kept last 5 backups, removed older ones" } +# 0.7.0's secret guard refuses an empty or well-known keystone.admin_password. +# Configs written by the 0.6.x deploy scripts contain no admin_password key at +# all, and this script preserves the config verbatim, so generate one before the +# service starts. BootstrapAdmin uses it only to seed an admin account that is +# absent or still carries the public `secret` default; a password already +# rotated through the Identity API is never overwritten. +ensure_admin_password() { + if grep -Eq '^[[:space:]]*admin_password[[:space:]]*:' "$CONFIG_FILE"; then + log_info "keystone.admin_password is present in $CONFIG_FILE" + return + fi + + if ! command -v openssl &> /dev/null; then + log_error "openssl not found — cannot generate a keystone.admin_password" + log_error "Add keystone.admin_password to $CONFIG_FILE or export" + log_error "LIGHTSTACK_ADMIN_PASSWORD in the service environment, then re-run." + exit 1 + fi + + local password backup tmp + # URL/newline-safe: command substitution drops the trailing newline, and + # translating +/ keeps the value usable in a URL/query string as well. + password="$(openssl rand -base64 24 | tr -d '\n' | tr '/+' '_-')" + backup="${CONFIG_FILE}.bak.$(date +%Y%m%d-%H%M%S).$$" + cp -a "$CONFIG_FILE" "$backup" + tmp="$(mktemp "${CONFIG_FILE}.tmp.XXXXXX")" + + # Insert directly under the top-level keystone: key, preserving every other + # line and the file's own indentation. + if ! awk -v password="$password" ' + BEGIN { inserted = 0 } + /^[[:space:]]*keystone:[[:space:]]*$/ && !inserted { + print + match($0, /^[[:space:]]*/) + indent = substr($0, 1, RLENGTH) " " + print indent "admin_password: \"" password "\"" + inserted = 1 + next + } + { print } + END { exit inserted ? 0 : 1 } + ' "$CONFIG_FILE" > "$tmp"; then + rm -f "$tmp" + log_error "Could not find a keystone: block in $CONFIG_FILE" + log_error "Add keystone.admin_password manually (previous config: $backup), then re-run." + exit 1 + fi + + chmod --reference="$CONFIG_FILE" "$tmp" + mv -f "$tmp" "$CONFIG_FILE" + + log_success "Generated keystone.admin_password and added it to $CONFIG_FILE" + log_info "Previous configuration saved as $backup" + log_info "The generated value is a first-boot seed only; an already-rotated admin password is left untouched." +} + # Stop Lightstack service stop_service() { if [ "$SERVICE_RUNNING" = true ]; then @@ -561,6 +617,10 @@ main() { # Create backup before any changes create_backup + # 0.7.0 refuses to start without a real keystone.admin_password. Configs + # from 0.6.x have no such key; inject one before the service is touched. + ensure_admin_password + # Stop service stop_service From ed7d5f0923c716541279cc0a3627719327143263 Mon Sep 17 00:00:00 2001 From: Uwe Schwaeke Date: Mon, 2 Nov 2026 10:43:11 +0000 Subject: [PATCH 12/12] ci: move to Go 1.27.3 (GO-2026-6809) and pin Helm 3.22.1 Shared CI unblocker for the open PRs (independent of this PR's content): - govulncheck now reports GO-2026-6809 in crypto/x509 (reachable through the HTTP server), fixed in Go 1.27.3. Main pins 1.27.2 everywhere, so every PR's Runtime Vulnerabilities and SBOM job fails. Pin 1.27.3 in go.mod, tools/go.mod, CI workflows, the builder image, the test container and the single-node deploy script (version + sha256). - The unpinned Helm install now pulls Helm 4, whose 'helm plugin install' rejects the helm-unittest source without --verify=false, failing the Helm Charts job with 'plugin source does not support verification'. Install Helm 3.22.1 and helm-unittest 1.2.1 in an isolated plugin dir, matching PR #107, so the gate is version-stable. Signed-off-by: Uwe Schwaeke --- .github/workflows/ci.yml | 27 +++++++++++++-------------- .github/workflows/release.yml | 2 +- .github/workflows/security.yml | 2 +- build/package/Dockerfile | 2 +- deployments/docker-compose.test.yml | 2 +- docs/MULTIARCH.md | 2 +- docs/security/SBOM_TRIAGE.md | 3 ++- go.mod | 2 +- scripts/deploy-single-node.sh | 4 ++-- tools/go.mod | 2 +- 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8dd960fe..9e0b6806 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v6 with: - go-version: '1.27.2' + go-version: '1.27.3' - name: Cache Go modules uses: actions/cache@v5 @@ -83,7 +83,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v6 with: - go-version: '1.27.2' + go-version: '1.27.3' - name: Cache Go modules uses: actions/cache@v5 @@ -118,7 +118,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v6 with: - go-version: '1.27.2' + go-version: '1.27.3' - name: Cache Go modules uses: actions/cache@v5 @@ -322,6 +322,9 @@ jobs: name: Helm Charts runs-on: ubuntu-latest timeout-minutes: 10 + env: + HELM_VERSION: v3.22.1 + HELM_UNITTEST_VERSION: v1.2.1 steps: - name: Checkout code @@ -329,18 +332,14 @@ jobs: # Same mechanism as `make install-tools`: the official get-helm-3 script plus the # helm-unittest plugin, which `make chart-test` hard-requires (Makefile:103-104). - - name: Install Helm and the helm-unittest plugin + - name: Install pinned Helm and helm-unittest run: | - if ! command -v helm >/dev/null 2>&1; then - # Downloaded, not piped: the default run shell is `bash -e` without pipefail, - # so `curl ... | bash` would swallow a failed download. - curl -fsSL -o "$RUNNER_TEMP/get-helm-3" \ - https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 - bash "$RUNNER_TEMP/get-helm-3" - fi - if ! helm plugin list 2>/dev/null | grep -q '^unittest'; then - helm plugin install https://github.com/helm-unittest/helm-unittest - fi + export HELM_PLUGINS="$RUNNER_TEMP/helm-plugins" + echo "HELM_PLUGINS=$HELM_PLUGINS" >> "$GITHUB_ENV" + curl -fsSL -o "$RUNNER_TEMP/get-helm-3" \ + https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 + bash "$RUNNER_TEMP/get-helm-3" --version "$HELM_VERSION" + helm plugin install https://github.com/helm-unittest/helm-unittest --version "$HELM_UNITTEST_VERSION" helm version --short # Lints + renders + unit-tests both product charts: charts/lightstack, then diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bad5b030..92cb0c14 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,7 +32,7 @@ permissions: contents: read env: - GO_VERSION: '1.27.2' + GO_VERSION: '1.27.3' # Pinned to the same versions as CI (see the helm-check job in ci.yml). The # release must not let a runner-preinstalled Helm/plugin decide what gets # published. diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 2aaaaf58..5bafc671 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -24,7 +24,7 @@ jobs: - name: Set up Go uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: - go-version: '1.27.2' + go-version: '1.27.3' cache: true - name: Scan Go code and pinned development tool diff --git a/build/package/Dockerfile b/build/package/Dockerfile index 3844c8c3..60a465b0 100644 --- a/build/package/Dockerfile +++ b/build/package/Dockerfile @@ -1,5 +1,5 @@ # Multi-stage build for Lightstack - Multi-architecture support -FROM --platform=$BUILDPLATFORM golang:1.27.2-alpine3.24 AS builder +FROM --platform=$BUILDPLATFORM golang:1.27.3-alpine3.24 AS builder # Build arguments for cross-compilation ARG TARGETOS diff --git a/deployments/docker-compose.test.yml b/deployments/docker-compose.test.yml index 929f8fae..64c80599 100644 --- a/deployments/docker-compose.test.yml +++ b/deployments/docker-compose.test.yml @@ -7,7 +7,7 @@ version: '3.8' # OS_PASSWORD="$(...)" docker compose -f deployments/docker-compose.test.yml run --rm test-runner services: test-runner: - image: golang:1.27.2 + image: golang:1.27.3 container_name: lightstack-test-runner working_dir: /workspace volumes: diff --git a/docs/MULTIARCH.md b/docs/MULTIARCH.md index e648a281..6155ed73 100644 --- a/docs/MULTIARCH.md +++ b/docs/MULTIARCH.md @@ -76,7 +76,7 @@ The Dockerfile uses Docker's built-in multi-architecture support: ```dockerfile # Builder stage - runs on native architecture -FROM --platform=$BUILDPLATFORM golang:1.27.2-alpine3.24 AS builder +FROM --platform=$BUILDPLATFORM golang:1.27.3-alpine3.24 AS builder # Build arguments automatically set by Docker ARG TARGETOS # Target OS (linux) diff --git a/docs/security/SBOM_TRIAGE.md b/docs/security/SBOM_TRIAGE.md index 9cd4d3be..797b46d9 100644 --- a/docs/security/SBOM_TRIAGE.md +++ b/docs/security/SBOM_TRIAGE.md @@ -46,7 +46,8 @@ The generated runtime SPDX artifact replaces this export as the release inventor | Go 1.26.2 standard-library advisories | Toolchain affects every binary | Pin Go 1.26.8 in modules, CI, builder image, and test container | | GPL and other linter-only dependencies in the root module | Development-only, not shipped | Move the pinned linter graph to `tools/go.mod` | | Vulnerable transitive modules in the pinned linter graph | Development-only but executed in CI | Upgrade the affected modules and scan the linter command with `govulncheck` | -| GO-2026-6603, -6605, -6607, -6608, -6610, -6611, -6612, -6613, -6617 in the Go 1.26.8 standard library, published 2026-10-08 | Reachable; toolchain affects every binary | Pin Go 1.27.2, the current release, in modules, CI, builder image, test container, and the single-node deploy script | +| GO-2026-6603, -6605, -6607, -6608, -6610, -6611, -6612, -6613, -6617 in the Go 1.26.8 standard library, published 2026-10-08 | Reachable; toolchain affects every binary | Upgrade the toolchain in modules, CI, builder image, test container, and the single-node deploy script; current pin is Go 1.27.3 | +| GO-2026-6809 in `crypto/x509`, detected by CI on 2026-10-30 | Reachable through the HTTP server; Go 1.27.2 trusts compromised intermediate certificates | Pin Go 1.27.3 throughout the build and test toolchain; keep vulnerability scanning enabled | | GO-2026-6603, -6610, -6611, -6612, -6617 in `x/net`, published 2026-10-08 | Reachable through gin's HTTP/2 support | Upgrade transitively from 0.57.0 to 0.60.0; `x/crypto`, `x/sys`, `x/sync`, and `x/text` move to its minimums | ## Triage procedure diff --git a/go.mod b/go.mod index 62a3d15b..11b695b1 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/cobaltcore-dev/lightstack -go 1.27.2 +go 1.27.3 require ( github.com/aws/aws-sdk-go-v2 v1.42.0 diff --git a/scripts/deploy-single-node.sh b/scripts/deploy-single-node.sh index 3caa80e7..e61f3f62 100755 --- a/scripts/deploy-single-node.sh +++ b/scripts/deploy-single-node.sh @@ -477,8 +477,8 @@ build_lightstack() { log_info "Building Lightstack binary..." # Use the same patched toolchain as CI and the release image. - local go_version="1.27.2" - local go_sha256="ecbadb99091a3f46e31f5f934b068b1864eafa7995211b39eaddf76996045fe5" + local go_version="1.27.3" + local go_sha256="65efbc80fdc1fa2cd2631cad5b481777a68e8725f34e89f50fc6ac714e379b40" local installed_go="" if command -v go &> /dev/null; then installed_go=$(go env GOVERSION 2>/dev/null || true) diff --git a/tools/go.mod b/tools/go.mod index fe6322a3..095810b4 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -1,6 +1,6 @@ module github.com/cobaltcore-dev/lightstack/tools -go 1.27.2 +go 1.27.3 tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint