harden: key remembered site permissions by full origin (closes #402)
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
This commit was merged in pull request #431.
This commit is contained in:
+20
-11
@@ -28,11 +28,14 @@ function makeState(overrides = {}) {
|
||||
selectedAddress: 0,
|
||||
activeAddress: A0,
|
||||
allowedSites: {
|
||||
[A0]: ["a.example"],
|
||||
[A1]: ["b.example"],
|
||||
[B0]: ["c.example"],
|
||||
[A0]: ["https://a.example"],
|
||||
[A1]: ["https://b.example"],
|
||||
[B0]: ["https://c.example"],
|
||||
},
|
||||
deniedSites: {
|
||||
[A1]: ["https://d.example"],
|
||||
[C0]: ["https://e.example"],
|
||||
},
|
||||
deniedSites: { [A1]: ["d.example"], [C0]: ["e.example"] },
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
@@ -41,7 +44,7 @@ describe("removeWalletFromState", () => {
|
||||
test("deleting the last wallet clears hasWallet", () => {
|
||||
const state = makeState({
|
||||
wallets: [wallet("A", [A0])],
|
||||
allowedSites: { [A0]: ["a.example"] },
|
||||
allowedSites: { [A0]: ["https://a.example"] },
|
||||
deniedSites: {},
|
||||
});
|
||||
|
||||
@@ -109,8 +112,8 @@ describe("removeWalletFromState", () => {
|
||||
|
||||
removeWalletFromState(state, 0);
|
||||
|
||||
expect(state.allowedSites).toEqual({ [B0]: ["c.example"] });
|
||||
expect(state.deniedSites).toEqual({ [C0]: ["e.example"] });
|
||||
expect(state.allowedSites).toEqual({ [B0]: ["https://c.example"] });
|
||||
expect(state.deniedSites).toEqual({ [C0]: ["https://e.example"] });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -126,8 +129,14 @@ function makeAddressState(overrides = {}) {
|
||||
selectedWallet: 0,
|
||||
selectedAddress: 0,
|
||||
activeAddress: A0,
|
||||
allowedSites: { [A0]: ["a.example"], [A1]: ["b.example"] },
|
||||
deniedSites: { [A1]: ["d.example"], [B0]: ["e.example"] },
|
||||
allowedSites: {
|
||||
[A0]: ["https://a.example"],
|
||||
[A1]: ["https://b.example"],
|
||||
},
|
||||
deniedSites: {
|
||||
[A1]: ["https://d.example"],
|
||||
[B0]: ["https://e.example"],
|
||||
},
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
@@ -273,8 +282,8 @@ describe("removeAddressFromState", () => {
|
||||
|
||||
removeAddressFromState(state, 0, 1);
|
||||
|
||||
expect(state.allowedSites).toEqual({ [A0]: ["a.example"] });
|
||||
expect(state.deniedSites).toEqual({ [B0]: ["e.example"] });
|
||||
expect(state.allowedSites).toEqual({ [A0]: ["https://a.example"] });
|
||||
expect(state.deniedSites).toEqual({ [B0]: ["https://e.example"] });
|
||||
});
|
||||
|
||||
// The derivation counter is a high-water mark, never rewound: "+" derives
|
||||
|
||||
Reference in New Issue
Block a user