1. Resources
  2. Detection rules
  3. Backup Codes Generated or Security Key Added for a User by an Admin in Google Workspace

Backup Codes Generated or Security Key Added for a User by an Admin in Google Workspace detection rules

An attacker in a Google Workspace admin session generates backup codes for another user, registers a security key for them or turns off their login challenge, and so gets past that user's 2-Step Verification.

Platform
Google Cloud
Severity
High
Log source
Google Cloud Audit Logs
Last updated
Rule formats
Sigmaand queries for: SplunkMicrosoft SentinelIBM QRadar
What an attacker needs
Control of an admin account with user management privileges, a super admin account when the target is an administrator, and the target's password.
Impact
The attacker signs in as the target although 2-Step Verification is on, and a registered security key keeps working after a password reset.
Response
Secure the admin account that acted, remove security keys the owner does not recognise and generate new backup codes to invalidate the old ones.
Mitigation
Limit user management privileges to the helpdesk roles that need them and have the helpdesk verify the user before issuing codes or keys.
API methods
google.admin.AdminService.generate2SvScratchCodesgoogle.admin.AdminService.unblockUserSessiongoogle.admin.AdminService.securityKeyRegisteredForUser
Threat groups
Scattered Spider

How the attack works

Google Workspace gives administrators three recovery tools on a user's security page. They can get backup verification codes for a user who cannot reach their second factor, add a security key for a user, and turn off the login challenge for 10 minutes for a user who cannot verify their identity. All three exist for locked-out users, and all three let someone other than the owner satisfy or skip the second step of sign-in.

An attacker who controls an admin account uses them on a chosen target. Backup codes pass 2-Step Verification wherever it is on, including where it is enforced and a single user cannot be exempted. A security key that the attacker registers for the user stays valid as that user's second factor until someone removes it. Turning off the login challenge removes the extra check that Google applies when a sign-in looks suspicious. Together with a password the attacker knows or sets, each of them opens the account while its 2-Step Verification setting still reads on.

The Admin audit log records GENERATE_2SV_SCRATCH_CODES when new backup codes are generated for a user, SECURITY_KEY_REGISTERED_FOR_USER when a security key is registered for a user and UNBLOCK_USER_SESSION when a user is unblocked by temporarily disabling the login challenge. Each names the affected user in USER_EMAIL. Organizations that share Workspace data with Google Cloud receive them in Cloud Audit Logs at organization level as Admin Activity entries of admin.googleapis.com. Turning 2-Step Verification off or unenrolling a user is a different action and has its own page (2-Step Verification Weakened in Google Workspace).

What an attacker needs

  • Control of an admin account with user management privileges. Google states that only super administrators can generate backup codes for other admins.
  • The password of the target, or the right to reset it, which usually comes with the same role.

Impact

The attacker signs in as the target although 2-Step Verification is on for the account. Backup codes work until they are used up or replaced, and for users who must use a security key until the grace period that starts with the codes ends. A registered security key keeps working as the target's second factor until it is removed, so it survives a password reset. Google states that creating new backup codes invalidates the existing ones, so the owner's own codes stop working. Targets that hold admin roles or IAM roles in Google Cloud pass those privileges on.

Detection rules

Backup Verification Codes Generated for a User by an Admin in Google Workspace

Detects an administrator generating new 2-Step Verification backup codes for a user of a Google Workspace or Cloud Identity account (Admin audit event GENERATE_2SV_SCRATCH_CODES, rendered as "New 2-step verification scratch codes generated for the user {USER_EMAIL}"). A backup code passes the second step of sign-in in place of the user's phone or key, also where 2-Step Verification is enforced, so an attacker in an admin session uses it to get into a chosen account. Google states that creating new codes invalidates any existing code and that only super administrators can generate backup codes for other admins. The affected user is in the event parameter USER_EMAIL in protoPayload.metadata and the admin in principalEmail. The entry reaches Cloud Audit Logs as an Admin Activity entry at organization level, which is always written once Google Workspace data sharing with Google Cloud is enabled, and reaches the SIEM only when the organization-level logs are routed to it.

LevelMediumStatusExperimentalLog sourceGoogle Cloud Audit Logs
title: Backup Verification Codes Generated for a User by an Admin in Google Workspace
id: 9c0012a5-e9d0-4701-b307-18d35e6e4783
status: experimental
description: >-
  Detects an administrator generating new 2-Step Verification backup codes
  for a user of a Google Workspace or Cloud Identity account (Admin audit
  event GENERATE_2SV_SCRATCH_CODES, rendered as "New 2-step verification
  scratch codes generated for the user {USER_EMAIL}"). A backup code passes
  the second step of sign-in in place of the user's phone or key, also where
  2-Step Verification is enforced, so an attacker in an admin session uses
  it to get into a chosen account. Google states that creating new codes
  invalidates any existing code and that only super administrators can
  generate backup codes for other admins. The affected user is in the event
  parameter USER_EMAIL in protoPayload.metadata and the admin in
  principalEmail. The entry reaches Cloud Audit Logs as an Admin Activity
  entry at organization level, which is always written once Google
  Workspace data sharing with Google Cloud is enabled, and reaches the SIEM
  only when the organization-level logs are routed to it.
references:
  - https://docs.cloud.google.com/logging/docs/audit/gsuite-audit-logging
  - https://developers.google.com/workspace/admin/reports/v1/appendix/activity/admin-user-settings
  - https://knowledge.workspace.google.com/admin/security/manage-a-users-security-settings
  - https://attack.mitre.org/techniques/T1556/006/
author: Forestall
date: 2026-11-18
tags:
  - attack.defense-impairment
  - attack.persistence
  - attack.credential-access
  - attack.t1556.006
logsource:
  product: gcp
  service: gcp.audit
detection:
  selection:
    protoPayload.serviceName: admin.googleapis.com
    protoPayload.methodName: google.admin.AdminService.generate2SvScratchCodes
  condition: selection
falsepositives:
  - Helpdesk staff helping a user who lost a phone or left a security key at home, which is the purpose of the feature. Confirm each event against a ticket and with the user, and give priority to targets that are administrators or hold IAM roles in Google Cloud.
level: medium

False positives

  • Helpdesk staff helping a user who lost a phone or left a security key at home, which is the purpose of the feature. Confirm each event against a ticket and with the user, and give priority to targets that are administrators or hold IAM roles in Google Cloud.

Login Challenge Temporarily Turned Off for a User by an Admin in Google Workspace

Detects an administrator turning off the login challenge for a user of a Google Workspace or Cloud Identity account (Admin audit event UNBLOCK_USER_SESSION, rendered as "User {USER_EMAIL} unblocked by temporarily disabling login challenge"). Google presents a login challenge when it suspects that an unauthorized person is trying to sign in, and a verify-it's-you challenge before some sensitive actions. An admin can turn these off for one user for 10 minutes. An attacker in an admin session does this for an account whose password they hold, at the moment their own sign-in is being challenged. The affected user is in the event parameter USER_EMAIL in protoPayload.metadata and the admin in principalEmail. The entry reaches Cloud Audit Logs as an Admin Activity entry at organization level, which is always written once Google Workspace data sharing with Google Cloud is enabled, and reaches the SIEM only when the organization-level logs are routed to it.

LevelMediumStatusExperimentalLog sourceGoogle Cloud Audit Logs
title: Login Challenge Temporarily Turned Off for a User by an Admin in Google Workspace
id: b0cdbc83-9065-4b34-9c0d-bc7310caa146
status: experimental
description: >-
  Detects an administrator turning off the login challenge for a user of a
  Google Workspace or Cloud Identity account (Admin audit event
  UNBLOCK_USER_SESSION, rendered as "User {USER_EMAIL} unblocked by
  temporarily disabling login challenge"). Google presents a login challenge
  when it suspects that an unauthorized person is trying to sign in, and a
  verify-it's-you challenge before some sensitive actions. An admin can turn
  these off for one user for 10 minutes. An attacker in an admin session
  does this for an account whose password they hold, at the moment their
  own sign-in is being challenged. The affected user is in the event
  parameter USER_EMAIL in protoPayload.metadata and the admin in
  principalEmail. The entry reaches Cloud Audit Logs as an Admin Activity
  entry at organization level, which is always written once Google
  Workspace data sharing with Google Cloud is enabled, and reaches the SIEM
  only when the organization-level logs are routed to it.
references:
  - https://docs.cloud.google.com/logging/docs/audit/gsuite-audit-logging
  - https://developers.google.com/workspace/admin/reports/v1/appendix/activity/admin-user-settings
  - https://knowledge.workspace.google.com/admin/security/temporarily-turn-off-login-challenges-for-a-user
  - https://knowledge.workspace.google.com/admin/security/protect-google-workspace-accounts-with-security-challenges
  - https://attack.mitre.org/techniques/T1556/006/
author: Forestall
date: 2026-11-18
tags:
  - attack.defense-impairment
  - attack.persistence
  - attack.credential-access
  - attack.t1556.006
logsource:
  product: gcp
  service: gcp.audit
detection:
  selection:
    protoPayload.serviceName: admin.googleapis.com
    protoPayload.methodName: google.admin.AdminService.unblockUserSession
  condition: selection
falsepositives:
  - Helpdesk staff helping a user who cannot receive a verification code or does not remember their employee ID, which is the purpose of the feature. Confirm each event against a ticket, and review the user's sign-ins and account changes in the minutes after it.
level: medium

False positives

  • Helpdesk staff helping a user who cannot receive a verification code or does not remember their employee ID, which is the purpose of the feature. Confirm each event against a ticket, and review the user's sign-ins and account changes in the minutes after it.

Security Key Registered for a User in the Admin Audit Log of Google Workspace

Detects a security key being registered for a user of a Google Workspace or Cloud Identity account as recorded in the Admin audit log (event SECURITY_KEY_REGISTERED_FOR_USER, rendered as "Security key registered for {USER_EMAIL}"). Google's help describes how an admin adds a security key for a user on the user's security page, and states that a key added this way is for 2-Step Verification only. A key that an attacker in an admin session registers for a chosen user stays valid as that user's second factor until it is removed, so it outlasts a password reset. Google's reference does not say whether a key that a user adds in their own account is also written under this event, so compare the admin in principalEmail with the affected user in the event parameter USER_EMAIL in protoPayload.metadata. The entry reaches Cloud Audit Logs as an Admin Activity entry at organization level, which is always written once Google Workspace data sharing with Google Cloud is enabled, and reaches the SIEM only when the organization-level logs are routed to it.

LevelMediumStatusExperimentalLog sourceGoogle Cloud Audit Logs
title: Security Key Registered for a User in the Admin Audit Log of Google Workspace
id: 871d01cd-9f05-4822-97d9-29d752684371
status: experimental
description: >-
  Detects a security key being registered for a user of a Google Workspace
  or Cloud Identity account as recorded in the Admin audit log (event
  SECURITY_KEY_REGISTERED_FOR_USER, rendered as "Security key registered
  for {USER_EMAIL}"). Google's help describes how an admin adds a security
  key for a user on the user's security page, and states that a key added
  this way is for 2-Step Verification only. A key that an attacker in an
  admin session registers for a chosen user stays valid as that user's
  second factor until it is removed, so it outlasts a password reset.
  Google's reference does not say whether a key that a user adds in their
  own account is also written under this event, so compare the admin in
  principalEmail with the affected user in the event parameter USER_EMAIL
  in protoPayload.metadata. The entry reaches Cloud Audit Logs as an Admin
  Activity entry at organization level, which is always written once Google
  Workspace data sharing with Google Cloud is enabled, and reaches the SIEM
  only when the organization-level logs are routed to it.
references:
  - https://docs.cloud.google.com/logging/docs/audit/gsuite-audit-logging
  - https://developers.google.com/workspace/admin/reports/v1/appendix/activity/admin-user-settings
  - https://knowledge.workspace.google.com/admin/security/manage-a-users-security-settings
  - https://attack.mitre.org/techniques/T1556/006/
author: Forestall
date: 2026-11-18
tags:
  - attack.defense-impairment
  - attack.persistence
  - attack.credential-access
  - attack.t1556.006
logsource:
  product: gcp
  service: gcp.audit
detection:
  selection:
    protoPayload.serviceName: admin.googleapis.com
    protoPayload.methodName: google.admin.AdminService.securityKeyRegisteredForUser
  condition: selection
falsepositives:
  - Rollouts in which the IT team registers security keys for users before handing them out. These come in planned batches by known admins. Outside a rollout, confirm each event with the user, who can say whether the key listed on their account is theirs.
level: medium

False positives

  • Rollouts in which the IT team registers security keys for users before handing them out. These come in planned batches by known admins. Outside a rollout, confirm each event with the user, who can say whether the key listed on their account is theirs.

Detection logic

Patterns that need more than one event, a baseline or knowledge of your own environment. Each is a hypothesis to build and tune in your SIEM, not a ready rule.

Backup codes generated by an admin and then used to sign in from an unfamiliar address

Detection hypothesisSequence of eventsNeeds a baseline

Backup codes that the helpdesk hands to a locked-out user are used by that user from their usual network. Codes that an attacker generated in an admin session are used by the attacker. The pair of the admin event and a sign-in with a backup code from a place the user never signed in from is the trace.

  1. A google.admin.AdminService.generate2SvScratchCodes entry. Note the user in the event parameter USER_EMAIL and the admin in authenticationInfo.principalEmail.
  2. Within 24 hours, a google.login.LoginService.loginSuccess entry of login.googleapis.com for that user whose event parameter login_challenge_method holds backup_code.
  3. Compare the requestMetadata.callerIp of that sign-in with the addresses the user signed in from in the past 30 days.

Eventsgoogle.admin.AdminService.generate2SvScratchCodesgoogle.login.LoginService.loginSuccess

LimitsA user who lost a phone while travelling matches as well, so confirm with the user. The 24 hours and 30 days are starting points. A code that is used days later, or a sign-in from the user's own network through a compromised device, is not found.

Password reset and second factor issued for the same user by one admin

Detection hypothesisSequence of events

A locked-out user usually needs one thing, a new password or a way past the second factor. An attacker who takes an account over needs both, so the same admin sets a password and generates backup codes or registers a security key for the same user within minutes.

  1. A google.admin.AdminService.changePassword entry. Note USER_EMAIL and the admin in authenticationInfo.principalEmail.
  2. Within 60 minutes, before or after, a generate2SvScratchCodes, securityKeyRegisteredForUser or unblockUserSession entry of google.admin.AdminService by the same admin for the same USER_EMAIL.

Eventsgoogle.admin.AdminService.changePasswordgoogle.admin.AdminService.generate2SvScratchCodesgoogle.admin.AdminService.securityKeyRegisteredForUsergoogle.admin.AdminService.unblockUserSession

LimitsA user who lost both the phone and the password produces the same pair, so each match needs a ticket or a word with the user. The 60 minutes are a starting point. Two admin accounts that share the work do not match.

Triage

  • Read USER_EMAIL in the event parameters in protoPayload.metadata and compare it with the admin in principalEmail. Check whether the affected user holds an admin role in Workspace or IAM roles in Google Cloud.
  • Look for a helpdesk ticket, and confirm with the user through a second channel that they were locked out and asked for help.
  • Look for a password change for the same user by the same admin around that time (google.admin.AdminService.changePassword). A reset plus a way past the second factor is a complete takeover.
  • Review the user's sign-ins afterwards (google.login.LoginService.loginSuccess of login.googleapis.com). The event parameter login_challenge_method shows the method that was used, for example backup_code or security_key.
  • For a registered key, open the user's security page in the Admin console. The passkeys and security keys table shows when and where each key was added and last used, and the owner can say which keys are theirs.
  • Check the admin account itself. Review its recent sign-ins and whether it did the same for several users.

Response

Once the attack is confirmed:

  1. Secure the admin account that acted. Reset its password, reset its sign-in cookies so that existing sessions end, and review its own 2-Step Verification methods and admin roles.
  2. Remove every security key from the affected account that the owner does not recognise, on the user's security page in the Admin console.
  3. Generate new backup codes for the affected user and hand them to the verified owner. Creating new codes invalidates the ones the attacker holds.
  4. Reset the affected user's password with the owner verified, require a change at the next sign-in and reset the user's sign-in cookies.
  5. Establish what was done as the affected user from the first sign-in that used a backup code or the new key, and reverse changes such as mail forwarding, app access and role bindings.

Mitigation

  • Give user management privileges only to the helpdesk roles that need them, limited to the organizational units they serve, and keep super admins few.
  • Have the helpdesk verify the user through a second channel before it issues backup codes, adds a key or turns off a login challenge, and record each case in a ticket.
  • Enforce 2-Step Verification with security keys or passkeys for administrators and review the keys registered on those accounts regularly.
  • Alert on these three events when the target is an administrator or an account with IAM roles in Google Cloud, where recovery by the helpdesk should never be needed without notice.
  • Share Workspace data with Google Cloud and route the organization-level audit logs to the SIEM, including the Data Access log that carries the sign-in events.

Frequently asked questions

Why would an attacker generate backup codes instead of turning 2-Step Verification off?

Because turning it off is not always possible and is easier to notice. Google states that the option to turn 2-Step Verification off for a single user is disabled where it is enforced. Backup codes can be generated for a user in an enforced scope as well, even for users who must use a security key, and the account's 2-Step Verification setting does not change.

What happens to a user's existing backup codes when an admin generates new ones?

Google states that creating new verification codes invalidates any existing code. A user who finds that their saved codes no longer work, without having asked for new ones, has a reason to report it. The same behaviour is useful in the response, because a new set of codes makes the codes an attacker took worthless.

Can any admin generate backup codes for another administrator?

No. Google states that only super administrators can generate backup verification codes for other admins. Other admins can view and create backup codes only for their users. An event of this kind whose target is an administrator therefore comes from a super admin account, and that account is the first thing to check.

How long does a login challenge stay off when an admin turns it off for a user?

For 10 minutes. Google's help adds that the change can take several minutes to take effect. The setting applies to the login challenge and to the verify-it's-you challenge that Google shows before a sensitive action, so review both the sign-ins and the account changes of that user in the period after the event.

References

We respect your privacy

We use cookies to keep this site secure and working properly. With your permission, we also use optional cookies to understand usage and improve the experience. Cookie Policy

You can change your choice at any time.