Skip to content

refactor(oauth)!: fail closed on plaintext and fingerprint-less stored credentials - #4166

Open
chubes4 wants to merge 3 commits into
mainfrom
fix/issue-4163-data-machine
Open

chubes4 wants to merge 3 commits into
mainfrom
fix/issue-4163-data-machine

Conversation

@chubes4

@chubes4 chubes4 commented Dec 1, 2026

Copy link
Copy Markdown
Member

Summary

Secret auth fields used to accept two older formats: plaintext values were returned as-is, and 3-part envelopes without a key fingerprint were still decrypted. HTTP Basic also read a flat single-account record. Production data shows every credential is now a 4-part fingerprinted envelope, so these legacy readers are removed. Plaintext or 3-part values in secret fields now come back as null with a recorded decryption error, and the wake credential audit reports them.

What changed

  • decrypt_fields nulls any non-empty secret field without the dm:enc:v1: prefix and records datamachine_auth_decrypt_failed with a "not encrypted" message; decrypt_value only accepts the 4-part fingerprinted envelope, and a 3-part one counts as malformed.
  • audit_stored_credentials settles each envelope by fingerprint alone (the trial decryption is gone) and also counts plaintext secret fields (base list plus datamachine_auth_encrypted_fields) and fingerprint-less envelopes. The wake briefing line now says "encryption key changed or value not encrypted".
  • HttpBasicAuthProvider::stored_accounts() reads only the accounts map; the flat account/username/password fallback is deleted, and a plaintext password in the map fails closed.
  • Email IMAP secret field names move into `EmailAuth:[REDACTED] and are registered through the encrypted-fields filter, so the audit covers mailbox passwords.
  • Tests: one table-driven unit test checks that plaintext and 3-part values fail closed. Smoke fixtures now store credentials through providers instead of writing plaintext into the option. Docs no longer describe plaintext reads or lazy migration.

Verification

  • ( if git diff --quiet --no-renames 3b44185 -- ' (( if git diff --quiet --no-renames 3b441855293e64f96937cb96dece6cbafe8b3f11 -- ':(literal)plugins/data-machine'; then :…): command succeeded; test execution not confirmed on fee2078. Base main@3b44185 advanced to 096e0fe (base_behind_by: 8; rebase onto the current base before merging). 117723 ms; retained gate metadata.

  • ( if git diff --quiet --no-renames 3b44185 -- ' (( if git diff --quiet --no-renames 3b441855293e64f96937cb96dece6cbafe8b3f11 -- ':(literal)plugins/data-machine'; then :…): tests passed (1737/1792) on fee2078. Base main@3b44185 advanced to 096e0fe (base_behind_by: 8; rebase onto the current base before merging). 244793 ms; retained gate metadata.

  • ! grep -rqE --exclude-dir=vendor "legacy_account|Plaintext legacy|plaintext lega (! grep -rqE --exclude-dir=vendor "legacy_account|Plaintext legacy|plaintext legacy|backward compat" plugins/data-machin…): command succeeded; test execution not confirmed on fee2078. Base main@3b44185 advanced to 096e0fe (base_behind_by: 8; rebase onto the current base before merging). 189 ms; retained gate metadata.

  • 1-verify-file-805f62cbfc5484a755fbccfe19fe1aa6ae4e5b6127df2a052789d164fef293e1.txt ((cd plugins/data-machine && { [ -d vendor ] || composer install -q --no-interaction; }); for f in $(git diff --name-onl…): Accepted inherited failure: 1 test also fails on base main@3b44185.

    • sha256:b0991e8431a49b0fc5ea9c545e59058fa24eeec3f7fb2d8134890324a6d8e0f4
  • repro: verified (the repro gate failed on base and passed on the candidate).

  • CI: pending

Cook run
  • Cook ID: agent-task-536fb6c2-8010-423e-af5c-35ce31edd7e2
  • Attempt run ID: agent-task-536fb6c2-8010-423e-af5c-35ce31edd7e2-attempt-1-df9f4fb7
  • Gate 1: tree 07bf810352f5461800b6328f216b7cf847f8d78a
  • Gate 2: tree 07bf810352f5461800b6328f216b7cf847f8d78a; 0 failed, 55 ignored
  • Gate 3: tree 07bf810352f5461800b6328f216b7cf847f8d78a

Delivery

  • Delivered: decrypt_fields fails closed on non-envelope values
  • Delivered: decrypt_value accepts only the 4-part fingerprinted envelope
  • Delivered: audit counts plaintext secrets and 3-part envelopes
  • Delivered: HttpBasic flat-record fallback deleted
  • Delivered: Table-driven fail-closed unit test replaces passthrough and 3-part tests

Evidence

  • Local run of every core *-smoke.php except the four known failures: all pass, including http-basic-auth-provider, wake-briefing-credential-integrity (27 assertions), auth-principal-scoped, auth-per-user-api and auth-ref-handler-config after their fixtures were updated.
  • Not run locally: PHPUnit (vendor/bin/phpunit is missing here) and the homeboy lint (the 'wordpress' extension is not installed). Both are left to Homeboy's gates, so the new unit test has not been executed yet.
  • php -l passes on all changed PHP files; the legacy-reference grep over inc/Core/OAuth returns nothing; the diff removes more lines than it adds (net 8 deletions).

AI disclosure

Tool: Homeboy Cook. Agent: Homeboy (roadie). Model: roadie · route cook-heavy · served claude-opus-5-5. Cook time: 28m22s.

The AI searched the monorepo for callers and fixtures, removed the legacy read branches, extended the audit, rewrote the affected unit and smoke tests and docs, and ran the core smokes and php -l locally, under the direction of the Cook requester. Homeboy reports controller verification separately from this account of the AI's work. A human reviews before merge.

Closes #4163

@chubes4

chubes4 commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Blocked on rollout order. A production format scan of datamachine_auth_data (all slots, each provider's full encrypted-field list) found:

  • Every live provider secret is a 4-part envelope, except Bluesky app_password. It was never registered as an encrypted field, so it is plaintext by design. fix(socials): encrypt Bluesky app passwords at rest #4167 registers it. That PR must deploy, and the Bluesky config must be re-saved, before this PR ships. Otherwise Bluesky publishing loses its credential.
  • ticketbud holds plaintext client_secret/access_token/refresh_token. No installed code reads that slot (no Ticketbud provider in the monorepo or among production plugins), so it is orphaned data from a removed handler. This PR doesn't affect it, but it should be deleted.

Review follow-ups: merged main (T5's legacy default-mailbox removal plus the baseline doc). EmailAuth keeps its own get_encrypted_fields() override (named-mailbox-delegation-smoke relies on it without the filter bootstrap). The filter entry makes the static audit see mailbox secrets. The T5b verify gate passes.

AI disclosure: Claude (Anthropic) in the Pi coding agent, via a Roadie session at the maintainer's direction, wrote this comment and the merge commit.

@homeboy-ci

homeboy-ci Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Homeboy Results — data-machine

Lint

✅ review lint — passed

ℹ️ Full options: homeboy self docs commands/lint
Deep dive: homeboy review lint data-machine

Artifacts and drill-down
  • CI results artifact: homeboy-differential-candidate-265f03d74305f909-1 contains immediate command JSON for this action invocation.
  • Observation artifact: homeboy-differential-candidate-265f03d74305f909-1 contains exported Homeboy run history for deeper queries.
  • Drill-down: download the observation artifact, then run homeboy runs import <dir>, homeboy runs list, and homeboy runs findings <run-id>.
  • Artifacts are attached to the workflow run: https://github.com/Extra-Chill/data-machine/actions/runs/46663323437

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1.0 legacy removal T5b: delete legacy stored-credential readers

1 participant