Leaking All Users Google Drive Files
Google Classroom's assignment submission endpoint did not verify that the submitting student owned the Google Drive file ID being attached, and by adding the target user to the classroom, an attacker could submit the target's file ID and gain ownership of that file. This allowed access to another user's Google Drive files without permission.
Published on secreltyhiddenwriteups.blogspot.com
Long time no see. I decided to make some new blog posts about some of my top Google findings I have had over the years.
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.
Context
Google Drive is a file sharing service where users upload documents, PDFs or any other file and share them with other users. A file that is private, or simply not shared with you, returns an access denied error when you try to open it.
Google Classroom, at classroom.google.com, is the offering Google gives teachers and students to collaborate in a classroom-like environment. Teachers post announcements, assignments and grade papers. When a teacher posts an assignment, students receive a page to submit their work to the teacher for grading. That submission page lets a student attach a file, for example a Google Drive document they wrote for the class, and submit it.
When a student submits an assignment, Classroom runs a process that grants the teachers of the classroom ownership over the submitted document. Teachers need to be able to read the document once it is submitted, so the ownership transfer is part of the normal flow.
The finding described here let an attacker gain access to another user's Google Drive files without ever being granted access to them. The issue is fixed, and Google VRP paid a bounty for it.
Setup
The researcher used more than one account:
- An account that owns a Classroom and creates an assignment in it.
- A second account, controlled by the researcher, added to that Classroom as a student.
- A third account, the target, whose Drive files were to be accessed. This account is added to the Classroom as a student or teacher.
No special tooling is described. The work is done by intercepting and modifying the Classroom submission request, which is a batchexecute-style call carrying a f.req parameter.
Finding it
When a student attaches a Google Drive file to an assignment and submits it, the browser sends this request:
POST /v7/writesubmission?_reqid=4786040&rt=j HTTP/1.1
Host: [classroom.google.com](http://classroom.google.com)
f.req=[[3],[[["18537069787",["46653220298",["41400909728"]]],[["18537069787",["46653220298",["41400909728"]]],null,null,null,[[null,null,"[redacted]",2,"application/vnd.google-apps.ritz",null,null,null,null,null,null,null,null,null,[null,2]]],null,[],null,null,null,null,null,null,null,null,null,null,null,[],[]],[null,true],[]]],[null,true,null,true,true,null,true,true,true,null,null,null,true,null,[true],null,null,null,true,true,true,null,null,null,[[true,true]],[[true,true]]]]
Inside the f.req body, the value "[redacted]" is the ID of the student's Google Drive file being submitted for the assignment. The value application/vnd.google-apps.ritz appears next to it.
The request takes the file ID from the client and passes it to the submission flow. There were no proper RBAC checks verifying that the caller actually owned the Google Drive file being attached to the assignment. That is what made the file ID worth manipulating: if the backend trusted it, the ownership transfer that follows a submission might be applied to a file the submitter does not own.
Exploitation
Step 1: test a swapped file ID
The first test was to change the file ID in the request to the ID of a file belonging to another account. This did not grant access. At the time the researcher concluded the RBAC checks were working properly and that the behaviour was, if anything, only a UI issue: swapping the ID in the request did not give access to the other account's Drive file.
Step 2: add the target to the Classroom
Further digging produced a bypass that fully worked. If the person being targeted is added to your Google Classroom as a student or teacher, the same request then grants full access to their Google Drive file.
The flow is:
- Add the user you are targeting as a user to your Google Classroom and create an assignment in the Classroom.
- Add another account as a student that you control to the classroom and sign into that account.
- As the student account, submit an assignment and modify the request, putting the ID of the Google Drive file from the targeted user's Drive, the user you added to the classroom in step 1, into the request.
- Submit the assignment. You can then access their entire Google Drive file and get ownership over it.
Step 3: modify the submission request
As the student account, submit an assignment and modify this request:
POST /v7/writesubmission?_reqid=4786040&rt=j HTTP/1.1
Host: [classroom.google.com](http://classroom.google.com)
f.req=[[3],[[["18537069787",["46653220298",["41400909728"]]],[["18537069787",["46653220298",["41400909728"]]],null,null,null,[[null,null,"[redacted]",2,"application/vnd.google-apps.ritz"
The value to replace is the file ID in the position occupied by "[redacted]". Put there the ID of the Google Drive file, from the targeted user's Drive, belonging to the user you added to the classroom in step 1.
Step 4: submit and take ownership
Submit the assignment. The submission flow then grants ownership of the targeted file, and the attacker can access the entire file and holds ownership over it.
The researcher recorded a video of the flow:
Root cause
The submission flow took a Google Drive file ID supplied by the client, and there were no proper RBAC checks verifying ownership of the attached file. The missing piece was an authorisation check confirming that the submitter owned, or was otherwise entitled to, the file being attached. Without that check, the file ID in f.req is attacker-controlled input that decides which document the backend will hand ownership of to the classroom's teachers.
The first attempt, swapping the ID with no other change, failed, which suggests some check was in place. Adding the target to the Classroom as a student or teacher made the same request succeed. The report does not explain why adding the target to the Classroom made the same request succeed. The report does not describe the check itself, so the exact condition it evaluated is not stated.
Impact
An attacker who can add the target to a Classroom they control, and who controls a student account in that Classroom, can gain access to the target's Google Drive file and get ownership over it. The report describes access to the target's entire Google Drive file and ownership over it. The precondition is that the target is a member (student or teacher) of the attacker's Classroom, and the attacker needs the file ID of the file they want.
Fix
The issue is fixed. The check that should exist is an authorisation test on the file ID in the submission request, confirming that the submitting account owns or may legitimately attach that file, independent of who else is a member of the Classroom.
Variants to test
- Swap a client-supplied document or attachment ID in any submission, upload or share endpoint for an ID belonging to another account, and observe whether the response or a follow-up read shows the other account's content. A positive result is a successful read or an ownership or permission change on a file you do not own.
- Repeat the swap after adding the file's owner to the same group, classroom, team or project as the attacker. A positive result is that the request which failed before now succeeds, which points to a membership-based check standing in for an ownership check.
- Change the MIME type field next to the file ID (here
application/vnd.google-apps.ritz) while keeping a foreign file ID, and see whether the backend validates the type against the file. A positive result is a successful transfer of a file whose type does not match what was sent. - Test the same endpoint from an account that is a teacher rather than a student, and from an account that has been removed from the Classroom after the file was added. A positive result is that access or ownership persists or is granted where it should not be.
- Submit the same modified request twice, or resubmit after the assignment is graded, to see whether the ownership transfer is idempotent and whether it can be re-triggered on a file already transferred. A positive result is a second ownership change on a file the attacker no longer legitimately controls.
What happened, in plain words
Imagine a school where teachers hand out homework and students hand it back. When a student hands in a piece of work, the school automatically makes a copy for the teacher so the teacher can read and mark it. That automatic handover is the useful part of the system, and it is also where the problem lived.
Google Drive is Google's online storage for files: word documents, PDFs, photos, anything. You can keep a file private, share it with specific people, or share it with the world. If a file is private and you try to open it, Google shows you an "access denied" error. That is the normal, correct behaviour.
Google Classroom, at classroom.google.com, is Google's tool for schools. A teacher creates a class, posts announcements and assignments, and students join the class and submit their work. When a teacher posts an assignment, each student gets a page where they can attach a file (for example a document from their Drive) and press submit. When that happens, Classroom automatically gives the teacher ownership of the submitted document, because the teacher has to be able to read it to grade it.
The researcher found that this automatic handover could be pointed at somebody else's file. By changing one value in the request the browser sends when a student submits an assignment, and by first adding the target person to the attacker's own Classroom, the attacker could end up owning a file that belonged to the target, and could read it. The issue is fixed, and Google's bug bounty programme (Google VRP) paid a bounty for it.
A few words before we start, because they come up constantly:
- A request is a message your browser sends to a website's computer (the server) asking it to do something, like "save this assignment". The server sends back a response, which is the answer.
- An API is the set of addresses and rules a website's own pages use to talk to its server behind the scenes. Think of it as the service counter at the back of a shop: customers do not walk into it directly, but the shop's own staff do, and if you learn the counter's rules you can walk up to it too.
- A parameter is a named piece of information inside a request, like a field on a paper form.
f.reqbelow is one such field. - RBAC stands for Role-Based Access Control. It means the server decides what you may do based on your role (student, teacher, owner) and on whether you are entitled to the thing you are touching. In everyday terms: the librarian checks that the book you are returning is actually the one you borrowed, not just that you have a library card.
- An ID is a long string of letters and numbers that uniquely names one thing, like a barcode on a product. Google Drive files each have an ID, and so do Classroom assignments.
The setup
The researcher used more than one Google account:
- One account that owns a Classroom and creates an assignment in it.
- A second account, also controlled by the researcher, added to that Classroom as a student.
- A third account, the target, whose Drive files were to be accessed. This account is added to the Classroom as a student or teacher.
No special tools are described. The work is done by watching the request the browser sends when an assignment is submitted, and changing it before it goes out. Browsers have a built-in developer tools panel (usually opened with F12) that shows requests and lets you resend them with edits; that is the general idea of "intercepting and modifying a request".
Finding it
When a student attaches a Google Drive file to an assignment and submits it, the browser sends this request:
POST /v7/writesubmission?_reqid=4786040&rt=j HTTP/1.1
Host: [classroom.google.com](http://classroom.google.com)
f.req=[[3],[[["18537069787",["46653220298",["41400909728"]]],[["18537069787",["46653220298",["41400909728"]]],null,null,null,[[null,null,"[redacted]",2,"application/vnd.google-apps.ritz",null,null,null,null,null,null,null,null,null,[null,2]]],null,[],null,null,null,null,null,null,null,null,null,null,null,[],[]],[null,true],[]]],[null,true,null,true,true,null,true,true,true,null,null,null,true,null,[true],null,null,null,true,true,true,null,null,null,[[true,true]],[[true,true]]]]
Line by line, in plain words:
POST /v7/writesubmission?_reqid=4786040&rt=j HTTP/1.1is the first line of the request.POSTis the verb meaning "I am sending data to be saved"./v7/writesubmissionis the address on the server that handles assignment submissions. Everything after the?is extra information attached to the address:_reqid=4786040is a request identifier, andrt=jis another short flag. These are bookkeeping values the site uses; they are not the interesting part.Host: [classroom.google.com](http://classroom.google.com)says which website the request is aimed at. The square brackets and thehttp://inside them are how the link was written in the blog post; the actual host is classroom.google.com.- The blank line separates the headers (the envelope) from the body (the letter inside).
f.req=starts the body. Google's web pages often pack a whole bundle of information into one parameter calledf.req, formatted as a long nested list of values in square brackets. You do not need to read all of it. What matters is that somewhere inside that list sits the ID of the file being submitted."[redacted]"is that file ID: the barcode of the student's Google Drive document being handed in.2next to it is a small numeric value, and"application/vnd.google-apps.ritz"is another value in the list.application/vnd.google-apps.ritzis Google's internal label for one of its own document formats. The rest of the list is a mass ofnullplaceholders andtrue/falseswitches for options that were not used in this case.
The key observation: the request takes the file ID from the browser and passes it into the submission flow. The server did not properly check, using RBAC, that the person submitting actually owned the file being attached. That is what made the file ID worth tampering with. If the server simply trusts whatever ID arrives, then the automatic ownership handover that follows a submission might be applied to a file the submitter does not own at all.
Exploitation
Step 1: test a swapped file ID
The first test was to change the file ID in the request to the ID of a file belonging to another account. This did not grant access. At the time the researcher concluded the RBAC checks were working properly, and that the behaviour was, if anything, only a cosmetic issue in the page: swapping the ID in the request did not give access to the other account's Drive file.
Why try this first? Because it is the simplest possible test of whether the server trusts the browser. If the server had accepted the foreign ID and handed over the file, the bug would have been found in one move. It did not, so something was checking something.
Step 2: add the target to the Classroom
Further digging produced a bypass that fully worked. If the person being targeted is added to your Google Classroom as a student or teacher, the same request then grants full access to their Google Drive file.
The flow is:
- Add the user you are targeting as a user to your Google Classroom and create an assignment in the Classroom.
- Add another account as a student that you control to the classroom and sign into that account.
- As the student account, submit an assignment and modify the request, putting the ID of the Google Drive file from the targeted user's Drive, the user you added to the classroom in step 1, into the request.
- Submit the assignment. You can then access their entire Google Drive file and get ownership over it.
Why does adding the target matter? The report does not explain it; it only says that adding the target as a student or teacher made the same request succeed. The report does not describe the check itself, so the exact condition it evaluated is not stated.
Step 3: modify the submission request
As the student account, submit an assignment and modify this request:
POST /v7/writesubmission?_reqid=4786040&rt=j HTTP/1.1
Host: [classroom.google.com](http://classroom.google.com)
f.req=[[3],[[["18537069787",["46653220298",["41400909728"]]],[["18537069787",["46653220298",["41400909728"]]],null,null,null,[[null,null,"[redacted]",2,"application/vnd.google-apps.ritz"
This is the same request as before, cut off partway through the body. The parts you have already met are unchanged: the POST line, the Host line, and the start of the f.req list. The value to replace is the file ID in the position occupied by "[redacted]". Put there the ID of the Google Drive file, from the targeted user's Drive, belonging to the user you added to the classroom in step 1.
In other words: the request still looks like a normal student handing in homework, but the barcode inside it now points at somebody else's document.
Step 4: submit and take ownership
Submit the assignment. The submission flow then grants ownership of the targeted file, and the attacker can access the entire file and holds ownership over it.
The researcher recorded a video of the flow:
Root cause
The submission flow took a Google Drive file ID supplied by the browser, and there were no proper RBAC checks verifying ownership of the attached file. The missing piece was an authorisation check confirming that the submitter owned, or was otherwise entitled to, the file being attached. Without that check, the file ID in f.req is input the attacker controls, and it decides which document the server will hand ownership of to the classroom's teachers.
The first attempt, swapping the ID with no other change, failed, which suggests some check was in place. Adding the target to the Classroom as a student or teacher made the same request succeed.
Impact
An attacker who can add the target to a Classroom they control, and who controls a student account in that Classroom, can gain access to the target's Google Drive file and get ownership over it. The report describes access to the target's entire Google Drive file and ownership over it. The precondition is that the target is a member (student or teacher) of the attacker's Classroom, and the attacker needs the file ID of the file they want.
Fix
The issue is fixed. The check that should exist is an authorisation test on the file ID in the submission request, confirming that the submitting account owns or may legitimately attach that file, independent of who else is a member of the Classroom.
Variants to test
These are the kinds of follow-up tests a hunter would run after finding something like this. Each one asks: does the server check the thing it should check, or does it trust the browser?
- Swap a client-supplied document or attachment ID in any submission, upload or share endpoint for an ID belonging to another account, and observe whether the response or a follow-up read shows the other account's content. A positive result is a successful read or an ownership or permission change on a file you do not own.
- Repeat the swap after adding the file's owner to the same group, classroom, team or project as the attacker. A positive result is that the request which failed before now succeeds, which points to a membership-based check standing in for an ownership check.
- Change the MIME type field next to the file ID (here
application/vnd.google-apps.ritz) while keeping a foreign file ID, and see whether the server validates the type against the file. A positive result is a successful transfer of a file whose type does not match what was sent. - Test the same endpoint from an account that is a teacher rather than a student, and from an account that has been removed from the Classroom after the file was added. A positive result is that access or ownership persists or is granted where it should not be.
- Submit the same modified request twice, or resubmit after the assignment is graded, to see whether the ownership transfer is idempotent and whether it can be re-triggered on a file already transferred. A positive result is a second ownership change on a file the attacker no longer legitimately controls.
Glossary
- API: the set of addresses and rules a website's own pages use to talk to its server behind the scenes; the service counter at the back of the shop.
- Authorisation check: a check by the server that you are allowed to do the thing you are asking for, not just that you are logged in.
- Bounty: a reward paid by a company to someone who reports a security problem to it.
- Bug bounty programme: a scheme where a company invites outside researchers to report security problems and pays for valid ones. Google's is called Google VRP (Vulnerability Reward Program).
- Classroom: Google's tool for teachers and students to run classes, post assignments and submit work.
- Endpoint: one specific address on a server that handles one kind of request, such as
/v7/writesubmission. f.req: the parameter in which Google's pages pack a long nested list of values into a single request body.- File ID: the long string of letters and numbers that uniquely names one file in Google Drive, like a barcode.
- Google Drive: Google's online file storage and sharing service.
- Header: the part of a request that carries envelope information, such as which website it is aimed at.
- Host: the header line naming the website a request is sent to.
- ID: a unique identifier for a thing, such as a file or a request.
- Idempotent: an operation that gives the same result whether you do it once or several times.
- MIME type: a label saying what kind of file something is, such as
application/vnd.google-apps.ritz. - Ownership: the status of being the account that controls a file, including who can read, share or delete it.
- Parameter: a named piece of information inside a request, like a field on a form.
- POST: the request verb meaning "I am sending data to be saved or acted on".
- RBAC (Role-Based Access Control): deciding what someone may do based on their role and their entitlement to the specific thing they are touching.
- Request: a message your browser sends to a server asking it to do something.
- Response: the server's answer to a request.
- Server: the computer that runs a website and answers requests.
- Student account: in this context, a Google account added to a Classroom in the student role, used here to submit the assignment.
- Target: the person whose files the attacker wants to reach.
- Teacher account: a Google account that owns or teaches in a Classroom and receives submitted work.
- UI (user interface): the part of a website you see and click on, as opposed to what happens behind the scenes.
- VRP: Vulnerability Reward Program, Google's bug bounty programme.