Fix review findings: secrets in snapshots, URL spoofing, migration data loss
Adversarial review of the branch produced findings across four areas. This addresses them, plus the Windows CI environment. Secrets. commit_container_snapshot baked the container's full env into the per-project snapshot image, so the shared OAuth token — and the AWS keys, git token and gateway master key — outlived revocation and were readable via docker inspect. Verified against Engine 29.6 that a commit body's config merges over the container's: keys cannot be dropped but can be overwritten, so all of them now commit as KEY=. clear_claude_token additionally rewrites images from earlier builds and reports honestly when a tag could not be rewritten. The recommendation to move the token out of env entirely was not taken, with reasoning: apiKeyHelper is a different auth method that outranks CLAUDE_CODE_OAUTH_TOKEN rather than a transport for it, and no file-based delivery exists. The durable exposure — the image — is what is closed here. Separately noted, not fixed: entrypoint.sh captures the token into the scheduler's .env inside the persisted volume. URL spoofing. Three call sites reached openUrl with container-controlled strings, one of which the review missed (the WebLinksAddon handler). The sign-in URL was scraped from container output with a longest-match tie-break and no userinfo check, so claude.ai@evil.tld rendered as "claude.ai…" in a truncating element. There is now one sanitizer in front of every sink — scheme allowlist, no userinfo, C0/C1 and quote rejection, host allowlist for the sign-in case, first-match — and the origin renders un-truncated. The toast is keyed so a changed URL remounts, closing a bait-and-switch where the user read one URL and clicked another. Migration. The rollback pin was best-effort: a tag failure was logged and the migration continued past remove_container, after which the final commit overwrote the only copy of the old system layer. It now aborts before anything destructive and reads the tag back. /var was destroyed while the ordinary recreate path preserves it — making the "safe" alternative to Reset more destructive than Reset's alternative; data-bearing subtrees are now detected and disclosed in the pre-flight rather than copied, since tarring a live database onto a different base's packages is a corruption risk. resume_migration now verifies the migration-state label instead of reporting success for a container that never swapped. dismiss actually resolves the record rather than leaving the feature permanently refusing to migrate. Start and Reset are guarded while a migration is live. Lifecycle. The gateway no longer publishes on 0.0.0.0 — bind address and advertised URL are derived together so they cannot drift. Disabling it now stops it. App exit runs teardown concurrently under a budget with a visible shutting-down state instead of blocking for minutes. Auto-starts retry when Docker is not up yet, and the polling-recovery path now reconciles, so interrupted migrations are still recovered. Auth-bridge forwards are capped, closing a container-driven fd exhaustion. Windows CI. build-windows failed on this branch with "linker link.exe not found". The runner had no MSVC build tools and the workflow assumed a hand-provisioned machine, so a bare runner registers, accepts jobs and fails at link time after downloading the whole crate graph. The job now installs the VC++ workload when vswhere cannot find it, matching how it already conditionally installs Rust and Node. 192 Rust tests, 274 frontend tests, both builds clean, zero warnings. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -28,9 +28,26 @@
|
||||
//!
|
||||
//! What is genuinely lost is confined to the container's writable layer:
|
||||
//! root-level `apt` installs, `npm -g` packages (npm's prefix is `/usr`),
|
||||
//! `/usr/local`, `/opt`, `/srv`, and anything under `/workspace` that is not on
|
||||
//! a bind mount. Those four categories are exactly what
|
||||
//! [`MigrationOptions`] can replay.
|
||||
//! `/usr/local`, `/opt`, `/srv`, anything under `/workspace` that is not on a
|
||||
//! bind mount — and **`/var`**. The first four are what [`MigrationOptions`]
|
||||
//! can replay. `/var` is not, and that gap is deliberate rather than an
|
||||
//! oversight, so it is stated here rather than glossed over:
|
||||
//!
|
||||
//! Service state lives in `/var/lib/<service>` and `/var/www`. Replaying the
|
||||
//! apt delta reinstalls `postgresql` onto the new base and hands back an
|
||||
//! **empty** cluster; the old one is gone with the writable layer. The
|
||||
//! ordinary recreate path does not have this problem, because it creates from
|
||||
//! the project's own snapshot and `/var` rides along — so a silent migration
|
||||
//! would be *more* destructive than the thing it is sold as a safer
|
||||
//! alternative to.
|
||||
//!
|
||||
//! Copying a live database's files out with `tar` and unpacking them onto a
|
||||
//! different base's version of the same package is not a fix; it is a
|
||||
//! corruption risk wearing a fix's clothes. So the answer is disclosure:
|
||||
//! [`crate::docker::migration::unpreserved_data`] finds the data-bearing
|
||||
//! subtrees under `/var` that the base does not ship, and
|
||||
//! [`ContainerStaleness::unpreserved_data`] carries them into the pre-flight,
|
||||
//! where the user is told to back them up before anything is touched.
|
||||
//!
|
||||
//! ## Serde
|
||||
//!
|
||||
@@ -67,6 +84,20 @@ pub struct PackageFailure {
|
||||
pub reason: String,
|
||||
}
|
||||
|
||||
/// A data-bearing subtree the migration will destroy and cannot put back.
|
||||
///
|
||||
/// See [`crate::docker::migration::unpreserved_data`]. Surfaced in the
|
||||
/// pre-flight so the user can take a backup first; never copied.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct UnpreservedData {
|
||||
/// Absolute path of the directory, e.g. `/var/lib/postgresql`.
|
||||
pub path: String,
|
||||
/// Total size of the non-package files beneath it.
|
||||
pub bytes: u64,
|
||||
/// How many non-package files it holds.
|
||||
pub file_count: u32,
|
||||
}
|
||||
|
||||
/// Everything the UI needs to decide whether a project is worth migrating, and
|
||||
/// to explain to the user what migrating would actually change.
|
||||
///
|
||||
@@ -102,6 +133,12 @@ pub struct ContainerStaleness {
|
||||
/// Non-dpkg-owned paths under the verbatim-copy roots that would be carried
|
||||
/// across. Empty when nothing user-authored was found.
|
||||
pub verbatim_paths: Vec<String>,
|
||||
/// Data-bearing subtrees under `/var` that a migration **destroys and
|
||||
/// cannot restore** — a database's files, a served site. Empty on an
|
||||
/// ordinary container; when it is not, the pre-flight has to say so before
|
||||
/// anything is touched. See [`UnpreservedData`].
|
||||
#[serde(default)]
|
||||
pub unpreserved_data: Vec<UnpreservedData>,
|
||||
/// dpkg packages the current base carries at a different version than this
|
||||
/// container does. A rough "how much security drift" number, not a promise
|
||||
/// that every one of them is newer.
|
||||
@@ -178,6 +215,11 @@ pub struct MigrationPlan {
|
||||
/// Base-image paths the old container lacked, so the finished migration can
|
||||
/// report which of them it actually gained.
|
||||
pub missing_paths: Vec<String>,
|
||||
/// What the pre-flight found under `/var` that the migration would destroy.
|
||||
/// Frozen here so the finished report can name it even though the container
|
||||
/// it was measured on no longer exists.
|
||||
#[serde(default)]
|
||||
pub unpreserved_data: Vec<UnpreservedData>,
|
||||
}
|
||||
|
||||
/// Persisted, host-side migration state. Written **before** anything
|
||||
|
||||
Reference in New Issue
Block a user