Skip to content

webadmin: let admins view an entry's passphrase - #58

Draft
tridge wants to merge 3 commits into
ArduPilot:mainfrom
tridge:pr-admin-passphrase
Draft

tridge wants to merge 3 commits into
ArduPilot:mainfrom
tridge:pr-admin-passphrase

Conversation

@tridge

@tridge tridge commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

keys.tdb only holds sha256(passphrase), which is the MAVLink signing key, so an admin had no way to look up an ID's passphrase. This records the plaintext in a separate database so admins can view it from the admin edit page.

Storage

  • A new keys.passphrases.tdb sits next to keys.tdb and is created mode 0600. Only the webadmin and keydb.py use it; the daemon never opens it, and the keys.tdb record layout is unchanged.
  • A passphrase is recorded whenever one is set: admin add, admin edit, owner change, and keydb.py add/setpass. Deleting an ID (keydb.py remove, admin delete) forgets it. Writes happen only after the keys.tdb commit, and are best effort: a failure is logged and reported, but does not undo the saved change.
  • A record is only returned while it still hashes to the entry's key. A passphrase changed by any other route therefore reads as "not recorded" rather than showing a stale value.
  • IDs whose passphrase was set before this change show "not recorded" until the passphrase is set again.

Viewing

  • The admin edit page has a passphrase row with a Show button. It POSTs, with a CSRF token, to /admin/<port2>/passphrase, which returns JSON with Cache-Control: no-store. The passphrase is never rendered into the page, and the page clears it on pagehide so going back doesn't show it from the page cache.
  • Each view is logged as "admin X viewed the passphrase of Y", without the passphrase itself.

Sessions

  • Sessions used to identify the user by port2 alone. A cookie for a deleted entry would therefore inherit whatever entry, possibly an admin one, later took that port, and could then reveal passphrases.
  • Sessions now also carry an HMAC, keyed with the app secret, of the entry's key. A session that no longer matches is cleared.
  • Changing a passphrase therefore ends that ID's other sessions; the session that made the change is rebound after the commit.
  • Existing sessions are logged out once on upgrade.
  • Admin add, edit, delete and the reveal re-check the caller inside their own transaction, so a request already in flight when the caller is demoted is refused.

Testing

  • New webadmin tests cover:
    • recording from every path;
    • stale records;
    • refused saves;
    • store failures;
    • an unreadable store;
    • the CSRF token in the Show form;
    • owner denial;
    • port reuse;
    • sessions ending on a passphrase change;
    • in-flight saves and reveals after the key or the admin flag changed;
    • the keyed fingerprint;
    • file permissions;
    • the audit log;
    • the CLI.
  • Webadmin, keydb and the daemon tests that drive the web UI and CLI pass.
  • Deployed on the FireVPS proxy. An end-to-end check against a copy of its keys.tdb passed: add an ID with the CLI, log in, use Show, and confirm the view is logged.

Known limits

  • Deleting a record does not scrub its bytes from the tdb file. The file is as private as keys.tdb.
  • Rotating back to an earlier passphrase makes a session issued under it valid again.
  • docker/Dockerfile now copies passdb_lib.py, which keydb.py imports.

keys.tdb only holds the hash, so a passphrase cannot be recovered from
it. keydb.py now records the plaintext in keys.passphrases.tdb, which
the daemon never opens, after its keys.tdb commit. A record is only
returned while it still matches the entry's key.
The admin edit page gets a Show button that fetches the passphrase on
demand. Admin add, admin edit and owner changes record it once keys.tdb
has committed, and delete forgets it. Each view is logged.

Sessions are now tied to the entry's key as well as its port2, so a
cookie for a deleted entry cannot be reused when the port is given to a
new (possibly admin) entry, and a passphrase change ends other sessions.
@tridge tridge added the AIReview Request an automated AI review; picked up by the reviewprs sweep label Dec 2, 2026
@AP-Review

Copy link
Copy Markdown

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: COMMENT

Reviewed at head 619f923eb2.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/supportproxy/58/1.html#prSupportProxy-58

This adds a careful admin passphrase view with no blocking issues; there are two low-severity suggestions.

Suggestions

  • passdb_lib.py:70: record()/forget() run after the keys.tdb commit and do not re-check the entry. Two overlapping passphrase changes, or a delete followed quickly by a re-add, can leave a stale or missing record, which then shows as "not recorded" (never a wrong passphrase). Inside the passdb transaction, re-read the keys.tdb entry and only store (or forget) if it still matches.
  • webadmin/routes_owner.py:106: owner-chosen passphrases are now viewable by admins, but the /me/ help text does not say so. Consider adding "admins can view this passphrase" to its description.
Minor (1)
  • webadmin/auth.py:80: existing sessions have no key_fp, so everyone is logged out once on deploy. This is expected; maybe mention it in the deploy notes.

@timtuxworth

Copy link
Copy Markdown

Not a good idea @tridge . I don't think the plain text passphrase should be stored or viewable. This should have the same protections as a password on Unix.

@tridge

tridge commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Not a good idea @tridge

I keep getting users asking me what their passphrase is, I can reset it for them, but that means transmitting it to them over discord or similar, this seems a lesser evil

@timtuxworth

timtuxworth commented Dec 3, 2026 •

Copy link
Copy Markdown

Not a good idea @tridge

I keep getting users asking me what their passphrase is, I can reset it for them, but that means transmitting it to them over discord or similar, this seems a lesser evil

Sorry, it may be more convenient for you, but it's very bad security practice. Sending passwords "out of band" is actually far better than storing them, but the right answer is to provide a self serve password reset option.

@timtuxworth timtuxworth left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Codex provided adversarial review:-

Security review of SupportProxy PR #58

Request changes. The linked comment identifies the right product fix. Give users a way to set a new passphrase. The PR gives every web admin access to existing credentials that work for both dashboard login and MAVLink signing. I reviewed all 14 changed files at 619f923eb2 and traced the daemon’s key-loading path. These are static findings. I ran no tests and made no requests to a deployed proxy. PR #58 · Linked discussion

PR findings

[P1] One compromised admin session can expose every recorded passphrase

passdb_lib.record() saves the original text, including passphrases owners set themselves. show_passphrase() returns it to any current admin with a valid session and CSRF token, with no fresh authentication. Admins can already reset an entry. Reading its existing secret leaves the owner’s login and clients working, so the owner may see no disruption. 0600 limits filesystem access, no-store limits HTTP caching, and the audit entry records the disclosure after access is granted. Plaintext store · Reveal route

Suggested change. Drop the plaintext database and Show route. Keep the transaction-time admin checks and replace Show with reset.

[P1] Revoked web sessions can become valid again

The session fingerprint is deterministic for a given signing key. At the same port2, restoring a prior passphrase restores the prior session fingerprint. Deleting and recreating an entry with the same port and passphrase has the same result, and the old cookie picks up the replacement entry’s current role. The port-reuse test only covers a replacement with a different passphrase. Session validation · Port-reuse test

Suggested change. Persist a random per-entry session generation, bind the cookie to it, and replace it transactionally on creation and credential rotation. Retain the signing-key fingerprint to detect daemon-side key changes, and update the generation on that path too.

[P2] The reveal releases its authorization transaction before reading the secret

A demotion can commit after still_admin() succeeds and before passdb_lib.lookup() retrieves the plaintext. The existing test covers demotion before the second authorization check. Reveal transaction · Demotion test

Suggested change. If Show survives review, keep the lookup inside the same keys.tdb transaction as the caller and target checks.

How I’d implement reset

Start with admin-issued, owner-completed reset. SupportProxy identifies owners by port and passphrase today. Fully self-service recovery needs a verified recovery channel first. An admin can verify the owner through an established contact and send a short-lived, single-use reset link. Generate the token with secrets.token_urlsafe(32) and store only its digest, expiry, and entry generation. Consume it on the reset POST in the same transaction that calls ke.set_passphrase(), changes the session generation, and saves the entry. Audit the reset without logging the token or either passphrase. Current login flow · OWASP reset guidance

Make the reset revoke live signing access too. This is an existing gap the reset would inherit. The daemon loads the signing key when a channel initializes, and the listener reload doesn’t look at changes to that key. Have the daemon retire or rekey affected signed connections when the key changes, and have its signing-key update handler compare the channel’s key with the current database key before accepting a change. Test that an established connection using the retired key loses access. Channel initialization · Listener reload · Signing-key update

The PR reports that it was deployed on FireVPS. If that deployment recorded real credentials, disable reveal, coordinate rotation for the affected entries, and handle the plaintext database and any retained copies as credential material. Deployment note

@tridge

tridge commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Sorry, it may be more convenient for you, but it's very bad security practice.

you (and codex) are wrong. The way the signing system works if you have a copy of the hash (which is what we store now) then you can login. So having the plain-text makes no difference at all to the security of the system. You've probably read something about the password hashes in unix systems and they work quite differently. There are good reasons for the way signing works, and the design is a widely used one for auth systems.

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

Labels

AIReview Request an automated AI review; picked up by the reviewprs sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants