<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>guyfischman</title><description>Notes on security and performance.</description><link>https://guyfischman.com/</link><item><title>The Importance of Establishing Boundaries with your DOM — Stealing 1Password Keys</title><link>https://guyfischman.com/posts/1password-delegation/</link><guid isPermaLink="true">https://guyfischman.com/posts/1password-delegation/</guid><description>1Password Chrome Extension reveals private keys to 1Password&apos;s DOM, and used to do the same on third-party sites</description><pubDate>Tue, 23 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Disclosure status:&lt;/strong&gt; This finding was reported to 1Password through their HackerOne program and remediated in 1Password in the browser &lt;strong&gt;8.12.21&lt;/strong&gt;. It is being published under coordinated disclosure with 1Password&apos;s awareness.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;hr /&gt;
&lt;h2&gt;TL;DR&lt;/h2&gt;
&lt;p&gt;The 1Password browser extension would hand your &lt;strong&gt;master key&lt;/strong&gt;, &lt;strong&gt;secret key&lt;/strong&gt;, and an active &lt;strong&gt;session key&lt;/strong&gt; to JavaScript running on a page whose hostname matched a hardcoded allowlist, with no user interaction. Unfortunately that allowlist included nine dev/staging domains with wildcard DNS, and at least two production domains (&lt;code&gt;brand.1password.com&lt;/code&gt; and &lt;code&gt;status.1password.com&lt;/code&gt;) that serve third party JavaScript.&lt;/p&gt;
&lt;p&gt;The vulnerability went from &quot;Informative, working as intended&quot; to &quot;High severity, shipping a patch&quot; in a few months of back and forth, revealing a common blind spot in how we model trust with third-party vendors.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;A quick word on threat models, or: why your password manager is special&lt;/h2&gt;
&lt;p&gt;Most apps get to assume that if an attacker is running JavaScript on your origin, you&apos;ve already lost. XSS is game over, the reasoning goes, so why defend past it?&lt;/p&gt;
&lt;p&gt;A password manager doesn&apos;t get that luxury. The entire pitch of 1Password is &lt;strong&gt;zero-knowledge&lt;/strong&gt;: even 1Password can&apos;t read your vault, your master key never leaves your control, and &lt;em&gt;no single failure&lt;/em&gt; should expose it as described in their &lt;a href=&quot;https://1passwordstatic.com/files/security/1password-white-paper.pdf&quot;&gt;security whitepaper&lt;/a&gt;, itself an excellent read.&lt;/p&gt;
&lt;p&gt;So when the extension&apos;s design assumes that any JS running on a trusted hostname is safe to receive cryptographic secrets, it violates a core security guarantee. Keep this in mind, because 1Password&apos;s first response was essentially that XSS on their origin is game over anyway. For most products, that is fair. For a zero-knowledge password manager, it undermines the primary threat model.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;How the extension talks to the web app&lt;/h2&gt;
&lt;p&gt;The 1Password web app (&lt;code&gt;my.1password.com&lt;/code&gt;, or teams’ tenant subdomains) and the browser extension need to cooperate. When you&apos;re signed into the web app and your extension is unlocked, the extension can perform a &lt;strong&gt;Magic Unlock&lt;/strong&gt; (also known as &quot;Automatic sign-in to &lt;a href=&quot;http://1Password.com&quot;&gt;1Password.com&lt;/a&gt;&quot;) session delegation: it spins up a server-backed session for the web app so the page can decrypt and show your stuff.&lt;/p&gt;
&lt;p&gt;To pull this off, the content script &lt;code&gt;b5.js&lt;/code&gt; — injected into pages matching the allowlist — listens for events. Specifically, it listens for &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent&quot;&gt;&lt;code&gt;CustomEvent&lt;/code&gt;&lt;/a&gt;s dispatched on &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Document&quot;&gt;&lt;code&gt;document&lt;/code&gt;&lt;/a&gt;. The same &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Document&quot;&gt;&lt;code&gt;document&lt;/code&gt;&lt;/a&gt; that any script on the page can reach out and touch.&lt;/p&gt;
&lt;p&gt;Here&apos;s the allowlist that gates the creds— twelve domain suffixes:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1password.com, 1password.ca, 1password.eu,
b5dev.com,     b5dev.ca,     b5dev.eu,
b5test.com,    b5test.ca,    b5test.eu,
b5local.com,   b5staging.com, b5rev.com
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Nine of those are dev/staging domains. All of them have &lt;strong&gt;wildcard DNS&lt;/strong&gt; — &lt;code&gt;literally-anything.b5test.com&lt;/code&gt; resolves to AWS and serves the full 1Password web SPA. The only authorization gate between a page and your master key was: &lt;em&gt;does the hostname end in one of these twelve strings?&lt;/em&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;The flow, end to end&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Page dispatches &lt;code&gt;B5SessionInit&lt;/code&gt;&lt;/strong&gt; on &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Document&quot;&gt;&lt;code&gt;document&lt;/code&gt;&lt;/a&gt; with an &lt;code&gt;accountUuid&lt;/code&gt; and a &lt;code&gt;device&lt;/code&gt; object.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;b5.js&lt;/code&gt; (&lt;code&gt;Np()&lt;/code&gt;) catches it&lt;/strong&gt;, checks &lt;em&gt;only&lt;/em&gt; the hostname allowlist (&lt;code&gt;D()&lt;/code&gt;), and forwards it to the background script via &lt;code&gt;chrome.runtime.sendMessage&lt;/code&gt; as &lt;code&gt;b5-session-init&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Background (&lt;code&gt;gqe&lt;/code&gt;)&lt;/strong&gt; looks up the account by UUID in its local DB and calls &lt;code&gt;getDelegateSessionInit()&lt;/code&gt;, which phones the 1Password &lt;strong&gt;server&lt;/strong&gt; to mint a delegated session.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Server returns full session credentials.&lt;/strong&gt; Background sends &lt;code&gt;auto-sign-in-to-b5&lt;/code&gt; back to the content script.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;b5.js&lt;/code&gt; dispatches &lt;code&gt;B5InitializeSession&lt;/code&gt;&lt;/strong&gt; — as a &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent&quot;&gt;&lt;code&gt;CustomEvent&lt;/code&gt;&lt;/a&gt;, on &lt;code&gt;document&lt;/code&gt; — containing the goods:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code&gt;document.addEventListener(&quot;B5InitializeSession&quot;, (e) =&amp;gt; {
 // e.detail contains:
 //   masterKey   (JWK)  — decrypts your personal keyset → all vault keys → all items
 //   accountKey         — your Secret Key, in plaintext
 //   sessionKey  (JWK)  — active session encryption key
 //   email, deviceUuid, apiHost, derivationInfo
 //   serverConfig.notifier — a wss:// URL with a PASETO token valid for 30 days
 exfiltrate(e.detail);
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The attacker&apos;s entire exploit is: add an event listener, dispatch one event, collect the keys. Here&apos;s the actual PoC:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// 1. Listen for the response
document.addEventListener(&quot;B5InitializeSession&quot;, (e) =&amp;gt; {
 console.log(&quot;=== MASTER KEY + SESSION CREDENTIALS ===&quot;);
 console.log(JSON.stringify(e.detail));
});


// 2. Ask nicely for a session. A FRESH device UUID is required each time —
//    the server silently drops requests that reuse a device UUID.
document.dispatchEvent(new CustomEvent(&quot;B5SessionInit&quot;, {
 detail: {
   accountUuid: &quot;&amp;lt;target_account_uuid&amp;gt;&quot;,
   device: {
     uuid: crypto.randomUUID().replace(/-/g, &quot;&quot;).substring(0, 26),
     clientName: &quot;1Password for Web&quot;,
     clientVersion: &quot;2218&quot;,
     // ...standard device fields
   }
 }
}));
&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h2&gt;The missing controls&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Cryptographic challenge/response&lt;/li&gt;
&lt;li&gt;Proof the page actually authenticated&lt;/li&gt;
&lt;li&gt;Signature/HMAC on the event data&lt;/li&gt;
&lt;li&gt;Content-script isolation (not on &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Document&quot;&gt;&lt;code&gt;document&lt;/code&gt;&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Distinguishing production from dev/staging&lt;/li&gt;
&lt;li&gt;&lt;code&gt;event.isTrusted&lt;/code&gt; check&lt;/li&gt;
&lt;li&gt;Scoping delegation to the requesting origin&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The page&apos;s &lt;em&gt;own&lt;/em&gt; authentication state didn&apos;t matter. You didn&apos;t have to be signed in on the page. You didn&apos;t have to be on the sign-in page. You just had to be on a hostname that ended in one of the right twelve strings, and the extension would conjure a brand-new server-side session and read you the master key, secret key, and session key.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;&quot;Works as intended&quot;&lt;/h2&gt;
&lt;p&gt;I submitted the initial report on March 22. On March 27 the report was closed &lt;strong&gt;Informative&lt;/strong&gt; — the polite security-team way of saying &quot;valid observation, no bounty, no change.&quot; The reasoning:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The Magic Unlock delegation includes the AUK (Account Unlock Key) by design... The inclusion of dev/staging domains in the trusted allowlist is also a deliberate choice, made to support regression testing of production builds against those environments... The team is aware of this tradeoff and has made a conscious decision to maintain the current design.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;hr /&gt;
&lt;h2&gt;Maybe Not&lt;/h2&gt;
&lt;p&gt;The &quot;conscious decision&quot; rested on one load-bearing assumption:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The trust model assumes any hostname on the allowlist is under our control and serving content we authored.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;To verify this, I audited the twelve domain suffixes. The results showed that &quot;under our control and serving content we authored&quot; was no longer entirely accurate:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;passage.1password.eu&lt;/code&gt; → CNAME to &lt;code&gt;proxy-ssl.webflow.com&lt;/code&gt;, serving a Webflow 404&lt;/li&gt;
&lt;li&gt;&lt;code&gt;passage.1password.ca&lt;/code&gt; → CNAME to &lt;code&gt;proxy-ssl.webflow.com&lt;/code&gt;, TLS error&lt;/li&gt;
&lt;li&gt;&lt;code&gt;passkeys.1password.com&lt;/code&gt; → CNAME to &lt;code&gt;proxy-ssl.webflow.com&lt;/code&gt;, TLS error&lt;/li&gt;
&lt;li&gt;&lt;code&gt;b5app.b5dev.eu&lt;/code&gt; → CNAME to &lt;code&gt;cloudflare.net&lt;/code&gt;, connection refused&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Dangling CNAMEs pointing at deprovisioned third-party SaaS. The kind of thing that, on a normal domain, is a medium-severity subdomain-takeover finding worth a shrug. On a domain that the 1Password extension treats as &lt;strong&gt;cryptographically authoritative&lt;/strong&gt;, it&apos;s a direct path to your master key.&lt;/p&gt;
&lt;p&gt;The most critical finding wasn&apos;t dangling records, but live ones:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;When I go to &lt;code&gt;https://brand.1password.com&lt;/code&gt;, I&apos;m served &lt;strong&gt;Frontify&lt;/strong&gt; JS on a hostname on the allowlist. You did not write this code, and you may not even be aware of what the code is unless Frontify runs all their releases by 1Password first. Yet this JS has full cryptographic authority over the visiting user&apos;s 1Password keys.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That&apos;s the whole point of the post, really. The trust boundary wasn&apos;t &quot;JavaScript 1Password wrote.&quot; It was &quot;JavaScript served by &lt;em&gt;anyone&lt;/em&gt; 1Password ever pointed a subdomain at&quot; — Frontify (&lt;code&gt;brand.1password.com&lt;/code&gt;), Atlassian (&lt;code&gt;status.1password.com&lt;/code&gt;), Lithium/Khoros (&lt;code&gt;communitystage.1password.com&lt;/code&gt;), Webflow, and whoever they delegate &lt;em&gt;their&lt;/em&gt; infrastructure to. The boundary you think you&apos;re holding is only as strong as the weakest vendor in your CNAME records.&lt;/p&gt;
&lt;p&gt;The report got reopened on April 12.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;The severity climb&lt;/h2&gt;
&lt;p&gt;Here is the timeline of the severity escalation:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Status&lt;/th&gt;
&lt;th&gt;Reasoning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Mar 27&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Informative&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&quot;Working as intended&quot;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Apr 12&lt;/td&gt;
&lt;td&gt;Reopened&lt;/td&gt;
&lt;td&gt;DNS audit landed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;May 6&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Medium&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&quot;Attacker must first compromise a 1Password property — high bar&quot;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jun 1&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;High&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&quot;Compromise of a &lt;em&gt;third-party provider&lt;/em&gt; hosting an allowlisted subdomain is itself sufficient&quot;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The Medium→High jump came down to an argument about chain depth. 1Password initially scored it as a chain requiring &lt;em&gt;two&lt;/em&gt; exploitable conditions (compromise a 1Password property &lt;strong&gt;and&lt;/strong&gt; intercept the delegation). I pushed back:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&quot;An attacker has to first compromise a 1Password property&quot; — this is not true. They could compromise a Frontify, Atlassian, or Lithium property. They could be a malicious insider. They could compromise an employee or service credential at one of those companies. They could be a well-meaning Atlassian engineer who accidentally introduces an HTML-injection bug on the status page.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;To their credit, the team agreed:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;On closer review, we agree that compromise of a provider hosting one of the allowlisted subdomains is itself sufficient to deliver arbitrary content on that subdomain. That collapses the chain depth and warrants a higher rating. Your pushback also prompted us to look more critically at how we score scenarios that depend on third-party trust, particularly in light of the slew of supply chain compromises that have surfaced across the industry recently.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In an era of xz, npm, and a steady drip of SaaS-supply-chain incidents, &quot;we trust every vendor we ever CNAME&apos;d to&quot; is not the threat model you want guarding a master key.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;The Fix&lt;/h2&gt;
&lt;p&gt;1Password&apos;s first instinct on severity was that some key exposure is &quot;inherent to the feature working at all.&quot; This is the part worth dwelling on, because it&apos;s the engineering lesson.&lt;/p&gt;
&lt;p&gt;It is &lt;em&gt;not&lt;/em&gt; inherent. There&apos;s no functional requirement to broadcast cryptographic material onto the page&apos;s &lt;code&gt;document&lt;/code&gt; via a &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent&quot;&gt;&lt;code&gt;CustomEvent&lt;/code&gt;&lt;/a&gt; that any script can listen for. The fix is the boring, correct one:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Don&apos;t put secrets on &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Document&quot;&gt;&lt;code&gt;document&lt;/code&gt;&lt;/a&gt;.&lt;/strong&gt; &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent&quot;&gt;&lt;code&gt;CustomEvent&lt;/code&gt;&lt;/a&gt; on &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Document&quot;&gt;&lt;code&gt;document&lt;/code&gt;&lt;/a&gt; is a public address system. Use &lt;a href=&quot;https://developer.chrome.com/docs/extensions/reference/api/runtime&quot;&gt;&lt;code&gt;chrome.runtime&lt;/code&gt;&lt;/a&gt; messaging exclusively, or a private &lt;code&gt;MessageChannel&lt;/code&gt;, where the page&apos;s arbitrary scripts can&apos;t eavesdrop.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Origin-isolate the crypto context.&lt;/strong&gt; Move the &quot;view/copy/decrypt&quot; surface into an origin-isolated iframe (e.g. &lt;code&gt;crypto.1password.com&lt;/code&gt;) and pass keys via a &lt;em&gt;targeted&lt;/em&gt; &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage&quot;&gt;&lt;code&gt;postMessage&lt;/code&gt;&lt;/a&gt; to that specific origin. Now a vendor XSS or a subdomain takeover on &lt;code&gt;brand.1password.com&lt;/code&gt; escalates to... a vendor XSS on &lt;code&gt;brand.1password.com&lt;/code&gt;. Not a vault breach.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Scope delegation to the tenant.&lt;/strong&gt; Validate that the requesting origin matches the &lt;code&gt;apiHost&lt;/code&gt; of the account being requested. No more cross-tenant delegation from a marketing subdomain.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;What 1Password shipped in &lt;strong&gt;8.12.21&lt;/strong&gt; is the third one: Magic Unlock is now constrained to the sign-in surfaces that match the user&apos;s exact signed-in tenant. This effectively breaks the exploit chain I reported, as a random allowlisted subdomain can no longer mint a session for an arbitrary account. The dangling subdomains were decommissioned, and the broader &quot;should the crypto context be DOM-isolated&quot; question got punted to a longer architectural review. That last one is the real prize, and I hope they take it.&lt;/p&gt;
&lt;p&gt;The general principle, and the title of this post: &lt;strong&gt;your DOM is a hostile, shared space.&lt;/strong&gt; Anything you dispatch onto &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Document&quot;&gt;&lt;code&gt;document&lt;/code&gt;&lt;/a&gt; is something you&apos;ve handed to every script on the page — including the one your vendor&apos;s vendor shipped last Tuesday.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;A Note on Browser Extensions&lt;/h2&gt;
&lt;p&gt;If you install a browser extension with &amp;lt;all_urls&amp;gt; permissions (like an AI grammar checker, an adblocker, or a coupon clipper), and that extension is compromised or sold to a malicious actor, you have a major problem. For most websites, a malicious extension can scrape your current session cookies or read passwords as you type them.
But with this architecture, a compromised extension doesn&apos;t have to wait for you to type anything. It can steal your entire vault instantly, silently, in the background:&lt;/p&gt;
&lt;p&gt;For individual accounts: The extension simply opens a hidden iframe to &lt;a href=&quot;http://my.1password.com&quot;&gt;my.1password.com&lt;/a&gt;, dispatches the B5SessionInit event, and listens for the Master Key to be dropped onto the document.
For Team accounts: The extension reads localStorage on any 1Password page (or observes browser traffic) to find your specific tenant URL (e.g., &lt;a href=&quot;http://company.1password.com&quot;&gt;company.1password.com&lt;/a&gt;), opens a hidden iframe to that exact tenant, and runs the same exploit.&lt;/p&gt;
&lt;p&gt;Because the request originates from the correct tenant, 1Password&apos;s patch allows it (in fact, even if they moved off &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Document&quot;&gt;&lt;code&gt;document&lt;/code&gt;&lt;/a&gt; into an origin-isolated iframe, this risk remains). The extension hands over the Master Key, and the attacker decrypts your vault without you ever interacting with the password manager.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Timeline&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;2026-03-22&lt;/strong&gt; — Reported.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;2026-03-27&lt;/strong&gt; — Closed &lt;strong&gt;Informative&lt;/strong&gt; (&quot;works as intended&quot;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;2026-03-28&lt;/strong&gt; — DNS audit submitted (dangling CNAMEs + third-party JS on allowlisted origins).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;2026-04-12&lt;/strong&gt; — Reopened.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;2026-04-30&lt;/strong&gt; — Reproduction confirmed&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;2026-05-06&lt;/strong&gt; — Rated &lt;strong&gt;Medium&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;2026-05-06&lt;/strong&gt; - Emphasized supply-chain risk of 3rd party JS on allowlisted domains.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;2026-06-01&lt;/strong&gt; — Re-rated &lt;strong&gt;High&lt;/strong&gt;. Fix shipped in 8.12.21.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;2026-06-23&lt;/strong&gt; — Coordinated public disclosure.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2&gt;Lessons for the rest of us&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;An allowlist is only as strong as everything it points to.&lt;/strong&gt; Audit what&apos;s actually &lt;em&gt;served&lt;/em&gt; on every entry — including the CNAME targets and the third parties behind them. &quot;Under our control&quot; is a claim with an expiry date.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent&quot;&gt;&lt;code&gt;CustomEvent&lt;/code&gt;&lt;/a&gt; on &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Document&quot;&gt;&lt;code&gt;document&lt;/code&gt;&lt;/a&gt; is not a private channel.&lt;/strong&gt; If your content script broadcasts secrets there, you&apos;ve published them to the page.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Password managers don&apos;t get to treat XSS as game over.&lt;/strong&gt; Defense in depth means the master key survives a compromised origin. If it doesn&apos;t, &quot;defense in depth&quot; is marketing.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;em&gt;Thanks to the 1Password security team, who engaged thoughtfully, raised their own severity twice, owned a process gap, and shipped a fix.&lt;/em&gt;&lt;/p&gt;
</content:encoded></item><item><title>Making inference on Mac a little faster</title><link>https://guyfischman.com/posts/idiv-metal/</link><guid isPermaLink="true">https://guyfischman.com/posts/idiv-metal/</guid><description>Or: how I spent thirteen months almost noticing what a WWDC talk said out loud a decade ago</description><pubDate>Fri, 15 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;em&gt;Or: how I spent thirteen months[^1] almost noticing what a WWDC talk said out loud a decade ago.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;[^1]: The actual investigation was a day. I noticed the idiv
weirdness, forgot about it for a year, and only wandered back into the llama hot loop last week because I was procrastinating on something else.&lt;/p&gt;
&lt;p&gt;Apple&apos;s M-series GPU has no hardware integer divide. None. In 2026. So when you ask AGX to compute &lt;code&gt;a / b&lt;/code&gt;, it runs a ~730-cycle software subroutine — a tiny shameful program nestled inside an otherwise competent GPU (or at least mostly competent. It
also lacks &lt;code&gt;double&lt;/code&gt; - more on that in a future post), doing long division the way
you learned it in fourth grade. That is unless the divisor is a compile-time constant
&lt;em&gt;to the AGX backend&lt;/em&gt;, which is a much narrower category than you&apos;d think.&lt;/p&gt;
&lt;p&gt;ggml&apos;s Metal matmul kernels (&lt;code&gt;mul_mm&lt;/code&gt;, &lt;code&gt;mul_mv&lt;/code&gt;) eat four such divides per thread, by values that are constant for the entire inference session. The divisors come in through a uniform buffer, so the AGX compiler never sees them, so every dispatch pays ~2,800 cycles of &lt;code&gt;udiv&lt;/code&gt; it absolutely doesn&apos;t have to. Multiply by every thread of every dispatch of every layer of every token on every Mac running llama.cpp, and you arrive at a number that&apos;s embarrassing to contemplate.&lt;/p&gt;
&lt;p&gt;The fix is mechanical: promote the four divisors to MSL
&lt;code&gt;[[function_constant]]&lt;/code&gt;s, baked into the pipeline-state object at PSO-compile time. The AGX backend then strength-reduces them to a no-op (&lt;code&gt;ne12=1&lt;/code&gt;), a shift (pow2), or a magic-multiply (otherwise).&lt;/p&gt;
&lt;h2&gt;Where AGX&apos;s divide goes&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;where &lt;code&gt;d&lt;/code&gt; comes from&lt;/th&gt;
&lt;th&gt;per-op cost&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pow2 literal (&lt;code&gt;% 256u&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;~5 cy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Non-pow2 literal (&lt;code&gt;% 255u&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;~80 cy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;[[function_constant]]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;~80 cy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kernel argument / uniform buffer&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;~730 cy&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The slow path exists because at PSO build there&apos;s no value to fold; the buffer&apos;s contents only exist at dispatch time. The fast paths all share one thing: AGX could see the divisor when it built the pipeline. It turns out, Apple warned us about it in a talk a decade ago at WWDC2016 - &lt;a href=&quot;https://developer.apple.com/videos/play/wwdc2016/606/?time=1521&quot;&gt;&quot;So avoid divisional modulus by denominators that are not literal or function constants...that will be very, very slow. Think hundreds of clock seconds&quot;&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;When it matters&lt;/h2&gt;
&lt;p&gt;The win requires three things at once:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The kernel is &lt;strong&gt;ALU-bound&lt;/strong&gt;, not memory-bound. If the divide hides behind a memory stall, fixing it buys nothing.&lt;/li&gt;
&lt;li&gt;The divisor is &lt;strong&gt;constant for the run&lt;/strong&gt; — tensor dims, GQA group sizes, ring-buffer lengths.&lt;/li&gt;
&lt;li&gt;The divide happens &lt;strong&gt;often&lt;/strong&gt; — once per thread, large grid.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;ggml&apos;s matmul kernels happen to hit all three. Most other places you&apos;d grep for don&apos;t — fragment shaders are float-land, audio kernels are memory-bound, Stable Diffusion&apos;s UNet has the wrong arithmetic intensity. So this isn&apos;t some general technique I&apos;ve unlocked; it&apos;s one kernel family where the stars aligned.&lt;/p&gt;
&lt;h2&gt;The fix&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;// before — divisors come through args struct
const int i13 = im / args.ne12;        // 730 cy
const int i12 = im % args.ne12;        // 730 cy
const int i02 = i12 / args.r2;         // 730 cy
const int i03 = i13 / args.r3;         // 730 cy

// after — same values, promoted to function constants
constant int16_t FC_mul_mv_ne12 [[function_constant(FC_MUL_MV_NE12)]];
const int i13 = im / FC_mul_mv_ne12;   // 80 cy magic-multiply (or 5cy shift, or no-op)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/ggml-org/llama.cpp/pull/22711&quot;&gt;ggml-org/llama.cpp#22711&lt;/a&gt;. +127 / −88 across 4 files.&lt;/p&gt;
&lt;p&gt;Host-side: extract &lt;code&gt;(ne12, ne13, r2, r3)&lt;/code&gt; from the op shape, bind via &lt;code&gt;MTLFunctionConstantValues&lt;/code&gt;, thread them into the PSO cache key so a Gemma-2 GQA pipeline isn&apos;t reused for a TinyLlama (&lt;code&gt;ne12=1, r2=1, r3=1&lt;/code&gt;) op. The interesting code is two lines; the boring code is two hundred.&lt;/p&gt;
&lt;h2&gt;Results&lt;/h2&gt;
&lt;p&gt;M4 Pro, &lt;code&gt;llama-bench -p 512 -n 128 -r 20&lt;/code&gt;, tg128 tok/s:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;model&lt;/th&gt;
&lt;th&gt;quant&lt;/th&gt;
&lt;th&gt;baseline&lt;/th&gt;
&lt;th&gt;patched&lt;/th&gt;
&lt;th&gt;delta&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;TinyLlama 1.1B&lt;/td&gt;
&lt;td&gt;Q4_0&lt;/td&gt;
&lt;td&gt;239.05&lt;/td&gt;
&lt;td&gt;246.57&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;+3.15%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Llama 3.2 1B&lt;/td&gt;
&lt;td&gt;Q4_0&lt;/td&gt;
&lt;td&gt;227.58&lt;/td&gt;
&lt;td&gt;230.96&lt;/td&gt;
&lt;td&gt;+1.49% (noise)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gemma 3 1B (GQA)&lt;/td&gt;
&lt;td&gt;Q4_K_M&lt;/td&gt;
&lt;td&gt;164.67&lt;/td&gt;
&lt;td&gt;173.52&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;+5.37%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gemma 2 2B (GQA)&lt;/td&gt;
&lt;td&gt;Q4_K_M&lt;/td&gt;
&lt;td&gt;103.41&lt;/td&gt;
&lt;td&gt;106.66&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;+3.14%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mistral 7B (GQA)&lt;/td&gt;
&lt;td&gt;Q4_0&lt;/td&gt;
&lt;td&gt;52.10&lt;/td&gt;
&lt;td&gt;52.73&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;+1.21%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Perplexity bit-identical (magic-multiply is exact for unsigned division, and since
our values are trivially nonnegative the compiler folds them). The biggest wins are
on GQA models — exactly the ones people actually run - which hit &lt;em&gt;all four&lt;/em&gt; divisors meaningfully — &lt;code&gt;r2&lt;/code&gt; and &lt;code&gt;r3&lt;/code&gt; are &amp;gt;1 and dividing is real work.&lt;/p&gt;
&lt;h2&gt;Global impact, or lying with arithmetic&lt;/h2&gt;
&lt;p&gt;1M DAU × ~20K tokens/day ÷ ~150 tok/s × ~3% speedup ≈ &lt;strong&gt;~46 person-years per year&lt;/strong&gt;, if you squint. Add the rest of the ggml ecosystem and call it 50. These numbers are off by up to 10× in either direction.&lt;/p&gt;
&lt;p&gt;If you write Metal compute: grep your &lt;code&gt;.metal&lt;/code&gt; files for &lt;code&gt;/ args.&lt;/code&gt; and &lt;code&gt;% args.&lt;/code&gt;. For each hit, ask if the divisor is constant for the kernel&apos;s deployment. If yes, and the kernel isn&apos;t memory-bound, there&apos;s a ~9× win sitting on the divide.&lt;/p&gt;
&lt;p&gt;If you don&apos;t write Metal but ship software that runs ggml on a Mac: things got 1–5% faster this week.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;PR: &lt;a href=&quot;https://github.com/ggml-org/llama.cpp/pull/22711&quot;&gt;ggml-org/llama.cpp#22711&lt;/a&gt;. Reproducer: &lt;a href=&quot;https://github.com/SovereignSoft/agx-idiv-demo&quot;&gt;github.com/SovereignSoft/agx-idiv-demo&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
</content:encoded></item></channel></rss>