tools: update inside LXC and use the existing proxy #22

Merged
schmidt.florian merged 2 commits from 21-external-proxy into master 2026-11-15 13:06:06 +01:00
Owner

Closes #21

What and why

The previous installer added Caddy without the user requesting it, duplicating their existing reverse proxy. Updates also required the Proxmox host checkout. Version 1.2.1 corrects both:

  • The host installer creates the CT only; new installs expose private HTTP :5187 behind the user's existing HTTPS proxy and never install/configure/start a proxy.
  • finaltoken-update runs as root inside the CT. It downloads fresh anonymous source, reuses the shared bounded source bundle and isolated guest build/activation, and updates its own active-release command. Root updater bytes are captured directly from the verified archive before build handoff; build-owned updater source/output is never installed. No Proxmox host commands or host checkout are required.
  • Existing 1.2.0 containers bootstrap the new command once inside the CT. The update preserves identity/configuration/history, changes only the known loopback listener, checks backend health and disables only finaltoken-proxy.service. It backs up the environment, restores it/service states on migration failure, preserves stopped backends, and leaves custom listeners, unrelated proxy services, packages and certificate data alone.
  • The old host update command refuses deployment and explains the new entry point. Deployment docs include the in-container bootstrap and external proxy target.

Decisions

D14 and R8 now record the user's explicit deployment direction: existing HTTPS reverse proxy, private backend, in-container updates. D1/D2/D5/D6 remain in force. No application analysis/login logic is changed. Python 3 was already required in the CT; Git is a newly explicit CT package dependency for anonymous source updates. No NuGet package is added.

How it was tested

Failing regressions first reproduced Caddy being installed, the unwanted loopback listener and proxy service management. Byte-preservation/rollback regressions then exposed Windows newline conversion before that was fixed.

  • dotnet build FinalToken.slnx -c Release: 0 warnings/errors.
  • dotnet test --solution FinalToken.slnx -c Release: 431 passed, 0 failed/skipped.
  • python -B tools/proxmox/test_installer.py: 35 passed, including no-proxy defaults, key/config/line-ending preservation, migration rollback, stopped/custom listener handling, updater-file ownership and offline real npm.
  • python -B tools/proxmox/test_update.py: 7 passed; real local Git source refresh through the in-container updater with a synthetic guest provisioner; non-root/foreign/missing CT refusal, dry-run, busy/fetch/build failures and CT-only Git bootstrap.
  • python -B tools/docs/check_docs.py: 0 errors.
  • Bash syntax checks for both entry files, git diff --check, and host server-install dry-run: passed.
  • python -B tools/check_public.py --history: 0 recognized pattern findings.

Proxmox, apt/systemd, NativeAOT publishing and Linux locking are substituted in these tests. The npm fixture runs on Windows with its documented prefix adaptation. No real container migration, Linux build, external-proxy TLS path or provider login was exercised; no live host/container was modified. No view changes or repeated browser QA.

Closes #21 ## What and why The previous installer added Caddy without the user requesting it, duplicating their existing reverse proxy. Updates also required the Proxmox host checkout. Version 1.2.1 corrects both: - The host installer creates the CT only; new installs expose private HTTP :5187 behind the user's existing HTTPS proxy and never install/configure/start a proxy. - `finaltoken-update` runs as root inside the CT. It downloads fresh anonymous source, reuses the shared bounded source bundle and isolated guest build/activation, and updates its own active-release command. Root updater bytes are captured directly from the verified archive before build handoff; build-owned updater source/output is never installed. No Proxmox host commands or host checkout are required. - Existing 1.2.0 containers bootstrap the new command once inside the CT. The update preserves identity/configuration/history, changes only the known loopback listener, checks backend health and disables only `finaltoken-proxy.service`. It backs up the environment, restores it/service states on migration failure, preserves stopped backends, and leaves custom listeners, unrelated proxy services, packages and certificate data alone. - The old host update command refuses deployment and explains the new entry point. Deployment docs include the in-container bootstrap and external proxy target. ## Decisions D14 and R8 now record the user's explicit deployment direction: existing HTTPS reverse proxy, private backend, in-container updates. D1/D2/D5/D6 remain in force. No application analysis/login logic is changed. Python 3 was already required in the CT; Git is a newly explicit CT package dependency for anonymous source updates. No NuGet package is added. ## How it was tested Failing regressions first reproduced Caddy being installed, the unwanted loopback listener and proxy service management. Byte-preservation/rollback regressions then exposed Windows newline conversion before that was fixed. - `dotnet build FinalToken.slnx -c Release`: 0 warnings/errors. - `dotnet test --solution FinalToken.slnx -c Release`: 431 passed, 0 failed/skipped. - `python -B tools/proxmox/test_installer.py`: 35 passed, including no-proxy defaults, key/config/line-ending preservation, migration rollback, stopped/custom listener handling, updater-file ownership and offline real npm. - `python -B tools/proxmox/test_update.py`: 7 passed; real local Git source refresh through the in-container updater with a synthetic guest provisioner; non-root/foreign/missing CT refusal, dry-run, busy/fetch/build failures and CT-only Git bootstrap. - `python -B tools/docs/check_docs.py`: 0 errors. - Bash syntax checks for both entry files, `git diff --check`, and host server-install dry-run: passed. - `python -B tools/check_public.py --history`: 0 recognized pattern findings. Proxmox, apt/systemd, NativeAOT publishing and Linux locking are substituted in these tests. The npm fixture runs on Windows with its documented prefix adaptation. No real container migration, Linux build, external-proxy TLS path or provider login was exercised; no live host/container was modified. No view changes or repeated browser QA.
schmidt.florian added the type/bugtype/decisiontype/tooling labels 2026-11-15 12:50:45 +01:00
schmidt.florian added 1 commit 2026-11-15 12:50:46 +01:00
Keep the Proxmox host responsible only for container creation. Serve the private backend on port 5187 behind the operator's HTTPS proxy and install a self-updating in-container command. Preserve existing identity and history while migrating the old installer-owned proxy with listener rollback.

Refs #21
Author
Owner

Agent review: fail on 7b70c7a0fa

Blocking

  1. [P1] Keep the root updater out of the build user's writable source. tools/proxmox/guest.py:218: build() chowns the extracted source tree to finaltoken-build, runs dotnet publish as that user, and then copies source/tools/lxc_update.py into the release as finaltoken-update. That script is subsequently exposed through /usr/local/sbin/finaltoken-update and explicitly run as root. A compromised build dependency/task or build-user process can replace the writable source script during publishing and gain root on the next update. Root ownership of the final copy does not restore trust in its contents. I reproduced this using the existing synthetic-publish seam: the archive contained a trusted updater; the mocked build step replaced its extracted source; production guest.build() installed the replacement unchanged. Preserve the updater bytes in a root-controlled location or memory before handing source to the build user, and install only those trusted bytes. Add a regression in which publishing changes the extracted updater and confirm the installed command still matches the trusted archive.

Notes

  • No real Debian/LXC update, apt/systemd migration, NativeAOT publish, Linux advisory locking or external-proxy TLS route was exercised. The PR describes these limits accurately. Live validation remains necessary for confidence in deployment behavior.

Checked

Reviewed commit 7b70c7a0fa130658bc8dfd55e12ca4992d127154 in a separate detached worktree. Read PR #22, issue #21 and its comments, root/tool rules, Project Mind, requirements, applicable decisions (including the D14 change), the full diff and installer/updater activation/migration paths. There were no earlier PR review comments.

Commands run from the review worktree:

  • dotnet build FinalToken.slnx -c Release: passed, 0 warnings/errors.
  • dotnet test --solution FinalToken.slnx -c Release: 431 passed, 0 failed/skipped.
  • python -B tools/proxmox/test_installer.py: 34 passed.
  • python -B tools/proxmox/test_update.py: 7 passed.
  • python -B tools/docs/check_docs.py: 0 errors.
  • bash -n tools/proxmox.sh and bash -n tools/proxmox-update.sh: passed.
  • git diff --check origin/master...HEAD: passed.
  • Additional provider-free Python reproduction through production guest.build(), with OS ownership and native publishing substituted: confirmed that changing the updater in the build-owned source installs the changed root command. This checks the copy/trust path; it is not a live Linux privilege-escalation test.

No tracked files were changed.

**Agent review: fail** on 7b70c7a0fa130658bc8dfd55e12ca4992d127154 ## Blocking 1. **[P1] Keep the root updater out of the build user's writable source.** `tools/proxmox/guest.py:218`: `build()` chowns the extracted source tree to `finaltoken-build`, runs `dotnet publish` as that user, and then copies `source/tools/lxc_update.py` into the release as `finaltoken-update`. That script is subsequently exposed through `/usr/local/sbin/finaltoken-update` and explicitly run as root. A compromised build dependency/task or build-user process can replace the writable source script during publishing and gain root on the next update. Root ownership of the final copy does not restore trust in its contents. I reproduced this using the existing synthetic-publish seam: the archive contained a trusted updater; the mocked build step replaced its extracted source; production `guest.build()` installed the replacement unchanged. Preserve the updater bytes in a root-controlled location or memory before handing source to the build user, and install only those trusted bytes. Add a regression in which publishing changes the extracted updater and confirm the installed command still matches the trusted archive. ## Notes - No real Debian/LXC update, apt/systemd migration, NativeAOT publish, Linux advisory locking or external-proxy TLS route was exercised. The PR describes these limits accurately. Live validation remains necessary for confidence in deployment behavior. ## Checked Reviewed commit `7b70c7a0fa130658bc8dfd55e12ca4992d127154` in a separate detached worktree. Read PR #22, issue #21 and its comments, root/tool rules, Project Mind, requirements, applicable decisions (including the D14 change), the full diff and installer/updater activation/migration paths. There were no earlier PR review comments. Commands run from the review worktree: - `dotnet build FinalToken.slnx -c Release`: passed, 0 warnings/errors. - `dotnet test --solution FinalToken.slnx -c Release`: 431 passed, 0 failed/skipped. - `python -B tools/proxmox/test_installer.py`: 34 passed. - `python -B tools/proxmox/test_update.py`: 7 passed. - `python -B tools/docs/check_docs.py`: 0 errors. - `bash -n tools/proxmox.sh` and `bash -n tools/proxmox-update.sh`: passed. - `git diff --check origin/master...HEAD`: passed. - Additional provider-free Python reproduction through production `guest.build()`, with OS ownership and native publishing substituted: confirmed that changing the updater in the build-owned source installs the changed root command. This checks the copy/trust path; it is not a live Linux privilege-escalation test. No tracked files were changed.
schmidt.florian added 1 commit 2026-11-15 13:00:26 +01:00
Capture the updater from the verified source archive before unprivileged build handoff. Exclude build-supplied updater files from copied artifacts and atomically install the trusted command in the root-owned release. Cover source and output replacement with an adversarial publishing regression.

Refs #21
Author
Owner

Fixed the blocking root-updater trust issue in b404d75.

The new adversarial regression first replaced both source/tools/lxc_update.py and the build output's finaltoken-update during synthetic publishing. It failed against 7b70c7a: the installed root command was the replacement.

build() now captures the updater directly from the verified root-owned archive before extracting/chowning build source. Build-supplied updater files are excluded from output copying. Only the captured trusted content is atomically written into the locked-down root-owned destination after artifact copying/validation. The unprivileged build never supplies the root command, including by changing the extracted source.

The regression now passes. python -B tools/proxmox/test_installer.py: 35 passed; python -B tools/proxmox/test_update.py: 7 passed; Release build: 0 warnings/errors; docs and whitespace checks pass. The earlier full solution run remains 431 passed with no C# behavior change. Real Linux privilege escalation/deployment was not exercised; the regression uses the existing substituted publish/ownership seam.

Requesting the required fresh re-review of the fixed head under docs/agents/review.md.

Fixed the blocking root-updater trust issue in b404d75. The new adversarial regression first replaced both `source/tools/lxc_update.py` and the build output's `finaltoken-update` during synthetic publishing. It failed against 7b70c7a: the installed root command was the replacement. `build()` now captures the updater directly from the verified root-owned archive before extracting/chowning build source. Build-supplied updater files are excluded from output copying. Only the captured trusted content is atomically written into the locked-down root-owned destination after artifact copying/validation. The unprivileged build never supplies the root command, including by changing the extracted source. The regression now passes. `python -B tools/proxmox/test_installer.py`: 35 passed; `python -B tools/proxmox/test_update.py`: 7 passed; Release build: 0 warnings/errors; docs and whitespace checks pass. The earlier full solution run remains 431 passed with no C# behavior change. Real Linux privilege escalation/deployment was not exercised; the regression uses the existing substituted publish/ownership seam. Requesting the required fresh re-review of the fixed head under docs/agents/review.md.
Author
Owner

Agent review: pass on b404d75fe8

## Blocking

None. The blocking finding from the failed review of 7b70c7a0fa is fixed. build() captures the updater from the verified archive before build-user handoff, excludes build-supplied updater files from artifact copying, and atomically installs the captured content in the root-owned release. The adversarial regression replaces both extracted source and build output and confirms that the installed updater retains the trusted content.

Notes

  • No real Linux/LXC migration, apt/systemd operation, NativeAOT publishing, Linux advisory locking, external-proxy TLS route or provider login was exercised. Ownership and publishing are substituted in the regression. The PR accurately describes these limits.

Checked

Reviewed b404d75fe8 in a separate detached worktree. Read PR #22, linked issue #21 and its comments, the previous failed review and author's response, root and Proxmox rules, Project Mind, requirements, applicable decisions including D1/D2/D5/D6/D14, and the full diff for context. Blocking review scope followed docs/agents/review.md step 5: the prior blocking finding and the author's commit since the reviewed 7b70c7a, excluding master.

Commands run from the review worktree:

  • dotnet build FinalToken.slnx -c Release: passed, 0 warnings/errors.
  • dotnet test --solution FinalToken.slnx -c Release: 431 passed, 0 failed/skipped.
  • python -B tools/proxmox/test_installer.py: 35 passed, including the new adversarial updater regression.
  • python -B tools/proxmox/test_update.py: 7 passed.
  • python -B tools/docs/check_docs.py: 0 errors.
  • bash -n tools/proxmox.sh and bash -n tools/proxmox-update.sh: passed.
  • git diff --check origin/master...HEAD: passed.
  • Ran the new adversarial regression against the previous guest implementation loaded from 7b70c7a: it failed with the installed malicious replacement, as expected. The initial Windows harness import lacked Linux's pwd module; rerunning with the same substituted module used by the test suite reproduced the expected failure. No production files were altered.

No tracked files were changed.

**Agent review: pass** on b404d75fe806bb8b1331b5ac5d7033fe1462d32c ## Blocking None. The blocking finding from the failed review of 7b70c7a0fa130658bc8dfd55e12ca4992d127154 is fixed. `build()` captures the updater from the verified archive before build-user handoff, excludes build-supplied updater files from artifact copying, and atomically installs the captured content in the root-owned release. The adversarial regression replaces both extracted source and build output and confirms that the installed updater retains the trusted content. ## Notes - No real Linux/LXC migration, apt/systemd operation, NativeAOT publishing, Linux advisory locking, external-proxy TLS route or provider login was exercised. Ownership and publishing are substituted in the regression. The PR accurately describes these limits. ## Checked Reviewed b404d75fe806bb8b1331b5ac5d7033fe1462d32c in a separate detached worktree. Read PR #22, linked issue #21 and its comments, the previous failed review and author's response, root and Proxmox rules, Project Mind, requirements, applicable decisions including D1/D2/D5/D6/D14, and the full diff for context. Blocking review scope followed docs/agents/review.md step 5: the prior blocking finding and the author's commit since the reviewed 7b70c7a, excluding master. Commands run from the review worktree: - `dotnet build FinalToken.slnx -c Release`: passed, 0 warnings/errors. - `dotnet test --solution FinalToken.slnx -c Release`: 431 passed, 0 failed/skipped. - `python -B tools/proxmox/test_installer.py`: 35 passed, including the new adversarial updater regression. - `python -B tools/proxmox/test_update.py`: 7 passed. - `python -B tools/docs/check_docs.py`: 0 errors. - `bash -n tools/proxmox.sh` and `bash -n tools/proxmox-update.sh`: passed. - `git diff --check origin/master...HEAD`: passed. - Ran the new adversarial regression against the previous guest implementation loaded from 7b70c7a: it failed with the installed malicious replacement, as expected. The initial Windows harness import lacked Linux's `pwd` module; rerunning with the same substituted module used by the test suite reproduced the expected failure. No production files were altered. No tracked files were changed.
schmidt.florian merged commit 43caf1e412 into master 2026-11-15 13:06:05 +01:00
schmidt.florian deleted branch 21-external-proxy 2026-11-15 13:06:08 +01:00
Sign in to join this conversation.