Skip to content

Automation  ·  IT and security

How to build compromised account response

The password was reset within the hour, and the attacker's open session kept reading mail for two more days. The design behind response that cuts off every way in, the prompts that build it, and what running it takes.

Built with Tray Headless

  1. System Okta
  2. Step Ask the user
  3. Step Revoke everywhere
  4. Step Remove what was left
  5. System Jira
Also Slack

Resetting the password is one step of six. Sessions, tokens, sign-in methods and mail rules are cut off together, because any one left behind keeps the attacker in.

The short answer

What is compromised account response automation?

Compromised account response has four parts: checking a risky sign-in with the user before anything else, so a trip abroad is resolved in one message; cutting off every way in on a confirmed takeover, which means sessions, tokens and sign-in methods in every app, not just the password; finding and removing what the attacker left behind, such as mail forwarding rules, new sign-in methods and app grants; and recording every step on one case. The common miss is stopping at the password reset. An open session or a forwarding rule outlives the reset, and the attacker keeps reading.

Stage 4 of 7: Compromised account response. Part of Security operations, end to end : every stage, the systems it runs on and the guide that builds it.

What matters here

  • Ask the user first. Most risky sign-ins are travel or a new phone, and one message settles them.
  • Cut off every way in at once: sessions, tokens and sign-in methods, in every app the account reaches.
  • A password reset alone leaves open sessions working. Revoke them explicitly.
  • Look for what the attacker left: forwarding rules, new sign-in methods, app grants and new API tokens.
  • Accounts with admin power go to a person before anything is cut off, with the evidence attached.

Who this is for

You run security operations or identity. Risky sign-in alerts arrive every day, most are harmless, and the real ones need minutes, not a ticket queue.

How it works in practice

From a risky sign-in alert to the account being safe again.

  1. 1

    A risky sign-in raises an alert

    Impossible travel, a new country, a sign-in method change or a burst of failed attempts.

  2. 2

    The account's context is attached

    Who they are, what they can reach, whether they have admin power, and what changed on the account this week.

  3. 3

    The user is asked whether it was them

    In Slack, on a channel the attacker can't reach, with the time and place of the sign-in.

  4. 4

    A confirmed takeover is contained

    Every session and token revoked, sign-in methods reset, and the password changed, in every app the account reaches.

  5. 5

    What the attacker left is found and removed

    Mail forwarding rules, new sign-in methods, app grants and tokens created during the window.

  6. 6

    One case records it all

    What was seen, what was cut off, what was removed, and who approved each step.

What account response is made of

Four parts. The second and third are the ones a password reset on its own leaves undone.

A check with the user

One message, on a channel tied to the person rather than the account, settles most alerts in minutes.

Revocation everywhere

Sessions, tokens and sign-in methods across the identity provider and every app it signs into, as one step.

Cleanup of what was left

Forwarding rules, new sign-in methods, app grants and tokens created while the attacker was in.

One case, with approvals

Every action, its time and its approver on one record. Admin accounts never get cut off without a person.

The Tray Headless prompts

Paste these into Claude Code or Codex with the Tray Headless plugin installed. Each stage runs on its own. The systems named in them are the worked example rather than a requirement, and every prompt says so.

Once per project, run /tray-workflows:set-workspace to pick the workspace these build in. Point it at a sandbox first.

  1. 1

    Set up, then attach the account's context

    Whether to act depends on what the account can reach.

    Headless skills build-workflow

    Use build-workflow. The systems in play are Okta or Azure Active
    Directory, Office365 Management, Google Workspace, Datadog or
    Splunk for the alerts, Slack, Jira and Snowflake, or whatever we run in
    those seats. Before you plan anything, tell me which of them are
    already authenticated in the workspace, because I do not want a
    connector stubbed that I have not authenticated.
    
    On every risky sign-in alert, attach: the person, their department and
    manager, whether they are a leaver, which apps the account signs into,
    whether it holds admin power anywhere, and every change to the account
    in the last seven days, including new sign-in methods.
  2. 2

    Ask the user, on a channel the attacker can't use

    Most risky sign-ins are travel or a new phone.

    Headless skills build-workflow

    Use build-workflow. Message the user in Slack with the sign-in time,
    location and device, and two buttons: "This was me" and "Not me".
    
    If they say it was them, close the alert and record the answer. If
    they say it was not, or don't answer within 15 minutes for a high
    risk alert, start containment.
    
    Never ask by email. If the mailbox is the thing that has been taken,
    the attacker is the one who answers.
  3. 3

    Revoke every way in, at once

    A password reset leaves open sessions working.

    Headless skills tray-gotchas

    Use tray-gotchas, then on a confirmed takeover, in this order:
    
      Revoke every session in the identity provider
      Revoke sessions and tokens in each app the account signs into
      Reset sign-in methods, removing any added in the last seven days
      Force a password change at next sign-in
      Tell the user, and their manager, what happened and what to do next
    
    Run the revocations together, not one app at a time over an afternoon.
    For an account with admin power anywhere, stop before the first step
    and ask the on-call analyst to approve in Slack, with the evidence.

    Order matters. Revoking sessions before resetting sign-in methods stops the attacker from signing straight back in with the method they added.

  4. 4

    Find and remove what was left behind

    A forwarding rule outlives every reset.

    For the window between the first suspicious sign-in and containment,
    look for:
    
      Mail forwarding or delete rules created
      New sign-in methods or recovery details
      Apps granted access to the account
      API tokens or app passwords created
      Files shared outside the company
    
    List each finding on the case and remove it after an analyst confirms.
    Some of them, such as a forwarding rule to a personal address, are
    real changes the user made, which is why a person confirms.
  5. 5

    Record it, and measure time to revoke

    The record is what an incident review and an auditor ask for.

    Keep one Jira case per account: the alert, the user's answer, every
    action with its time and approver, and everything removed.
    
    Report: alerts, share settled by the user, confirmed takeovers, time
    from confirmation to every session revoked, and anything found in
    cleanup. Time to revoke is the number to drive down.
  6. 6

    Validate it, then hand the rules to security ops

    Because what counts as high risk is a security decision.

    Run the per-step schema checks and the whole-workflow audit before this
    touches production. Run it for a fortnight asking users and building
    cases, with revocation done by an analyst pressing a button, before any
    of it runs on its own.
    
    Then open the same workflow in Tray Build so security operations can
    change the risk rules, the answer timeout and which accounts need an
    approver, in the visual canvas.

What it connects to

The sign-in happened in one place, and the attacker's access reaches every app the account does.

Okta

Read the account and its recent changes, revoke sessions, and reset sign-in methods.

Reads and writes

Azure Active Directory

Revoke sessions and reset sign-in methods where Microsoft runs identity.

Reads and writes

Office365 Management

Read sign-in and mailbox activity, including forwarding rules created during the window.

Reads

Google Workspace

Revoke Google sessions and app grants, and list Drive files shared outside the company.

Reads and writes

Datadog

Read the risky sign-in detection with its raw detail.

Reads

Slack

Ask the user whether it was them, and ask the analyst to approve containment for admin accounts.

Reads and writes

Jira

Keep one case per account with every action, time and approver.

Writes

Snowflake

Land alerts, answers and actions, so time to revoke is measurable.

Writes

Same build, other stacks

The design does not change if you run something else in one of these seats. The same prompts build it against Google BigQuery, Microsoft Teams, ServiceNow, Databricks, Google Chat or Jira Service Desk.

Connections in this build

Field mapping, templates and common problems for each pairing: Office365 Management + Okta, G-Suite + Okta, Okta + Slack and Azure Active Directory + Slack.

Named systems are the ones most teams run, not the only ones that work. Each is an authentication in your Tray workspace, referenced by name, so the workflow never holds a credential. Where we have a connector page, the name links to it.

Running it in production

This cuts people off. Doing it to the wrong account at the wrong time is a real cost, and so is doing it late.

It runs where production runs, not on a laptop

Alerts are handled the minute they fire, including at 3am on a Sunday, with every step recorded.

Admin accounts always get a person

Cutting off an administrator mid-change can cause an outage of its own. Those accounts wait for an analyst's yes.

Managed credentials, not secrets in a config file

A credential that can revoke every session in the company is powerful. It is a scoped authentication in your workspace, separately rotated.

Security ops own the rules

Risk rules, the answer timeout and the approver list open in Tray Build, owned by the team that answers for a takeover.

Start with a button, not a rule

Two weeks with an analyst pressing revoke, then the clear cases move to the rule once the record shows it would have been right.

Questions people ask

Isn't a password reset enough?

No. Open sessions and tokens keep working after a reset, and a forwarding rule keeps sending mail out. Each has to be revoked or removed explicitly.

Why ask the user in Slack rather than by email?

Because if the mailbox has been taken, the attacker is the one reading the email. A message on a different channel reaches the real person.

What if the user doesn't answer?

For a high risk alert, containment starts after a short timeout, typically 15 minutes. The user can sign back in once they have reset their sign-in, so a false alarm costs them a few minutes.

Should admin accounts be contained automatically?

No. Cutting off an administrator in the middle of a change can cause an outage. Those accounts go to an analyst for approval, with the evidence attached.

What should the attacker cleanup look for?

Forwarding and delete rules, new sign-in methods, app grants, API tokens and files shared outside the company, created between the first suspicious sign-in and containment.

Last reviewed October 2026.