harden: key remembered site permissions by full origin #431

Merged
clawbot merged 1 commits from issue-402-permissions-by-origin into next 2026-10-04 18:09:05 +02:00
Collaborator

Remembered site permissions (allowedSites, deniedSites) were stored and matched by bare hostname. A grant to https://dapp.example therefore also covered http://dapp.example and every port on that host, and the prompts named only the hostname. Fixes #402.

What changed:

  • Both lists store and match the full origin (scheme://host[:port]), the key the connections approved without "Remember" already used. This applies to every check in src/background/index.js: connection requests, eth_accounts, chain switch, permissions, signing, eth_sendTransaction, accountsChanged.
  • The connection, transaction and signature prompts show the origin. Their element ids are now approve-origin, approve-tx-origin and approve-sign-origin.
  • Settings lists origins, and AUTISTMASK_REMOVE_SITE carries origin instead of hostname. Removing a site leaves the same host on another scheme or port alone.
  • The phishing check still matches the hostname, now taken from the origin.
  • README.md and docs/README.md describe a site as its origin.

Worth knowing:

  • No migration, per the plan comment on the issue: hostname entries already in storage match no site, so those sites prompt again, and Settings lists the old entries until they are removed.
  • Every new test (http and other-port origins refused under an https grant, Remember storing the origin, prompts and Settings showing the origin) fails against the old code.
  • One previous Settings test assumed two ports of one host were one site. It now checks the reverse, and the "remembered and unremembered at once" case is kept using two addresses.

Model: opus-5-5

Remembered site permissions (`allowedSites`, `deniedSites`) were stored and matched by bare hostname. A grant to `https://dapp.example` therefore also covered `http://dapp.example` and every port on that host, and the prompts named only the hostname. Fixes https://git.eeqj.de/sneak/AutistMask/issues/402. What changed: - Both lists store and match the full origin (`scheme://host[:port]`), the key the connections approved without "Remember" already used. This applies to every check in `src/background/index.js`: connection requests, `eth_accounts`, chain switch, permissions, signing, `eth_sendTransaction`, `accountsChanged`. - The connection, transaction and signature prompts show the origin. Their element ids are now `approve-origin`, `approve-tx-origin` and `approve-sign-origin`. - Settings lists origins, and `AUTISTMASK_REMOVE_SITE` carries `origin` instead of `hostname`. Removing a site leaves the same host on another scheme or port alone. - The phishing check still matches the hostname, now taken from the origin. - `README.md` and `docs/README.md` describe a site as its origin. Worth knowing: - No migration, per the plan comment on the issue: hostname entries already in storage match no site, so those sites prompt again, and Settings lists the old entries until they are removed. - Every new test (http and other-port origins refused under an https grant, Remember storing the origin, prompts and Settings showing the origin) fails against the old code. - One previous Settings test assumed two ports of one host were one site. It now checks the reverse, and the "remembered and unremembered at once" case is kept using two addresses. Model: opus-5-5
clawbot added the needs-review label 2026-10-04 16:28:12 +02:00
clawbot self-assigned this 2026-10-04 16:28:12 +02:00
Author
Collaborator

FAIL

  1. tests/stateMerge.test.js lines 273-297 and tests/persistedEntryFloors.test.js lines 62-93 still describe and seed allowedSites / deniedSites as hostname lists. The comment at line 273 gives the layout as { [address]: [hostname, ...] } and says the background pushes "a newly approved hostname". The helpers there take a hostname. The test titles at lines 62 and 70 say "hostname list" and "a hostname that is not text". After this change the lists hold origins and nothing writes a hostname to them, so these statements are false, and they point the next reader at the layout this PR removed. Acceptable: describe these lists as origin lists and seed them with origins (for example https://dapp.example), the way src/shared/state.js and src/shared/persistedState.js now do.

Model: opus-5-5

FAIL 1. `tests/stateMerge.test.js` lines 273-297 and `tests/persistedEntryFloors.test.js` lines 62-93 still describe and seed `allowedSites` / `deniedSites` as hostname lists. The comment at line 273 gives the layout as `{ [address]: [hostname, ...] }` and says the background pushes "a newly approved hostname". The helpers there take a `hostname`. The test titles at lines 62 and 70 say "hostname list" and "a hostname that is not text". After this change the lists hold origins and nothing writes a hostname to them, so these statements are false, and they point the next reader at the layout this PR removed. Acceptable: describe these lists as origin lists and seed them with origins (for example `https://dapp.example`), the way `src/shared/state.js` and `src/shared/persistedState.js` now do. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-04 16:54:13 +02:00
clawbot force-pushed issue-402-permissions-by-origin from f87c97ba50 to 30f57b9076 2026-10-04 17:06:11 +02:00 Compare
Author
Collaborator

Rework for #431 (comment):

  1. Fixed. Both files now describe and seed these lists as origin lists. The same bare-hostname seeds in tests/support/popupBoot.js, tests/stateRecovery.test.js, tests/persistedFieldContract.test.js, tests/walletDelete.test.js and tests/deleteWalletLostPassword.test.js are origins now too. Nothing else in the tree calls them hostname lists.

Judgement call: the tests/stateMerge.test.js comments that cited line numbers this PR moved now name rememberSiteChoice() and forgetOrigin() instead.
Judgement call: older Completed Steps entries in TODO.md that say "hostname" are left alone, since they record what was true when they were written.

Rebased onto current next. In the TODO.md conflict both entries are kept.

Model: opus-5-5

Rework for https://git.eeqj.de/sneak/AutistMask/pulls/431#issuecomment-124245: 1. Fixed. Both files now describe and seed these lists as origin lists. The same bare-hostname seeds in `tests/support/popupBoot.js`, `tests/stateRecovery.test.js`, `tests/persistedFieldContract.test.js`, `tests/walletDelete.test.js` and `tests/deleteWalletLostPassword.test.js` are origins now too. Nothing else in the tree calls them hostname lists. Judgement call: the `tests/stateMerge.test.js` comments that cited line numbers this PR moved now name `rememberSiteChoice()` and `forgetOrigin()` instead. Judgement call: older Completed Steps entries in `TODO.md` that say "hostname" are left alone, since they record what was true when they were written. Rebased onto current `next`. In the `TODO.md` conflict both entries are kept. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-04 17:06:28 +02:00
Author
Collaborator

FAIL

  1. The branch conflicts with current next in TODO.md (line 48 on the rebased tree): the Completed Steps entry for #407 landed at the same spot. Acceptable: rebase onto next, keeping both entries.
  2. On the rebased tree, tests/rpcOrigin.test.js (added on next for #407) still seeds allowedSites with the bare hostname (CONNECTED_HOSTNAME, lines 20 and 61), which this change no longer matches. The test "a connected site's frame on a stranger's page gets the address" fails, and "a stranger's frame on a connected site gets no address" now passes whichever site the request is credited to, so it no longer checks anything. Acceptable: seed the list with CONNECTED_ORIGIN and drop CONNECTED_HOSTNAME, as this change did for the other test seeds, so both tests pass and each fails again if a request is credited to the tab's page instead of the frame that sent it.

Model: opus-5-5

FAIL 1. The branch conflicts with current `next` in `TODO.md` (line 48 on the rebased tree): the Completed Steps entry for https://git.eeqj.de/sneak/AutistMask/issues/407 landed at the same spot. Acceptable: rebase onto `next`, keeping both entries. 2. On the rebased tree, `tests/rpcOrigin.test.js` (added on `next` for https://git.eeqj.de/sneak/AutistMask/issues/407) still seeds `allowedSites` with the bare hostname (`CONNECTED_HOSTNAME`, lines 20 and 61), which this change no longer matches. The test "a connected site's frame on a stranger's page gets the address" fails, and "a stranger's frame on a connected site gets no address" now passes whichever site the request is credited to, so it no longer checks anything. Acceptable: seed the list with `CONNECTED_ORIGIN` and drop `CONNECTED_HOSTNAME`, as this change did for the other test seeds, so both tests pass and each fails again if a request is credited to the tab's page instead of the frame that sent it. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-04 17:36:49 +02:00
clawbot added 1 commit 2026-10-04 17:52:40 +02:00
harden: key remembered site permissions by full origin (closes #402)
check / check (push) Failing after 2s
e2e / e2e-chrome (push) Failing after 3s
e2e / e2e-firefox (push) Failing after 2s
e557f21bb0
allowedSites and deniedSites held the bare hostname, so a grant to
https://dapp.example also authorised http://dapp.example and every port
on that host, and the connection, transaction and signature prompts
named only the hostname. Both lists now store and match the full origin
(scheme://host[:port]), the key the connections approved without
Remember already used. The prompts, the Settings site lists and
AUTISTMASK_REMOVE_SITE use the origin too. Entries saved by hostname
are not migrated (pre-1.0): they match no site.

Model: opus-5-5
clawbot force-pushed issue-402-permissions-by-origin from 30f57b9076 to e557f21bb0 2026-10-04 17:52:40 +02:00 Compare
Author
Collaborator

Rework for #431 (comment):

  1. Fixed. Rebased onto current next, keeping both Completed Steps entries in TODO.md.
  2. Fixed. tests/rpcOrigin.test.js seeds allowedSites with CONNECTED_ORIGIN, and CONNECTED_HOSTNAME is gone. Both tests fail when the request is credited to the tab's page instead of the frame that sent it, checked by hand. No other test seeds these lists with a hostname.

Model: opus-5-5

Rework for https://git.eeqj.de/sneak/AutistMask/pulls/431#issuecomment-124457: 1. Fixed. Rebased onto current `next`, keeping both Completed Steps entries in `TODO.md`. 2. Fixed. `tests/rpcOrigin.test.js` seeds `allowedSites` with `CONNECTED_ORIGIN`, and `CONNECTED_HOSTNAME` is gone. Both tests fail when the request is credited to the tab's page instead of the frame that sent it, checked by hand. No other test seeds these lists with a hostname. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-04 17:52:50 +02:00
Author
Collaborator

PASS

Model: opus-5-5

PASS Model: opus-5-5
clawbot merged commit 1144fdb71b into next 2026-10-04 18:09:05 +02:00
clawbot deleted branch issue-402-permissions-by-origin 2026-10-04 18:09:06 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/AutistMask#431