Join our Newsletter — 33% off our NHI Course
Home› Guides› Google Apps Script Security Guide: Control Scopes, Triggers,…
Guide SaaS & OAuth Integrations

Google Apps Script Security Guide: Control Scopes, Triggers, Web Apps and Admin Settings

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 13 November 2026 14 min read
On this page

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 pathRuns asMain risk
Manual run from editor or menuThe user running itOver-broad scopes granted on first consent
Simple triggers (onOpen, onEdit)The active user, with restricted capabilitiesLimited, but code in shared files runs for every editor
Installable triggers (time-driven, edit, change, form submit, calendar)The account that created the triggerPersistent, unattended access that outlives the original need
Web app, executeAs USER_DEPLOYINGThe deployerAnyone allowed to reach the URL acts with the deployer's access
Web app, executeAs USER_ACCESSINGThe visitorPhishing-style consent prompts to many users
API executable (Apps Script API)Depends on deployment accessRemote invocation of script functions
Add-ons and Marketplace apps built on Apps ScriptThe installing userGoverned 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.json manifest in Project Settings and list only required scopes in oauthScopes. For example, https://www.googleapis.com/auth/spreadsheets.readonly instead of full spreadsheet access.
  • Handle granular consent: users can grant some scopes and refuse others. Scripts should call ScriptApp.requireScopes or ScriptApp.getAuthorizationInfo before using a service, and call requireScopes when 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.getOAuthToken output 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.

SettingValueMeaningGuidance
executeAsUSER_DEPLOYINGRuns as the deployerOnly with access DOMAIN or narrower, and only when the deployer's access is scoped to the task
executeAsUSER_ACCESSINGRuns as the visitorPreferred for internal tools; each user consents to their own access
accessMYSELFOnly the deployerPersonal tools and testing
accessDOMAINUsers in the deployer's domainNormal setting for internal web apps
accessANYONEAny signed-in Google userNeeds a documented business reason and review
accessANYONE_ANONYMOUSAnyone, not signed inHighest 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

SituationApproachTrade-off
Small organisation, few scripts, no developer teamTurn Apps Script off by default; enable for a named access groupUsers who rely on macros or custom functions lose them; inventory first
Large organisation with business automation in SheetsKeep on; restrict high-risk scopes, enable the URL allowlist, run quarterly project reviewsGovernance 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-onsSlower delivery of automations
Business-critical automation on a triggerMove to a standard Cloud project with a governed owner, or to a managed integrationMore set-up; much better ownership and logging
Public-facing form or endpointAvoid ANYONE_ANONYMOUS with USER_DEPLOYING; use a proper hosted serviceLoses 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

  1. Inventory: list default projects under the system-gsuite > apps-script folder (Google's documentation shows gcloud projects list filtered 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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 areaNIST SP 800-53 Rev 5NIST CSF 2.0CIS Controls v8.1ISO/IEC 27001:2022 Annex AATT&CK addressed
Restrict who can run scriptsCM-7, CM-11PR.PS-052.7A.8.19T1102
Scope minimisation and API controlsAC-6, AC-3PR.AA-056.8A.5.15T1528, T1550.001
Outbound URL allowlistSC-7PR.PS-0513.10A.8.20T1567, T1102
Monitoring projects, grants and URL callsAU-6DE.CM-098.11A.8.16T1567

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 oauthScopes and urlFetchWhitelist in 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

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

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 13 November 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.