Commit Graph

4 Commits

Author SHA1 Message Date
Teknium
850efff14f fix(vault): check the page origin before entering a backend's fill_context
After rebasing onto the shared origin guard (_bound_page_origin), browser_vault fill still entered the
backend's fill_context before the guard ran: a page on the wrong origin opened a plugin's manager
session or lock just to be refused. enter_code checked first, but then resolved the code from inside
the context without looking at the item again.

Both paths now run in this order, for built-in and plugin items alike: read the item's metadata, run
_bound_page_origin (plus the card confirmation for payments), and only then enter fill_context. Inside
the context a backend with its own fill_context has the item re-read, and the fill is refused unless
the frozen item still binds the checked origin. The origins checked and the secret resolved therefore
come from one snapshot, as the plugin guide promises. The built-in managers keep the default no-op
context and are not re-listed.

A plugin error while reading metadata for enter_code is now the same backend_unavailable refusal fill
gives. The write half of fill moves into _fill_bound_page, unchanged.

Tests: a plugin OTP on a foreign origin is refused with the backend never called (no context, no
resolve_otp, no prompt, nothing written; red on the pre-rebase head); an item re-bound inside the
context is refused for fill and enter_code before its secret is resolved (red for enter_code without
this change); the fill call order is now get_meta, fill_context, get_meta, resolve_password.
2026-10-25 05:32:43 -07:00
Teknium
5c4c661ae6 fix(vault): automatic one-time codes run inside the backend's fill_context
browser_vault enter_code called resolve_otp outside the backend's fill_context. A plugin that opens
its manager session (or lock/snapshot) in that context filled the password, then failed to mint its
stored code, and Hermes silently fell back to asking the user.

Mint and write the code inside fill_context, as a password fill does; a backend without a code
(or failing to give one) still falls back to the user's prompt.
2026-10-25 05:32:43 -07:00
Teknium
b2f6533cd8 fix(vault): plugin login backends only ever touch their own entries
A password-manager plugin registered with ctx.register_login_backend shares
browser_vault with the Hermes vault, 1Password and Bitwarden. On the branch
head the core consulted the plugin's own owns() (a greedy plugin received
op:/bw:/other plugins' handles), listed whatever ids the plugin returned
(spoofed vault_/op: handles), let a second plugin take over a registered
name, let a needs_unlock plugin drive the Hermes master-password prompt under
any label, read name/prefix through properties that can change after
validation, and copied plugin exception text into the model-facing list result.

Every plugin backend now reaches the vault tool only through a core-owned
PluginLoginBackend (agent/vault_backends/plugin.py):
- namespace is "<registry key>:"; ownership is decided by the core, items and
  metas outside it are dropped, resolve_* refuse foreign handles;
- the plugin gets the handle and nothing else; needs_unlock is always False;
- plugin exceptions and wrong-typed values become a fixed-text
  PluginBackendError raised outside the except (no chained context).
Registration refuses descriptor name/prefix, prefix != "<name>:", built-in
names and prefixes (derived from the built-in classes), held names, and
needs_unlock. The fill wrapper turns only PluginBackendError into a typed
refusal, so built-in fills behave as before.
2026-10-25 05:32:43 -07:00
Jess Sullivan
d4e19b9839 feat(tools): support scoped browser vault backend plugins
Huskycat-Receipt: v1;spec=42868e9ef8d7276ff7a143d63766f58e099ba891987567a17028fedc061cc95b;tiers=t0,t1;blobs=bc5861c5f4dd0ded777b118a2538a448bd1ce85a464e14650f08b9e4caad8dc6;pending=l8f617729aa7e7b60
2026-10-25 05:32:43 -07:00