fix: a page with an opaque origin is refused, not treated as a site (closes #527)
A page with an opaque origin, such as one its server sandboxes with a Content-Security-Policy, is reported to the background with the origin "null". The background took that as a site, so every such page on every website was one site: a connection remembered for one covered them all, and the phishing check never matched. A request whose origin is "null" is now refused with 4100, like one with no origin, before any method runs, and is not credited to the site its URL names. tests/rpcOrigin.test.js sends one, and README's SiteApproval says so. Model: opus-5-5
This commit is contained in:
+28
-2
@@ -8,8 +8,14 @@
|
||||
// and a request the browser said nothing about was credited to whatever the
|
||||
// page wrote (https://git.eeqj.de/sneak/AutistMask/issues/407).
|
||||
//
|
||||
// Every sender here lacks sender.origin, as on old Firefox. The connection
|
||||
// check on eth_accounts is what shows which site a request was credited to.
|
||||
// A page with an opaque origin, such as one its server sandboxes with a
|
||||
// Content-Security-Policy, is reported with the origin "null". That names no
|
||||
// site, so its request is refused
|
||||
// (https://git.eeqj.de/sneak/AutistMask/issues/527).
|
||||
//
|
||||
// Every other sender here lacks sender.origin, as on old Firefox. The
|
||||
// connection check on eth_accounts is what shows which site a request was
|
||||
// credited to.
|
||||
|
||||
const { makeStorageStub } = require("./support/storageStub");
|
||||
|
||||
@@ -144,3 +150,23 @@ describe("a request the browser does not say the sender of", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("a request from a page with an opaque origin", () => {
|
||||
test("is refused, whatever the page's URL says", async () => {
|
||||
const accounts = loadBackground();
|
||||
|
||||
const result = await accounts({
|
||||
origin: "null",
|
||||
url: CONNECTED_ORIGIN + "/sandboxed.html",
|
||||
tab: { url: CONNECTED_ORIGIN + "/sandboxed.html" },
|
||||
});
|
||||
|
||||
expect(result).toEqual({
|
||||
error: {
|
||||
code: 4100,
|
||||
message:
|
||||
"The wallet could not tell which site sent this request.",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user