Repository navigation
fix: DO installer puts no admin password in user-data (#3799) - #3808
Conversation
) The droplet's user-data carries ADMIN_PASSWORD, and cloud-init keeps user-data.txt and the rendered script under /var/lib/cloud for the life of the machine. The first-boot script now shreds and removes those copies in an EXIT trap, on a successful or a failed install. start.sh has already written the password to .env, and a reboot does not re-run per-instance user-data. Fixes #3799 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
merge-train (2026-10-19): ejected after validation, rides the next train once fixed. Two findings against cloud-init 24.4 (the Ubuntu 24.04 line), both verified from its source, not from the PR comment:
Ruling at Gate 1: add Everything else validated clean: Tier 1 green, the EXIT-trap test executes the real trap in bash and goes red on dev (2 failed), |
|
@vybe both findings come from the password being in user-data at all, so I'd like to do the 1.0.1 follow-up here and drop the trap. Plan for this PR:
With nothing secret in user-data, Trade-off: a doc-script droplet is unclaimed until someone completes If you'd rather keep an operator-chosen password on the doc installer, say so and I'll do the Gate 1 fixes (obj.pkl, per-boot re-shred, comment and doc wording) instead. |
AndriiPasternak31
left a comment
There was a problem hiding this comment.
Agree with vybe's two findings and checked both against the cloud-init 24.4 source. obj.pkl still holds the full user-data. init.update() (stages.py:568) rewrites user-data.txt and user-data.txt.i on every boot, so the trap at trinity-do-create.sh:163 only holds until the first reboot. Adding an obj.pkl to the test fixture makes the test fail on this head. The leftover scan also needs read_bytes(), because a real pickle crashes read_text().
The 1-Click path in single-server.md:363 puts the password in cloud-config user-data too, and nothing scrubs it there.
Small correction to the PR description: a failing rm in the trap does change the exit status under set -e (0 becomes 1). That's fine, but it should say so.
I'm fine with your plan of ADMIN_PASSWORD_SOURCE=browser with no secret in user-data. It fixes all of the above at the source. Please cover the 1-Click write_files path as well, or open a follow-up issue for it, and update digitalocean.md:160. I'll re-review once it's pushed.
|
✅ Nightly unit-suite clean when this PR is merged into |
cloud-init keeps user-data for the droplet's life: it rewrites user-data.txt on every boot, pickles the datasource into obj.pkl, and the metadata service serves it. No shred on the droplet can remove it. trinity-do-create.sh no longer prompts for a password. Its user-data exports ADMIN_PASSWORD_SOURCE=browser, the path the DO 1-Click and Vultr already run, and the installer tells the operator to open the address and create the admin at /setup. The EXIT trap and its test are removed; a new test asserts the user-data carries no ADMIN_PASSWORD. Docs: the DO guide, single-server, deploying-trinity, FAQ, setup, DEPLOYMENT.md, PROV-014 and the hosted-install flow describe the browser claim and its window. Co-Authored-By: Claude Opus 5.5 <[email protected]>
AndriiPasternak31
left a comment
There was a problem hiding this comment.
Re-reviewed at c08f46a16.
The installer change is right. The generated user-data now carries only ADMIN_PASSWORD_SOURCE=browser and the tag (trinity-do-create.sh:121-141), and an ADMIN_PASSWORD in the operator's environment doesn't reach it. That path is the same one the 1-Click and Vultr run: start.sh:899-912 writes the blank password and the marker to .env, and /setup accepts browser (setup.py:248). So for this installer, obj.pkl, the per-boot rewrite and the metadata service have nothing to leak. The new test goes red when I put export ADMIN_PASSWORD='…' back into the heredoc. digitalocean.md:160 is fixed, and the trap exit-status point is moot now that the trap is gone.
Still open:
- 1-Click
write_files. The description says it's tracked as a follow-up, but I can't find an issue. Please open it.single-server.md:369still says "The file is shredded once the password has been read", which is the claim #3799 disproved: the password stays inuser-data.txt,obj.pkland the metadata service. The same option is still recommended atDEPLOYMENT.md:517,faq/security.md:101andsetup.md:63. One line at each saying it persists, plus a link to the issue, is enough here. - #3799 itself. It still has the shred title and expected outcome, and its validation says
GET /api/setup/statusstill reports admin set, which is false after this PR. Please retitle and update it, as in your 10-20 plan, beforeFixes #3799closes it. - Two docs still say the installer puts a password in user-data:
faq/deployment-and-upgrades.md:19("with the admin password chosen up front") and PROV-013 inrequirements/infrastructure.md:177("a script install's user-data holds the admin password"). - The accepted-risk text is still marketplace-only.
setup.py:39says "That acceptance covers the marketplace only, so nothing else may become claimable by it", andDEPLOYMENT.md:502names only 1-Click droplets.do-scriptis claimable now, so both should say so. - The claim warning only prints on the happy path. If the IP cert isn't issued, Caddy falls back to its internal CA and Trinity still starts, so
/setupis open. But the 15-minute timeout message (trinity-do-create.sh:195-207) and the "no public IP yet" exit (:164) say nothing about claiming. The same two lines there would close that.
Optional: asserting set(interpolated) == {"TRINITY_IMAGE_TAG_Q"} in test_every_single_quoted_interpolation_in_the_user_data_is_quoted would catch a password written under any other name. The new test stays green if it's written to /etc/trinity/admin-password. Also FYI, #3824 still specs TRINITY_ADMIN_PASSWORD into user-data for unattended runs, which would undo this.
I need 1–4 before I approve. 5 is small and I'd like it in the same push.
|
@AndriiPasternak31 pushed (
|
|
@obasilakis thanks. #3942 and the #3799 update cover the issue side of points 1 and 2. The head is still
Did a push not go through? |
dolho
left a comment
There was a problem hiding this comment.
/validate-pr — Lane B (installer script + docs)
The installer change itself is right, and I agree with Andrii's 10-24 assessment: the user-data now carries only ADMIN_PASSWORD_SOURCE=browser and the tag, so obj.pkl, the per-boot rewrite and the metadata service have nothing to leak. #3942 and the #3799 rewrite cover the issue side.
But the head is still c08f46a16, the commit Andrii re-reviewed, so the doc and script follow-ups he asked for are not on the branch. I checked each at that head:
This PR requires the following changes before merge:
-
docs/user-docs/guides/deploying/single-server.md:369still says "The file is shredded once the password has been read" — the claim #3799 disproved. Same option, no persistence warning, atDEPLOYMENT.md:517,faq/security.md:101,getting-started/setup.md:63: one line each saying the password persists in user-data, linking #3942. -
faq/deployment-and-upgrades.md:19still says the script installs "with the admin password chosen up front". - PROV-013 in
requirements/infrastructure.md:177still says "a script install's user-data holds the admin password". -
src/backend/routers/setup.py:39(andDEPLOYMENT.md:502) still say the claim-window acceptance "covers the marketplace only, so nothing else may become claimable by it". After this PR the DO script install is claimable too, so that text now contradicts the code path it documents. -
scripts/deploy/trinity-do-create.sh:164: the no-public-IP exit (and the timeout exit) leave a created, unclaimed droplet without telling the operator to claim it at/setup.
| Other checks | |
|---|---|
| Commits / issue | conventional; Fixes #3799 ✅ |
| Secrets / host paths | none ✅ |
| Test | test_no_admin_password_reaches_the_droplets_user_data goes red with the password back in the heredoc (Andrii verified; I did not re-run) ✅ |
It looks like a push may not have gone through. Once these land I'm happy to re-review.
REQUEST CHANGES.
🤖 Reviewed with Claude Code
… on every exit (#3799) - single-server.md: drop the shred claim; a cloud-config write_files password stays in the droplet's user-data (#3942). Same line in DEPLOYMENT.md, faq/security.md and getting-started/setup.md. - faq/deployment-and-upgrades.md, PROV-013: the script install sets the admin password in the browser at /setup. - setup.py docstring, DEPLOYMENT.md: the browser-claim acceptance covers every ADMIN_PASSWORD_SOURCE=browser install, including do-script. - trinity-do-create.sh: claim_warning() prints on the no-public-IP and 15-minute-timeout exits as well as the ready path. - test_2380: user-data interpolates only TRINITY_IMAGE_TAG_Q; the no-IP exit prints the claim warning. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Pushed
Optional: Results:
🤖 Generated with Claude Code |
dolho
left a comment
There was a problem hiding this comment.
Re-reviewed at a62211589.
Every item from my 10-27 review and Andrii's 10-24 review is fixed on this head, and the optional exact-set assertion is in. The installer change is still right: the generated user-data carries only ADMIN_PASSWORD_SOURCE=browser and the quoted tag (scripts/deploy/trinity-do-create.sh:121-140), and the droplet clones v1.0.0, whose start.sh already honours browser (ensure_admin_password, v1.0.0:scripts/deploy/start.sh:879). The tests that matter go red under mutation. I found three small things below. None blocks the merge.
Status of my last review (10-27)
single-server.md:369shred claim, plus the persistence note atDEPLOYMENT.md:517,faq/security.md:101,setup.md:63: fixed.single-server.md:369now reads "The password stays in the droplet's user-data for the droplet's life: cloud-init keeps it on disk and the metadata service serves it ([#3942]…)". The same line with the #3942 link is atdocs/DEPLOYMENT.md:524-525,docs/user-docs/faq/security.md:101anddocs/user-docs/getting-started/setup.md:63. #3942 exists and is open. No "shred" wording is left in those five files.faq/deployment-and-upgrades.md:19"admin password chosen up front": fixed. It now says "you set the admin password in the browser at/setupwhen it prints the address".- PROV-013
requirements/infrastructure.md:177: fixed. The link-local rationale now cites "a 1-Click droplet given a password at create time holds it in user-data (#3942)". The script-install claim is gone. setup.py:39/DEPLOYMENT.md:502marketplace-only acceptance: fixed.src/backend/routers/setup.py:39-42now says the acceptance "covers every install whose provisioning exportsADMIN_PASSWORD_SOURCE=browser" and names the 1-Click, the Vultr Marketplace server anddo-script.docs/DEPLOYMENT.md:502-506names the same three. That matches the gate atsetup.py:251, which refuses onlyunset.- Claim warning on the no-public-IP and timeout exits: fixed.
claim_warning()(trinity-do-create.sh:166-173) is called on the no-IP exit (:177), the ready path (:198) and the 15-minute timeout (:223). The no-IP call is pinned by a test; the other two are not (see L2).
Status of Andrii's items (10-24)
- 1-Click
write_filesfollow-up, plus the docs: fixed. #3942 is filed, and the docs are covered by the first bullet above. - #3799 retitled and updated: fixed. Its title is "DigitalOcean installer puts the admin password in droplet user-data", its Expected section describes the
ADMIN_PASSWORD_SOURCE=browserclaim, and its Validation step is the Create your admin account form. Nothing in it still claims the admin is set. faq/deployment-and-upgrades.md:19and PROV-013: fixed (see above).- Marketplace-only accepted-risk text: fixed (see above).
- Claim warning only on the happy path: fixed for the two exits named. A residual is in L1.
- Optional, exact interpolation set: done.
tests/unit/test_2380_installer_portability.py:88assertsset(interpolated) == {"TRINITY_IMAGE_TAG_Q"}, and mutation M2 below shows it catches a password under another name.
What I ran
pytest -q -p no:randomly unit/test_2380_installer_portability.py unit/test_2380_installer_release_pin.py unit/test_ent580_marketplace_admin_claim.py unit/test_3237_system_agent_after_setup.py: 71 passed.bash -n scripts/deploy/trinity-do-create.sh: clean. shellcheck is not installed here, so I did not run it.git merge-tree --write-tree origin/dev HEAD: clean. The branch is 12 commits behinddev.- Enterprise-docs guard pattern over the added
docs/lines: 0 hits. - CI on the head: 14 checks pass, 5 skipped, none failing.
- Mutations of
trinity-do-create.sh, each run againsttest_2380_installer_portability.py(18 tests):
| Mutation | Result |
|---|---|
M1: add export ADMIN_PASSWORD='${ADMIN_PASSWORD_Q}' back to the heredoc |
2 red (…interpolation…is_quoted, test_no_admin_password_reaches_the_droplets_user_data) |
M2: the password under another name, export TRINITY_ADMIN_PW='${ADMIN_PASSWORD_Q}' |
1 red (…interpolation…is_quoted) |
M3: drop claim_warning from the no-IP exit |
1 red (test_no_admin_password…) |
M4: drop claim_warning from the timeout exit |
all green |
M5: drop claim_warning from the ready path |
all green |
M6: ADMIN_PASSWORD_SOURCE=unset |
7 red |
M8: export TRINITY_ADMIN_SECRET="${ADMIN_PASSWORD:-}" (double-quoted, taken from the operator's env) |
all green |
I also ran the installer against two failing doctl stubs to check L1.
New findings
No Blocking or Medium findings.
Low
L1. Two exits after the droplet exists still skip the claim warning. (trinity-do-create.sh:155-162, confidence 7/10)
doctl compute droplet create "$DROPLET_NAME" \
... --wait --format ID,Name,PublicIPv4 --no-header >&2
IP="$(doctl compute droplet list "$DROPLET_NAME" \
--format PublicIPv4 --no-header | tail -1 | tr -d '[:space:]')"
The script runs under set -euo pipefail (:28). If droplet create --wait returns non-zero after DigitalOcean has accepted the create (for example, a network error while it polls the create action), or if droplet list fails, the script exits 1 with only doctl's own error. The droplet exists and boots admin-less, and nothing tells the operator to claim it. I reproduced both with stub doctls: the output ends at "Creating the droplet..." followed by the doctl error, with rc=1 and no claim text. The comment at :164 ("every exit after this point tells the operator to claim it") is accurate for the code after it, but these two exits come just before it. Fix: set a flag right before droplet create, and use an EXIT trap that prints claim_warning "https://<the droplet's IP>" on any non-zero exit once the flag is set. Alternatively, put || true on the list substitution so a failure falls through to the existing no-IP branch.
L2. The ready-path and timeout claim warnings are not pinned. (tests/unit/test_2380_installer_portability.py:228-240, confidence 8/10)
M4 and M5 stay green. The ready path at :198 is the one most operators see. The stub's droplet list returns no IP, so the tests never reach the poll loop. Fix: add a stub droplet list that prints an IP and a stub curl that exits 0 (the stub dir is already first on PATH), then assert "create your admin account" is in stderr and the exit code is 0. A stub curl that exits 1, with DEADLINE reached quickly (or sleep stubbed), covers the timeout exit the same way.
L3. The env-leak property and some stale comments. (confidence 6/10)
- M8 shows nothing asserts that an
ADMIN_PASSWORDin the operator's environment stays out of user-data. Andrii checked that by reading the code. One more line would pin it: intest_no_admin_password_reaches_the_droplets_user_data, run withADMIN_PASSWORD=<sentinel>inenvand assert the sentinel is not in the user-data file. - Comments and docs that still describe
browseras marketplace-only or the installer as password-passing:src/backend/routers/setup.py:30: "(ADMIN_PASSWORD_SOURCE=browser, set only by the image's first boot)". Lines 39-42 of the same docstring now say otherwise.scripts/deploy/start.sh:1004-1005: "ADMIN_PASSWORD_SOURCE=browser, which only a marketplace first boot sets". This file is not in the diff.docs/memory/feature-flows/hosted-install.md:135: "start.shalso writes anADMIN_PASSWORDfrom the environment into.envwhen.envhas none — the installer's user-data relies on this". The installer's user-data no longer relies on it.docs/user-docs/guides/deploying/upgrading.md:118: "On a Marketplace Droplet whose admin was created in the browser…". This now applies todo-scriptdroplets too.
Execution coverage: every changed shell path except the ready and timeout warnings runs in a test that executes the real script against a stub doctl. The setup.py change is docstring-only. The interpolation regex is a source-text check, but it works as a guard over the heredoc this PR changes, and M1 and M2 show it biting.
…by tests (#3799) An EXIT trap now prints the claim warning when `droplet create --wait` or `droplet list` fails after DigitalOcean accepted the create; it keeps the user-data cleanup. Tests run the ready, timeout and both failure exits against stub doctl/curl/date/sleep, and assert an ADMIN_PASSWORD in the operator's environment stays out of the user-data. Comments and docs that called ADMIN_PASSWORD_SOURCE=browser marketplace-only, or said the installer's user-data carries a password, now name the script install too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Lows from the 10-30 review addressed at
@AndriiPasternak31, your 10-24 changes-requested review is still blocking the merge. dolho checked each of your items as fixed in the 10-30 review. Could you re-review? |
dolho
left a comment
There was a problem hiding this comment.
The core change looks good. User-data now carries only ADMIN_PASSWORD_SOURCE=browser and the image tag (trinity-do-create.sh:121-141). The Redis passwords, CREDENTIAL_ENCRYPTION_KEY and the JWT secret are all generated on the droplet by start.sh. The test asserts that no ADMIN_PASSWORD= reaches user-data.
Please fix before merge: two docs still claim the installer removes the claim window. After this PR that is false, because the script droplet now has the same first-visitor-becomes-admin window as the 1-Click. An operator who reads either page may not rush to /setup or restrict port 443:
docs/user-docs/faq/troubleshooting.md:153: "...or thetrinity-do-create.shinstaller, which removes the window entirely"docs/user-docs/guides/deploying/hardening.md:20: "The install script, or a password supplied at create time, provisions it at first boot instead". This PR does not touch this file.
Suggested fix: drop the installer from both sentences and list it alongside the 1-Click as a browser-claim install.
Lower priority:
trinity-do-create.sh:34,163-166: withTRINITY_IMAGE_TAGset to a tag older than the browser-claim support (which includes the test defaultv0.9.5-rc2),start.shignores thebrowsermarker and generates a password into the install log. The script's advice "someone got there first: destroy the droplet" then makes the operator destroy a healthy droplet. Either refuse old tags or soften the message.:170-177: the EXIT trap prints<the droplet's IP>even when$IPis already known. Use${IP:-<the droplet's IP>}.
I'm happy to approve once the two docs are corrected.
AndriiPasternak31
left a comment
There was a problem hiding this comment.
Re-reviewed at aa4210f0f.
All five items from my 10-24 review are fixed. I checked each one on this head:
- 1-Click
write_files. #3942 is open.single-server.md:369now says the password stays in user-data for the droplet's life and links it, and the same line is atDEPLOYMENT.md:524-525,faq/security.md:101andsetup.md:63. No "shred" wording is left. - #3799. It is retitled, its Expected section describes the
browserclaim, and its Validation is thegrepover/var/lib/cloudplus the Create your admin account form. - The two docs I named.
faq/deployment-and-upgrades.md:19now has the admin created at/setup, and PROV-013 (infrastructure.md:177) cites the 1-Click password instead of the script install. - Accepted-risk text.
setup.py:39-42andDEPLOYMENT.md:502-507namedo-scriptalongside the 1-Click and Vultr, which matches the gate atsetup.py:251. The:30docstring and thestart.sh:1004comment now agree with them. - Claim warning. It prints on the no-IP exit (
trinity-do-create.sh:192), the ready path (:213) and the timeout (:238), and the EXIT trap (:170-179) covers a failingdroplet create --waitordroplet list. Each is pinned bytest_every_exit_after_create_says_to_claim_the_droplet. Dropping any one of them turns its case red.
The exact-set assertion is in (test_2380_installer_portability.py:88), and the operator-env sentinel (:255, :262) now catches "${ADMIN_PASSWORD:-}" going into user-data under another name. test_2380_installer_portability.py, test_2380_installer_release_pin.py and test_ent580_marketplace_admin_claim.py pass locally (70). shellcheck is clean.
Before merge, the two docs raised in the latest review are still open: faq/troubleshooting.md:153 and deploying/hardening.md:20 both say the script install has no claim window. Two more lines say the same thing, in files this PR already edits:
faq/deployment-and-upgrades.md:39: "To skip the window entirely, … or use the installer script."guides/deploying-trinity.md:112: "(or use the installer script below)".:15and:118of that file are fixed,:112isn't.
I'd fix all four in the same push.
Small, non-blocking:
- Ctrl-C during the readiness poll runs the EXIT trap with
IPalready set, so it prints "may have been created" andhttps://<the droplet's IP>right under "Server is up at ".${IP:-<the droplet's IP>}at:175fixes the address. start.shatv0.9.5-rc2and earlier has nobrowserhandling, soTRINITY_IMAGE_TAGset to one of those generates a password, and the "destroy the droplet" advice is then wrong. The defaultv1.0.0is fine. A follow-up is enough.
FYI, #3824 still specs TRINITY_ADMIN_PASSWORD into user-data, which is worth fixing there.
Approving. My items are done, and the docs above are for the latest review to gate.
…indow (#3799) — per the merge-train note on the PR Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
merge-train pushed to this branch ( The operator ruled at Gate 1 to extend the claim-window acceptance to this installer; it is recorded on #3799. Riding with notes, for a follow-up:
|
Summary
user-data.txtanduser-data.txt.ion every boot (init.update()), pickles the datasource, includinguserdata_raw, intoobj.pkl, and the DigitalOcean metadata service serves it. A shred on the droplet cannot remove a password from user-data.trinity-do-create.shno longer prompts for an admin password. Its user-data exportsADMIN_PASSWORD_SOURCE=browser, the path the DO 1-Click and Vultr already run. When the site answers, the installer prints the address with a prompt to open it now and create the admin at/setup.Trade-off
A droplet from this installer is unclaimed until someone completes
/setup, and the first visitor becomes admin. This is the same accepted window as the 1-Click and Vultr (docs/DEPLOYMENT.md→ Security Recommendations). The installer is watching when the site comes up, so the operator is told to claim it at that moment.Changes
scripts/deploy/trinity-do-create.sh: password prompt,umask 077and the trap removed;ADMIN_PASSWORD_SOURCE=browserexported; final message tells the operator to create the admin.tests/unit/test_2380_installer_portability.py: newtest_no_admin_password_reaches_the_droplets_user_data(fails on the previous head); quoting tests now cover the image tag only; stdin fixtures drop the password answers.digitalocean.md(password step removed, Step 4 is creating the admin, claim-window note, troubleshooting rows for the password prompts removed, "What the installer does" updated),single-server.md,deploying-trinity.md, FAQ (deployment, security, troubleshooting),setup.md,DEPLOYMENT.md, PROV-014,hosted-install.md.Not in this PR
The 1-Click's optional
#cloud-configwrite_filespath (single-server.md→ Claim the admin account) still puts an operator-chosen password in user-data, with the sameobj.pkland per-boot copies. That needs a separate decision (drop the option, or document it as persisting) and is tracked in #3942.Test Plan
pytest unit/test_2380_installer_portability.py unit/test_2380_installer_release_pin.py -p no:randomly: 20 passedb973c589b's installer, green on this head-k "2380 or docs or provision or firstboot or ent580 or 2281 or hosted"): 420 passed; one local-only failure (mkdocs-materialversion pin vs local install)grep -r ADMIN_PASSWORD= /var/lib/cloudfinds nothingFixes #3799
🤖 Generated with Claude Code