Google Apps Script lets any Workspace user write code that acts on Gmail, Drive, Sheets and Calendar with their own OAuth grant, and by default every user can do it. A script authorised once can keep running on a time-driven trigger as its creator, call external URLs and publish web apps that run under the owner's identity. That makes Apps Script a quiet source of non-human access: scripts behave like small integrations, but they are created outside IT and rarely inventoried. This guide is for Workspace administrators and security engineers who need to govern Apps Script: scopes, triggers, web app deployments, the admin controls, and how to monitor and clean up projects. For the related admin-granted access model, see the Google Workspace Domain-Wide Delegation Security Guide.
This is an independent guide from NHI Mgmt Group, based on Google's public Apps Script documentation as of November 2026. It is not sponsored or reviewed by Google. Product features change, so confirm settings against Google's current documentation.
Key takeaways
- Apps Script is on for everyone by default. Google's admin documentation states the service is on for all users and guests until you change it by OU or group.
- Scripts inherit the user's access. A script acts with the OAuth scopes the user granted, so a broad scope on a user with wide Drive access is a broad integration.
- Triggers run as their creator. Installable triggers keep executing under the account that created them, and other users cannot see them.
- Outbound calls are open unless you restrict them. By default scripts and Sheets functions can send or fetch data to any URL; the Importing and fetching from URLs allowlist changes that on supported editions.
- You can see more than most admins look at. Drive log events for Google Script files, the Apps Script usage report, OAuth grants and the default Cloud projects together give a usable inventory.
How Apps Script acts as a non-human identity
An Apps Script project is code stored as a Drive file, either standalone or bound to a Sheet, Doc, Form or Slides file. When it first runs, the user sees a consent screen listing the scopes the code needs. Once granted, that authorisation is reused by triggers, web apps and API executions without the user present. Each project is backed by a Google Cloud project: by default an automatically created, hidden default project, or a standard project the developer creates and manages.
Google's governance documentation describes where default projects live: under Organization root > system-gsuite > apps-script, with project IDs beginning sys-. The IAM policy on each default project lists a single Google-managed service account, [email protected], not the owning user. Default projects are deleted automatically after 180 days without a script run, and copying a spreadsheet copies its bound script, so each copy that runs creates another default project. Do not delete the system-gsuite or apps-script folders: Google warns that scripts then fail to run.
| Execution path | Runs as | Main risk |
|---|---|---|
| Manual run from editor or menu | The user running it | Over-broad scopes granted on first consent |
| Simple triggers (onOpen, onEdit) | The active user, with restricted capabilities | Limited, but code in shared files runs for every editor |
| Installable triggers (time-driven, edit, change, form submit, calendar) | The account that created the trigger | Persistent, unattended access that outlives the original need |
| Web app, executeAs USER_DEPLOYING | The deployer | Anyone allowed to reach the URL acts with the deployer's access |
| Web app, executeAs USER_ACCESSING | The visitor | Phishing-style consent prompts to many users |
| API executable (Apps Script API) | Depends on deployment access | Remote invocation of script functions |
| Add-ons and Marketplace apps built on Apps Script | The installing user | Governed by Marketplace and API controls, not the Apps Script on/off switch |
OAuth scopes: what a script can touch
Apps Script scans code and sets most scopes automatically. Google's documentation notes that this can assign broader scopes than needed, and recommends declaring explicit scopes for published add-ons, web apps and Chat apps.
- Declare scopes explicitly: show the
appsscript.jsonmanifest in Project Settings and list only required scopes inoauthScopes. For example,https://www.googleapis.com/auth/spreadsheets.readonlyinstead of full spreadsheet access. - Handle granular consent: users can grant some scopes and refuse others. Scripts should call
ScriptApp.requireScopesorScriptApp.getAuthorizationInfobefore using a service, and callrequireScopeswhen installing a trigger, because installable triggers cannot prompt during execution. - Review scopes before approval: the project's Overview page lists Project OAuth Scopes. Use it in code review for any script that will run on a trigger or be shared.
- Never expose tokens: Google warns not to send
ScriptApp.getOAuthTokenoutput to the client side of a web app, because it can give other applications access to the user's data.
Treat Gmail send, full Drive and admin directory scopes as high risk. The OAuth Scope Design Guide covers scope minimisation patterns that apply directly here.
Triggers: persistent access nobody sees
Installable triggers always run under the account of the person who created them. Google's documentation notes that an open trigger fires when a colleague with edit access opens the file, but runs as the creator, and that one account cannot see triggers installed by another. Time-driven triggers can run from every minute to once a month.
- Ownership: a trigger on a shared spreadsheet keeps acting with the creator's mailbox and Drive access even after the creator has moved team. Agree that production automations run from a dedicated, governed account or move to a managed integration, rather than an individual's account.
- Leavers: include Apps Script projects and triggers in offboarding reviews. Find and migrate business-critical triggers before suspending or deleting the account, so the process neither breaks nor keeps running on a departed person's access. See the Joiner-Mover-Leaver Guide.
- Loops and volume: executions and API requests do not fire triggers (Google notes an exception for
Form.submitGrades()), but quotas apply, so a runaway trigger shows up as quota errors before it shows up as a security issue.
Web apps and API executables
A web app deployment has two settings, which the manifest exposes as webapp.executeAs and webapp.access.
| Setting | Value | Meaning | Guidance |
|---|---|---|---|
| executeAs | USER_DEPLOYING | Runs as the deployer | Only with access DOMAIN or narrower, and only when the deployer's access is scoped to the task |
| executeAs | USER_ACCESSING | Runs as the visitor | Preferred for internal tools; each user consents to their own access |
| access | MYSELF | Only the deployer | Personal tools and testing |
| access | DOMAIN | Users in the deployer's domain | Normal setting for internal web apps |
| access | ANYONE | Any signed-in Google user | Needs a documented business reason and review |
| access | ANYONE_ANONYMOUS | Anyone, not signed in | Highest risk, especially combined with USER_DEPLOYING; treat as a public endpoint acting as an employee |
The same access values apply to executionApi.access for API executables. The test deployment URL ending in /dev is limited to users with edit access and always runs the latest saved code, so it should never be shared as a production link. Web apps that run as the deployer can stop working if ownership moves to a shared drive or another domain, which is a useful signal when reviewing stale deployments.
Admin controls
Turn Apps Script on or off
The setting is at Apps > Google Workspace > Drive and Docs > Google Apps Script and needs the Drive and Docs administrator privilege. It is on by default and can be set per OU or access group, on all editions. When it is off for a user, Google lists the effects: the user cannot create or edit scripts, and script and trigger executions are blocked, including web apps, custom functions, Sheets macros, simple and installable triggers. AppSheet "Call a script", Google Ads scripts and Looker Studio community connectors also stop. Marketplace apps and add-ons built with Apps Script still install and run if Marketplace settings allow them.
Two edge cases matter. Scripts owned by users who have Apps Script off can still be run and edited by other users who have it on and can access the file. And if Apps Script is on but Drive and Docs is off, existing scripts still execute even though users cannot open the editor.
Restrict outbound connections
Importing and fetching from URLs, under Drive and Docs > Features and Applications, limits the URLs Apps Script (UrlFetch) and Sheets import functions can reach. By default any URL is allowed. The allowlist takes up to 1,000 entries, matches a URL and its paths, accepts one leading wildcard for subdomains, and returns an error for anything not listed. Google lists it for Frontline Plus, Business Plus, Enterprise Standard and Enterprise Plus, Education Standard and Education Plus, and Enterprise Essentials Plus. Add your required URLs before enabling it. Developers can apply the same principle per project with urlFetchWhitelist in the manifest, which requires HTTPS prefixes with a path and is required for versioned deployments.
API controls
Under Security > Access and data control > API controls, apps can be set to Trusted, Limited or Blocked, and Google services can be marked Restricted, including specific high-risk Gmail and Drive scopes. The Trust internal apps setting trusts domain-owned apps for user account access. Decide deliberately whether internal Apps Script projects should be trusted wholesale: trusting them lets any user-built script reach restricted services. See How to Inventory third party oauth apps in google workspace.
Decision guidance
| Situation | Approach | Trade-off |
|---|---|---|
| Small organisation, few scripts, no developer team | Turn Apps Script off by default; enable for a named access group | Users who rely on macros or custom functions lose them; inventory first |
| Large organisation with business automation in Sheets | Keep on; restrict high-risk scopes, enable the URL allowlist, run quarterly project reviews | Governance effort; needs an owner for the review |
| Regulated OUs (finance, HR, legal) | Turn off for the OU or allow only reviewed projects distributed as internal add-ons | Slower delivery of automations |
| Business-critical automation on a trigger | Move to a standard Cloud project with a governed owner, or to a managed integration | More set-up; much better ownership and logging |
| Public-facing form or endpoint | Avoid ANYONE_ANONYMOUS with USER_DEPLOYING; use a proper hosted service | Loses the convenience of a quick script |
Google's governance guidance recommends an internal directory of approved solutions distributed as published add-ons or Chat apps, and a naming convention for standalone projects. Both help separate supported automation from personal experiments. The Citizen Developer and Internal AI App Governance Guide covers the operating model.
Implementation plan
- Inventory: list default projects under the
system-gsuite > apps-scriptfolder (Google's documentation showsgcloud projects listfiltered by the folder ID), search Drive log events with document type Google Script, and pull the Apps Script usage report for active users and projects. - Classify: for each active project record owner, scopes, triggers, deployments and external URLs. Flag Gmail send, full Drive, admin scopes, ANYONE or ANYONE_ANONYMOUS web apps, and triggers owned by leavers or movers.
- Pilot restrictions: enable the Importing and fetching from URLs allowlist for a pilot OU with the URLs found in step 2, and review API controls for restricted services.
- Scope access: turn Apps Script off for OUs that do not need it, using an access group for approved builders. Test with the affected business teams for two weeks.
- Remediate: ask owners to declare explicit
oauthScopes, narrow web app access, and move critical triggers to governed accounts or standard projects. Google documents that deleting a project's Cloud project stops all its executions, which is the containment option for a single harmful script. - Roll back: both the service switch and the URL allowlist are per OU or group, so reverse a change by restoring inheritance on the OU. Allow up to 24 hours for changes to apply.
Detection and measurement
Google's admin documentation points to three sources: Drive log events filtered to document type Google Script for actions on projects, the Apps Script usage report (Reporting > Reports > Apps Reports > Apps Script) with six months of daily active users and projects, and Drive log events URL Accessed and Sheets Import URL for outbound URL calls. Add OAuth token events to see new grants to Apps Script projects. Export these to your SIEM; the Google Workspace Audit Log Detection Guide covers the export.
- Project hygiene: active projects with a named, current owner, as a percentage of all active projects.
- High-risk scope count: projects holding Gmail send, full Drive or admin scopes, trending down.
- Orphaned triggers: triggers owned by suspended, departed or moved accounts.
- Exposed web apps: deployments with ANYONE or ANYONE_ANONYMOUS access.
- Outbound reach: distinct external domains contacted by scripts per month, and blocked URL attempts after the allowlist is on.
Watch for a new project that receives a broad grant and immediately creates a time-driven trigger, and for scripts posting to unfamiliar external URLs: both fit token-based persistence and exfiltration over a web service.
Framework mapping
| Control area | NIST SP 800-53 Rev 5 | NIST CSF 2.0 | CIS Controls v8.1 | ISO/IEC 27001:2022 Annex A | ATT&CK addressed |
|---|---|---|---|---|---|
| Restrict who can run scripts | CM-7, CM-11 | PR.PS-05 | 2.7 | A.8.19 | T1102 |
| Scope minimisation and API controls | AC-6, AC-3 | PR.AA-05 | 6.8 | A.5.15 | T1528, T1550.001 |
| Outbound URL allowlist | SC-7 | PR.PS-05 | 13.10 | A.8.20 | T1567, T1102 |
| Monitoring projects, grants and URL calls | AU-6 | DE.CM-09 | 8.11 | A.8.16 | T1567 |
Common failure patterns
- Critical process on a personal trigger: a finance report or HR sync runs every hour as one employee; when they leave, either it breaks or nobody removes their access to keep it running.
- Anonymous web app running as the deployer: a quick form handler set to ANYONE_ANONYMOUS and USER_DEPLOYING gives the internet a URL that writes to Drive with an employee's access.
- Trusting all internal apps: Trust internal apps applied without review lets user-built scripts reach services you restricted for third-party apps.
- No outbound restriction: scripts send spreadsheet data to arbitrary URLs and nobody looks at URL Accessed events.
- Switch off without inventory: turning Apps Script off for everyone overnight stops macros, custom functions and AppSheet calls in live business processes, and the change is rolled back under pressure with no improvement made.
Practitioner checklist
- Inventory default projects, Google Script Drive events and the Apps Script usage report before changing anything.
- Decide per OU whether Apps Script is needed; turn it off where it is not and use an access group for approved builders.
- Enable the Importing and fetching from URLs allowlist where your edition supports it.
- Review API controls: restrict high-risk Gmail and Drive scopes and decide deliberately on Trust internal apps.
- Require explicit
oauthScopesandurlFetchWhitelistin the manifest for shared or triggered scripts. - Prohibit ANYONE_ANONYMOUS web apps that execute as the deployer without security review.
- Add Apps Script projects and triggers to joiner, mover and leaver procedures.
- Move business-critical automations to governed accounts or standard Cloud projects.
- Export Drive, OAuth token and URL access events to the SIEM and alert on new broad grants to scripts.
Standards and references
- Google Workspace Admin Help: Turn Apps Script on or off for users
- Google for Developers: Monitor and control Apps Script use in your Google Workspace organization
- Google for Developers: Govern Apps Script projects
- Google Workspace Admin Help: Allow only certain external connections for Apps Script and Sheets
- Google Workspace Admin Help: Control which third-party and internal apps access Google Workspace data
- Google for Developers: Apps Script authorization scopes
- Google for Developers: Apps Script installable triggers
- Google for Developers: Apps Script manifest, web apps and API executables
Related NHI Mgmt Group resources: Google Workspace Domain-Wide Delegation Security Guide · Google Workspace Security Guide · How to Inventory third party oauth apps in google workspace · OAuth Scope Design Guide · Low-Code and No-Code Application Security Guide