Skip to content

fix(start-os): keep the SMTP password out of the public database - #4943

Closed
MattDHill wants to merge 1 commit into
masterfrom
fix/smtp-password-private-master
Closed

MattDHill wants to merge 1 commit into
masterfrom
fix/smtp-password-private-master

Conversation

@MattDHill

@MattDHill MattDHill commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Browsers can no longer read the saved SMTP password from the server's public database. serverInfo is sent to every signed-in browser and cached there, and until now it carried the password in plain text.

What users see:

  • System → SMTP no longer prefills the password. When one is saved, the page says so. Leaving Password empty keeps it, and Remove saved password clears it.
  • Test email uses the saved password when the field is left empty.
  • Services that use the system SMTP settings still receive the password through get-system-smtp, and their callbacks still fire when the settings change.

History

This change first merged as #4892, into integration/registry-cache-sync. #4903 took it back out of that branch so #4898 would stay focused on registry sync. #4898 has since merged to master, and this PR lands the SMTP change on master on its own. A researcher asked on #4903 whether the change was still planned. This PR is the answer.

@dr-bonez, I read #4903 as keeping the omnibus focused rather than an objection to the change itself; if you had a concern with the approach, say so here.

Changes

The code is #4892's, adapted to current master:

  • Storage. The full settings, password included, move to private.smtp. serverInfo.smtp becomes SmtpInfo: host, port, from, username, security and passwordSet.
  • server.set-smtp takes SetSmtpParams: the existing SmtpValue flattened, so the server/login aliases still work, plus keepPassword (CLI --keep-password). With it set and no password given, the saved password is kept. Without it, a missing password means no password, as before. Adopted from helix-white's review proposal, with tests for canonical and legacy requests.
  • server.test-smtp's password is now optional. If it is omitted, the saved password is used, but only when the host, port and username match the saved settings. A test against another host therefore can't extract it.
  • get-system-smtp reads and watches private.smtp.
  • Migration: 0.4.3 goes to revision 5. fix(start-os): keep the SMTP password out of the public database #4892 used revision 4, but on master revision 4 is now feat(start-os): enforce unique shared-volume names #4901's shared-volume rename. up() copies an existing public SMTP value to private.smtp and replaces password with passwordSet. It skips a value that already has passwordSet, so it is idempotent with revision 4. down() restores the public value. The revision-queueing test now covers revisions 0 through 4. Three tests cover the move, an unset password, and a server with no SMTP configured.
  • UI strings. The two new web strings take IDs 1315/1316, after the strings master gained since fix(start-os): keep the SMTP password out of the public database #4892.
  • Supporting changes. The smtp.test.mjs stub now exports escapeHtml, which the component has imported since fix(web): render package text as sanitized markdown, OS-interpolated values as plain text #4907. The CLI reference and the SMTP guide describe the new behavior. fix(start-os): keep the SMTP password out of the public database #4892's security changelog fragment is included, because the exposure predates this release.

Generated artifacts

The man pages, TS bindings and MCP catalog carry #4892's regenerated output, merged onto master. The one conflict was ServerInfo.smtp in types.schemas.ts, which I resolved to master's codegen style. CI's start-core Tests & Man Pages and Generated Bindings & MCP Catalog jobs are the first real regeneration. If either reports drift, I'll commit its uploaded output.

Verification

  • make start-core-format-check: clean.
  • npm run check:i18n: all keys valid.
  • npm run build:deps && npm run check:ui: the typecheck passes, and 349 of 349 tests pass after the escapeHtml stub fix.
  • Prettier is clean.
  • No local Rust compile or test was run, so CI is the first build.

review effort: 'xhigh'

🤖 Generated with Claude Code

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 — Preserve the existing SMTP setter aliases (shared-libs/crates/start-core/src/system/mod.rs:1288–1296). The previous server.set-smtp parameter type, SmtpValue, accepts server for host and login for username. SetSmtpParams drops both aliases, so an existing valid request such as {"server":"smtp.example.com","port":587,"from":"a@example.com","login":"a"} now fails deserialization. Moving the password out of the public database does not require breaking these callers.

The proposal flattens the existing SmtpValue into SetSmtpParams, keeping the field names, aliases, defaults and CLI definitions owned in one place. It adds regression cases for canonical and legacy requests, including password retention. The proposal is unbuilt and untested, as required for review proposals; its generated bindings, MCP catalog and man pages have not been regenerated.

I also traced migration/revision handling, private SMTP reads and callbacks, password retention, test-email credential selection, and the UI's save/reset behavior. The reviewed head merges cleanly with master. CI was still running when inspected; this verdict does not depend on its completion.

Proposed changes: e837bcb...proposal/4943

To adopt the proposal, cherry-pick it onto your branch rather than merging or pulling it, so the PR's head stays your own commit:

git fetch https://github.com/Start9Labs/start-technologies.git proposal/4943
git cherry-pick e837bcbd9d625029ff358e9c3bac809c1a9c66b3..FETCH_HEAD

If your branch has moved since e837bcbd9d625029ff358e9c3bac809c1a9c66b3, resolve any conflicts the cherry-pick reports, or apply the changes your own way. Then push and say so in a comment.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

MattDHill pushed a commit that referenced this pull request Nov 25, 2026
SetSmtpParams flattens SmtpValue instead of restating its fields, so
set-smtp still accepts `server` for `host` and `login` for `username`.
Adopted from helix-white's review proposal on #4943.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MattDHill

Copy link
Copy Markdown
Member Author

@helix-red please regenerate the TS bindings, CLI man pages and MCP catalog for this branch (make start-core-ts-bindings and whatever else the Generated Bindings & MCP Catalog job checks), commit them signed, and push them to fix/smtp-password-private-master. Then request helix-white's review.

@helix-red
helix-red removed the request for review from dr-bonez November 25, 2026 18:06
@helix-red
helix-red dismissed helix-white’s stale review November 25, 2026 18:10

Dismissed by Helix: the changes require a substantive PR brief update. The new head restores server.set-smtp's server/login aliases through flattened SmtpValue, changing legacy requests from rejected to accepted and addressing the review's finding. The substantive compatibility explanation must now state that those existing RPC inputs remain supported.

@helix-red

Copy link
Copy Markdown
Contributor

Regenerated the TS osBindings, MCP tool catalog and start-cli server set-smtp man page with make start-core-mcp-tools manpages, the same targets that Generated Bindings & MCP Catalog and manpages-check check, on top of the adopted alias-preserving proposal (0504162). They're in signed commit b15132d. The diff reorders --keep-password after --security in the man page and adds the server/login aliases to the schemas and catalog. SetSmtpParams stays exported.

@helix-red

Copy link
Copy Markdown
Contributor

The start-core Tests & Man Pages failure ran on the previous head, 0504162. It reported start-cli-server-set-smtp.1 as out of date, which is exactly the drift that b15132d commits, so no further change is needed. CI is re-running on b15132d.

Re-lands #4892 on master; #4903 took it back out of
integration/registry-cache-sync so #4898 carried no SMTP change.

The full SMTP settings move to private.smtp; serverInfo.smtp becomes
SmtpInfo (no password, plus passwordSet). set-smtp takes keepPassword,
test-smtp falls back to the saved password when host, port and username
match, and get-system-smtp watches private.smtp. The SMTP page no longer
prefills the password, notes when one is saved and can remove it.

The 0.4.3 migration goes to revision 5 (master's revision 4 is the
shared-volume rename); hide_smtp_password skips a value that already has
passwordSet, so it is idempotent with revision 4. The new web strings
take IDs 1315/1316.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: helix-white <267227783+helix-a@users.noreply.github.com>
Co-Authored-By: helix-red <355572797+helix-red@users.noreply.github.com>
@MattDHill
MattDHill force-pushed the fix/smtp-password-private-master branch from b15132d to 3131d1c Compare November 25, 2026 18:17
@MattDHill

Copy link
Copy Markdown
Member Author

@helix-white the branch is now one commit authored by Matt, folding in your proposal/4943 change and helix-red's regenerated bindings (both credited as co-authors); the tree is identical to helix-red's push. Please re-review.

@MattDHill
MattDHill requested a review from dr-bonez November 25, 2026 18:17
@MattDHill

Copy link
Copy Markdown
Member Author

Closing: SMTP is being reworked as a whole in an upcoming PR, which will keep the password out of the public database as part of that change and improve the UX at the same time. Re-landing this separately would only conflict with it.

@MattDHill MattDHill closed this Nov 25, 2026

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at 3131d1c2f. The alias-preserving change addresses my earlier finding, and the regenerated schemas, MCP catalog and man page match that change. The branch merges cleanly with master.

Brief

  • The public database stops distributing the saved SMTP password to browsers. Full credentials live in private.smtp; the public summary reports whether a password is saved. Services retain their existing secret-bearing get-system-smtp effect and watch the private value, including password-only changes.
  • System → SMTP leaves Password blank. Saving with it blank retains the password; Remove saved password marks it for removal on Save. Cancel abandons that removal. A test email can use the saved password only when host, port and username match. CLI/RPC callers must explicitly request retention; omitting both the password and retention still clears the password. The existing server/login aliases remain accepted through the reused SmtpValue definition, adopted from my proposal.
  • The 0.4.3 migration advances to revision 5, moves existing credentials and publishes the non-secret summary. Reapplying the migration preserves an already-migrated value; downgrading across the version restores the old public representation. CLI/user documentation and all five UI translations accompany the change.

Implementation diff: +286 / −78 lines in 19 files (excludes lockfiles, tests, docs, release notes, and changelog; includes generated runtime schemas/catalog).

Data contracts — complete Rust definitions
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, VisitFields)]
#[serde(rename_all = "camelCase")]
pub struct SmtpInfo {
    pub host: String,
    pub port: u16,
    pub from: String,
    pub username: String,
    pub password_set: bool,
    #[serde(default)]
    pub security: SmtpSecurity,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Parser, VisitFields)]
#[group(skip)]
#[serde(rename_all = "camelCase")]
pub struct SetSmtpParams {
    #[command(flatten)]
    #[serde(flatten)]
    pub smtp: SmtpValue,
    #[arg(long, help = "help.arg.smtp-keep-password")]
    #[serde(default)]
    pub keep_password: bool,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Parser, VisitFields)]
#[group(skip)]
#[serde(rename_all = "camelCase")]
pub struct TestSmtpParams {
    #[arg(long, help = "help.arg.smtp-host")]
    pub host: String,
    #[arg(long, help = "help.arg.smtp-port")]
    pub port: u16,
    #[arg(long, help = "help.arg.smtp-from")]
    pub from: String,
    #[arg(long, help = "help.arg.smtp-to")]
    pub to: String,
    #[arg(long, help = "help.arg.smtp-username")]
    pub username: String,
    /// Omitted, uses the saved password for the same host, port and username.
    #[arg(long, help = "help.arg.smtp-password")]
    pub password: Option<String>,
    #[arg(long, help = "help.arg.smtp-security")]
    #[serde(default)]
    pub security: SmtpSecurity,
}

The reused credential type is unchanged:

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Parser, VisitFields)]
#[group(skip)]
#[serde(rename_all = "camelCase")]
pub struct SmtpValue {
    #[arg(long, help = "help.arg.smtp-host")]
    #[serde(alias = "server")]
    pub host: String,
    #[arg(long, help = "help.arg.smtp-port")]
    pub port: u16,
    #[arg(long, help = "help.arg.smtp-from")]
    pub from: String,
    #[arg(long, help = "help.arg.smtp-username")]
    #[serde(alias = "login")]
    pub username: String,
    #[arg(long, help = "help.arg.smtp-password")]
    pub password: Option<String>,
    #[arg(long, help = "help.arg.smtp-security")]
    #[serde(default)]
    pub security: SmtpSecurity,
}

The containing persisted models are:

#[derive(Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct Private {
    pub key_store: KeyStore,
    pub password: String, // argon2 hash
    #[serde(default)]
    pub sessions: Sessions,
    /// Retains the persisted name for existing databases.
    #[serde(default = "generate_server_identity_key", rename = "developerKey")]
    pub server_identity_key: Der64<ed25519_dalek::SigningKey>,
    pub ssh_privkey: Pem<ssh_key::PrivateKey>,
    pub available_ports: AvailablePorts,
    pub notifications: Notifications,
    #[serde(default)]
    pub os_security_notifications: SecurityNotifications,
    #[serde(default)]
    pub registry_cursors: BTreeMap<url::Url, crate::registry::sync::RegistryCursor>,
    #[serde(default)]
    pub push: crate::notifications::push::PushState,
    pub cifs: CifsTargets,
    #[serde(default)]
    pub backup_history: BTreeMap<String, crate::backup::history::BackupRun>,
    #[serde(default)]
    pub backup_target_credentials: BTreeMap<
        crate::backup::target::BackupTargetId,
        crate::shared_volumes::SharedVolumeCredentials,
    >,
    #[serde(default)]
    pub shared_volume_credentials: BTreeMap<
        crate::shared_volumes::SharedVolumeId,
        crate::shared_volumes::SharedVolumeCredentials,
    >,
    #[serde(default)]
    pub package_stores: BTreeMap<PackageId, Value>,
    #[serde(default)]
    pub smtp: Option<crate::system::SmtpValue>,
}

#[derive(Debug, Deserialize, Serialize, HasModel, VisitFields)]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct ServerInfo {
    pub id: String,
    pub hostname: InternedString,
    pub version: Version,
    /// Commit of the running StartOS build, rewritten on every boot.
    #[serde(default)]
    pub git_hash: InternedString,
    pub package_version_compat: VersionRange,
    #[visit(ts(type = "z.record(z.string(), z.unknown())"))]
    pub post_init_migration_todos: BTreeMap<Version, Value>,
    #[serde(default)]
    pub latest_migration_revision: usize,
    pub last_backup: Option<DateTime<Utc>>,
    pub network: NetworkInfo,
    #[serde(default)]
    pub status_info: ServerStatus,
    pub unread_notification_count: u64,
    #[serde(default = "initial_trusted_keys")]
    pub trusted_keys: TrustedKeys,
    /// Last observed trust proposals from connected registries.
    #[serde(default)]
    pub registry_keys: BTreeMap<InternedString, BTreeSet<crate::sign::AnyVerifyingKey>>,
    /// Connected registries; written only through `server.registries`.
    #[serde(default)]
    pub registries: Registries,
    /// Registry that provides StartOS updates; always connected.
    #[serde(default = "initial_os_registry")]
    pub os_registry: Url,
    pub pubkey: String,
    pub ca_fingerprint: String,
    #[serde(default)]
    pub ntp_synced: bool,
    #[serde(default)]
    pub zram: bool,
    pub governor: Option<Governor>,
    #[serde(default)]
    pub epp: Option<Epp>,
    pub smtp: Option<SmtpInfo>,
    #[serde(default)]
    pub nut: NutConfig,
    #[serde(default = "default_echoip_urls")]
    pub echoip_urls: Vec<Url>,
    pub ram: u64,
    pub devices: Vec<LshwDevice>,
    pub kiosk: Option<bool>,
    pub language: Option<InternedString>,
    pub keyboard: Option<KeyboardOptions>,
}

Existing persisted credentials are migrated before typed database normalization. Setter requests retain their flat JSON shape and legacy aliases. Consumers of the public SMTP value must use the password-presence summary rather than expecting credentials; package effects retain their existing credential contract.

Verification evidence

The author records a passing UI typecheck and 349 UI tests, i18n validation and formatting. The implementer's follow-up records successful local binding/catalog/man-page regeneration after adopting the alias fix. The current description's statement that CI will be the first real regeneration is therefore stale.

I built and ran this UI tree against the repository's mock backend only to capture the saved-password and pending-removal screens, using fictional credentials. The captured b15132d5c tree is identical to the squashed reviewed head. Screenshots follow in a separate attachment-only comment. No review tests were run, and this did not exercise live SMTP delivery, an OS upgrade, or service callbacks end to end.

At inspection, formatting/lockfiles, SDK/runtime/script tests, dependency licenses and changelog checks passed. Rust tests/man pages, generated-artifact checks and product builds were still pending; approval is based on the code, not an assumption that those checks will pass.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

@helix-white

Copy link
Copy Markdown
Member

Saved-password state: the field stays blank while the page offers retention or removal. Captured from the reviewed UI with the mock backend.

Pending removal: Save applies the choice and Cancel abandons it. Captured from the reviewed UI with the mock backend.

@helix-white

Copy link
Copy Markdown
Member

The squashed head 3131d1c has been re-reviewed; my approval and screenshots are posted above. I also see the subsequent closure in favor of the broader SMTP rework. No further changes or review requests from me on this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants