For me the risk/issue with sharing code tied to authenticated triggers is not overtly obvious to folks. In fact, when we brought it up with our company's Google liaison and explained the risk they acknowledged it is unobvious.
Basically, if you give someone else edit access to a script where you own an authenticated/scoped trigger, you are giving them access to the scope.
Imagine a scenario where there is a team on G Suite enterprise is using GAS for some team purpose/function and there are two developers, User 1 and User 2:
- Emails get sent to the team and they need to be "processed" using GAS
- They don't have access to service IDs, and, honestly, the average/novice developer won't think they need it (more on this below)
- User 1 creates a script that uses GmailApp.search(...) to search for emails in their (User 1) Gmail with the word "query" and uses GmailApp.sendEmail(...) to send an email to User X from their (User 1) Gmail account
- User 1 creates a trigger to run the script every hour and, as part of the trigger creation process, authorizes the appropriate scopes (e.g. Gmail)
- User 1 gives User 2 edit access to the code because both of them are developers on the same team working on the same project/automation
- At this point, User 2 could modify the code to search for "confidential" and send an email to User 2. Since the trigger is already created and authorized by User 1, for the relevant scopes (which User 2 didn't change) the updated nefarious code would run under User 1's identity. Meaning, it will search User 1's Gmail for "confidential" and email User 2 all from User 1's Gmail account.
I know the documentation says that
triggers run under the owner's account and you should only give edit access to code if you trust them but there is a very fine line in saying I trust someone to edit the code vs. being able to make "trivial" changes to do things like change Gmail search criteria.
GAS becomes a double edge sword: it makes it super easy to create automation, and Google is all about collaboration so giving folks edit access is just a given. So you've got loads of novice developers using GAS for the first time and they won't realize that by giving someone else edit access they are inadvertently giving access to their Google identity.
I wonder how many organizations using G-Suite have novice/inexperienced GAS developers giving edit access to their code -- code that is tied to an authenticated trigger.
At first I thought we could use triggers created against specific deployed versions but for some stupid reason whenever you deploy a new version, all triggers will be automatically updated to the new deployed version. A feature request was submitted for this so I guess we'll see what happens:
https://issuetracker.google.com/issues/145770681.
This was a big gotcha for me when I first realized it. You basically have two options: either you accept the risk and give other folks access to your Google identity (i.e. Gmail, Drive, etc...) or you don't collaborate which means nobody can support you if you're unavailable.