Compare commits

...

4 Commits

Author SHA1 Message Date
cabf8311e5 Merge branch 'main' into fix/low-severity-security
All checks were successful
check / check (push) Successful in 22s
2026-02-27 20:58:09 +01:00
fbcb679bcf fix(L5): truncate token name/symbol from RPC responses
All checks were successful
check / check (push) Successful in 22s
Limits token name to 64 chars and symbol to 12 chars to prevent
storage of excessively long values from malicious contracts.
2026-02-27 11:42:18 -08:00
aa15f771d5 fix(L4): generate EIP-6963 provider UUID at install time
UUID is generated once via crypto.randomUUID(), persisted in
chrome.storage.local, and sent from the content script to the
inpage script via postMessage.
2026-02-27 11:42:15 -08:00
571f2d6906 fix(L3): isUnlocked() returns false when no accounts exposed
_metamask.isUnlocked() now checks provider.selectedAddress instead of
always returning true.
2026-02-27 11:42:11 -08:00
3 changed files with 44 additions and 8 deletions

View File

@@ -13,6 +13,23 @@ if (typeof browser !== "undefined") {
(document.head || document.documentElement).appendChild(script); (document.head || document.documentElement).appendChild(script);
} }
// Send the persisted EIP-6963 provider UUID to the inpage script.
// Generated once at install time and stored in chrome.storage.local.
(function sendProviderUuid() {
const storage =
typeof browser !== "undefined"
? browser.storage.local
: chrome.storage.local;
storage.get("eip6963Uuid", (items) => {
let uuid = items?.eip6963Uuid;
if (!uuid) {
uuid = crypto.randomUUID();
storage.set({ eip6963Uuid: uuid });
}
window.postMessage({ type: "AUTISTMASK_PROVIDER_UUID", uuid }, "*");
});
})();
// Relay requests from the page to the background script // Relay requests from the page to the background script
window.addEventListener("message", (event) => { window.addEventListener("message", (event) => {
if (event.source !== window) return; if (event.source !== window) return;

View File

@@ -134,7 +134,7 @@
// Some dApps (wagmi) check this to confirm MetaMask-like behavior // Some dApps (wagmi) check this to confirm MetaMask-like behavior
_metamask: { _metamask: {
isUnlocked() { isUnlocked() {
return Promise.resolve(true); return Promise.resolve(provider.selectedAddress !== null);
}, },
}, },
}; };
@@ -155,21 +155,36 @@
"</svg>", "</svg>",
); );
const providerInfo = { let providerUuid = crypto.randomUUID(); // fallback until real UUID arrives
uuid: "f3c5b2a1-8d4e-4f6a-9c7b-1e2d3a4b5c6d",
name: "AutistMask", function buildProviderInfo() {
icon: ICON_SVG, return {
rdns: "berlin.sneak.autistmask", uuid: providerUuid,
}; name: "AutistMask",
icon: ICON_SVG,
rdns: "berlin.sneak.autistmask",
};
}
function announceProvider() { function announceProvider() {
window.dispatchEvent( window.dispatchEvent(
new CustomEvent("eip6963:announceProvider", { new CustomEvent("eip6963:announceProvider", {
detail: Object.freeze({ info: providerInfo, provider }), detail: Object.freeze({
info: buildProviderInfo(),
provider,
}),
}), }),
); );
} }
// Listen for the persisted UUID from the content script
window.addEventListener("message", (event) => {
if (event.source !== window) return;
if (event.data?.type !== "AUTISTMASK_PROVIDER_UUID") return;
providerUuid = event.data.uuid;
announceProvider();
});
window.addEventListener("eip6963:requestProvider", announceProvider); window.addEventListener("eip6963:requestProvider", announceProvider);
announceProvider(); announceProvider();
})(); })();

View File

@@ -192,6 +192,10 @@ async function lookupTokenInfo(contractAddress, rpcUrl) {
name = symbol; name = symbol;
} }
// Truncate to prevent storage of excessively long values from RPC
name = String(name).slice(0, 64);
symbol = String(symbol).slice(0, 12);
log.infof("Token resolved:", symbol, "decimals", Number(decimals)); log.infof("Token resolved:", symbol, "decimals", Number(decimals));
return { name, symbol, decimals: Number(decimals) }; return { name, symbol, decimals: Number(decimals) };
} }