When malware talks to graph.microsoft.com, api.telegram.org or a Slack workspace, your proxy sees a trusted destination and lets it through. Living off trusted sites (LOTS) is the practice of running command and control (C2) over legitimate cloud and SaaS services: OneDrive, Outlook mailboxes, Google Drive and Sheets, Telegram bots, Slack, Discord, GitHub and Pastebin. The attacker authenticates to their own account on the service with a token or bot key embedded in the implant, so the traffic is valid, encrypted and addressed to a domain you cannot block. This guide explains how the technique works, which actors and tools use which services according to MITRE ATT&CK and vendor research, and how to detect and restrict it with identity, tenant and egress controls. It is for SOC analysts, detection engineers and cloud security teams, and goes deeper than the general Command and Control (C2) Guide.
Key takeaways
- The destination is trusted, the account is not. LOTS C2 uses a real service but an attacker-owned tenant, mailbox, drive or bot, so the control point is "whose account" rather than "which domain".
- Every channel runs on a credential. OAuth refresh tokens, client secrets, bot tokens and webhook URLs are embedded in the implant; ESET documented OilRig downloaders carrying a hardcoded OAuth client ID, client secret and refresh token for an attacker OneDrive.
- Tenant restriction beats domain blocking. Controls such as Microsoft Entra Tenant Restrictions v2 stop managed devices signing in to foreign tenants and consumer accounts, which breaks the most common Microsoft 365 variant without blocking Microsoft 365.
- Process and host context is the best detector. A service process, a script host or a server calling the Telegram Bot API or Microsoft Graph is anomalous whatever the reputation of the domain.
- Takedown is a lever. Reporting the abusing account to the provider ends the channel, as happened when OpenAI disabled the API key behind the SesameOp backdoor.
How the attack works
MITRE ATT&CK models the technique as T1102 Web Service, with three sub-techniques that describe what the service is used for. The attacker first registers or compromises an account on the service (T1583.006 and T1584.006 Web Services in Resource Development), then embeds the credential for that account in the implant. From then on the implant behaves like an ordinary API client.
| Pattern | ATT&CK v20 | What the implant does | Typical services |
|---|---|---|---|
| Dead drop resolver | T1102.001 | Reads a public post, profile or document that contains the address of the real C2 server | GitHub, Pastebin, Telegram, Steam, Google Docs, public blockchains |
| Bidirectional channel | T1102.002 | Polls for commands and writes results back through the same service | OneDrive and Outlook via Microsoft Graph, Google Drive and Apps Script, Dropbox, Telegram Bot API |
| One-way channel | T1102.003 | Receives instructions from the service and returns output elsewhere, or not at all | Social media profiles, GitHub, TechNet-style pages |
| Exfiltration to cloud storage | T1567.002 | Uploads stolen data to an attacker storage account | MEGA, Dropbox, Google Drive, S3 buckets |
| Exfiltration over webhook | T1567.004 | Posts data to a webhook endpoint | Discord and Slack webhooks, webhook.site |
Mailbox drafts: ESET's analysis of OilRig showed a variant that never sends email. The SampleCheck5000 downloader used Exchange Web Services and the later OilCheck used the Microsoft Graph Outlook API to read and write draft messages in a shared mailbox, so commands and results never cross a mail gateway.
Drive folders: OilBooster and ODAgent used the Graph API to reach an attacker-controlled OneDrive, with a victim-specific folder for commands and output. ESET reported that OilBooster could fetch a fresh refresh token from a fallback server after repeated failures, which shows how central the token is to the channel's survival.
Bot APIs: ATT&CK records Sandworm Team (G0034) and the Small Sieve backdoor (S1035) using the Telegram Bot API to send and receive commands, and CHIMNEYSWEEP (S1149) using Telegram channels for tasking. A bot token is the whole credential: anyone holding it controls the bot.
Collaboration platforms: ATT&CK records that Brute Ratel C4 (S1063) can use Slack, Discord and Microsoft Teams as external C2 channels, so commercial and cracked red team frameworks put the technique within reach of any affiliate.
Where it shows up
LOTS C2 is not limited to one region or motive. ATT&CK and vendor research show it across state espionage, destructive operations and criminal tooling.
| Actor or tool (ATT&CK ID) | Service abused | Source |
|---|---|---|
| APT28 (G0007) | Google Drive for C2; Graphite malware using OneDrive (Trellix, January 2022) | ATT&CK; Symantec |
| HEXANE (G1001), ODAgent (S1170), OilBooster (S1172) | OneDrive and Outlook via Microsoft Graph | ATT&CK; ESET |
| POLONIUM (G1005) | OneDrive and Dropbox | ATT&CK |
| Sandworm Team (G0034), Small Sieve (S1035) | Telegram Bot API | ATT&CK |
| CloudDuke (S0054) | A OneDrive account to exchange commands and stolen data | ATT&CK |
| Flea / APT15 (Graphican), Harvester (Graphon), unattributed SiestaGraph and BirdyClient | Microsoft Graph and OneDrive or Microsoft 365 Mail | Symantec |
| Brute Ratel C4 (S1063) | Slack, Discord, Microsoft Teams | ATT&CK |
| SesameOp backdoor (Microsoft, 2025) | OpenAI Assistants API as a relay | Microsoft, via the live C2 guide |
Symantec notes that free consumer OneDrive accounts make the infrastructure cheap and that traffic to Microsoft endpoints draws little attention. The same economics apply to free Telegram bots and Discord servers. The newest variant is AI platforms: SesameOp showed that an LLM API key works as C2 infrastructure in the same way, a theme covered in the Command and Control (C2) Guide.
Impact
- Blocklists fail: indicator feeds cannot block graph.microsoft.com or api.telegram.org, and reputation scoring rates them as trusted.
- TLS inspection exemptions: many organisations exempt Microsoft 365 and Google Workspace from inspection for performance, which removes the URI and header detail that would show a foreign tenant.
- Long dwell time: polling a drive folder or a draft mailbox every few minutes produces small, regular requests that look like sync clients.
- Exfiltration capacity: the same storage account receives stolen data at cloud bandwidth, often within normal upload volumes.
- Credential exposure in your tenant: where an attacker compromises one of your own accounts or app registrations (T1584.006 and T1528), the C2 runs inside your tenant and your audit logs become the main evidence source.
Detection
Detection works by asking three questions that do not depend on domain reputation: which process made the call, which account or tenant it authenticated to, and whether that host should use the service at all.
| Signal | Telemetry source | Why it matters |
|---|---|---|
| Non-browser, non-Office process (script hosts, rundll32, unsigned binaries, service processes) connecting to graph.microsoft.com, api.telegram.org, discord.com, slack.com or Google APIs | EDR network events; Sysmon Event ID 3 (network connection) and Event ID 22 (DNS query) with process image | Legitimate clients are a short, known list per service |
| Servers, domain controllers or OT jump hosts calling consumer SaaS or bot APIs | Firewall and proxy logs joined to an asset inventory | Server roles rarely have a business need for Telegram or personal cloud storage |
| Sign-ins from managed devices to a foreign tenant or a consumer Microsoft account | Proxy logs of login.microsoftonline.com and login.live.com; Tenant Restrictions v2 block events | The attacker's tenant is the tell, not the domain |
| Graph API calls from your own tenant by unexpected apps, service principals or IP addresses, especially to drive and mail endpoints | Microsoft Graph activity logs (MicrosoftGraphActivityLogs table: AppId, ServicePrincipalId, IPAddress, RequestUri, UserAgent) | Catches C2 or exfiltration that runs through a compromised identity inside your tenant |
| Regular, low-volume polling with jitter to a storage or messaging API from a single host | Proxy or NDR flow data | Beaconing shape persists even over trusted services; see the Beaconing and C2 Detection Guide |
| Embedded tokens in binaries or scripts (refresh tokens, bot tokens, webhook URLs) | EDR file scanning, YARA on quarantined samples, secret scanning of scripts | Finding the credential tells you which account to report and revoke |
Know the limits of each log: Microsoft documents that Graph activity logs need Entra ID P1 or P2, cover only your own resource tenant (not an attacker's tenant), are usually delivered within 30 minutes but can take up to 2 hours, and cannot be filtered at the diagnostic setting. That makes them strong for insider-tenant abuse and blind to traffic toward an attacker's own tenant, which only network and endpoint telemetry can see.
Metrics
- Process coverage: percentage of endpoints and servers whose outbound connections to sanctioned SaaS carry process attribution in the SIEM.
- Foreign tenant attempts: monthly count of blocked sign-ins to non-allowlisted tenants, triaged to zero unexplained.
- Server SaaS egress: number of server-class assets allowed to reach consumer storage, messaging or bot APIs (target falling to an approved list).
- Inspection exemptions: share of SaaS traffic exempt from TLS inspection with no compensating tenant control.
- Time to takedown: hours from identifying an abusing account to provider suspension and local token revocation.
Prevention and hardening
- Inventory sanctioned services and tenants. List the SaaS your organisation uses, the tenants or workspaces that are yours, and which device and server groups need each one. Everything else is a candidate for blocking.
- Restrict tenants, not domains. Microsoft Entra Tenant Restrictions v2 can be enforced by proxy header injection (the sec-Restrict-Tenant-Access-Policy header on the login.microsoftonline.com, login.microsoft.com, login.windows.net and login.live.com sign-in endpoints), by Global Secure Access, or by Windows Group Policy. Microsoft notes gaps: consumer OneDrive at onedrive.live.com needs a separate proxy block, and non-Entra accounts on partner apps such as Slack are not covered. Use equivalent workspace or tenant controls offered by other SaaS and secure web gateways. Pilot in report mode with one device ring before enforcing.
- Deny server egress by default. Servers and OT jump hosts should reach only named update and service endpoints. Bot APIs, paste sites and personal storage should be unreachable from them. See the Agent Egress Control and Network Isolation Guide for the same pattern applied to AI agents.
- Remove blanket inspection bypasses. Keep Microsoft and Google optimisation for the high-volume media endpoints if you must, but inspect or at least log sign-in and API endpoints so tenant and app identifiers are visible.
- Control what can run. Application control (App Control for Business, AppLocker or equivalent) stops the unsigned implant that would hold the token. Microsoft notes that blocking .NET apps such as PowerShell under the Group Policy enforcement of Tenant Restrictions v2 also needs firewall protection of Microsoft endpoints and App Control tagging.
- Govern your own app registrations and tokens. Review OAuth consents, service principal secrets and bot tokens in your tenants so the attacker cannot borrow your identity for the channel (T1528, T1550.001). See the Consent Phishing and Illicit OAuth Grants Guide and the Discord and Telegram Bot Tokens Security Guide.
- Plan the takedown. Keep abuse-reporting contacts for Microsoft, Google, Telegram, Discord, Slack, GitHub and AI providers in the incident runbook. Rollback for any tenant or egress block is a policy exception scoped to the affected group, logged with an owner and an expiry date.
Where identity fits
LOTS C2 is a non-human identity problem on both sides. The attacker's channel is an OAuth client with a refresh token, a bot token or an API key: a machine credential that the provider can revoke. On your side, compromised service principals, over-scoped app registrations and leaked bot tokens let the attacker run the same channel through your own tenant, where it is even harder to tell apart from automation. Treating every SaaS token as an inventoried, owned and rotated identity closes that route. The OAuth Token Theft Incident Playbook covers response when one of your tokens is the channel.
Lessons from incidents
- Exempting a whole provider: allowlisting all of Microsoft 365 or Google at the proxy is exactly the cover OilRig's downloaders relied on, since their traffic went only to graph.microsoft.com, outlook.office365.com and login.microsoftonline.com.
- Treating takedown as optional: SesameOp ended when the provider disabled the attacker's API key and account. Blocking locally without reporting leaves the channel live for other victims and for a re-infection.
- Logging without process context: a proxy log entry to api.telegram.org from a workstation means little; the same entry tied to an unsigned binary in a temp folder is a high-confidence alert.
- Forgetting your own tenant: when the attacker uses a compromised account inside your tenant, network controls see nothing unusual. Without Graph activity logs and sign-in logs, there is no evidence to scope the intrusion.
Framework mapping
| Control | NIST CSF 2.0 | NIST SP 800-53 Rev. 5 | MITRE D3FEND |
|---|---|---|---|
| Tenant restriction and server egress filtering | PR.IR-01 | SC-7 Boundary Protection; AC-4 Information Flow Enforcement | D3-OTF Outbound Traffic Filtering |
| Application control for implants | PR.PS-05 | CM-7 Least Functionality | D3-EAL Executable Allowlisting |
| Process-attributed network monitoring | DE.CM-01 | SI-4 System Monitoring | D3-NTA Network Traffic Analysis |
| Review of Graph and SaaS audit logs | DE.AE-02 | AU-6 Audit Record Review, Analysis, and Reporting | |
| OAuth app and token governance | PR.AA-05 | AC-6 Least Privilege |
In CIS Controls v8.1 the relevant safeguards sit in Control 9 (Email and Web Browser Protections, including network-based URL filters) and Control 13 (Network Monitoring and Defense). In ISO/IEC 27001:2022 Annex A, see A.8.16 Monitoring activities and A.8.23 Web filtering.
Practitioner checklist
- List sanctioned SaaS services and the exact tenants, workspaces and accounts that belong to you.
- Enforce Tenant Restrictions v2 or an equivalent tenant control for Microsoft 365 and add a proxy block for consumer OneDrive.
- Block bot APIs, paste sites, webhook services and personal storage from servers, domain controllers and OT jump hosts.
- Make sure proxy and EDR telemetry for SaaS endpoints carries the originating process and user.
- Write detections for non-standard processes calling Microsoft Graph, Telegram, Discord, Slack and Google APIs.
- Enable Microsoft Graph activity logs and alert on unexpected apps, service principals and source IP addresses.
- Review TLS inspection bypass lists and keep sign-in and API endpoints visible.
- Inventory your own OAuth apps, service principal secrets and bot tokens, with owners and rotation dates.
- Keep provider abuse contacts in the IR runbook and record time to takedown for every case.
Standards and references
- MITRE ATT&CK: Web Service (T1102)
- MITRE ATT&CK: Exfiltration to Cloud Storage (T1567.002)
- MITRE ATT&CK: Acquire Infrastructure, Web Services (T1583.006)
- Microsoft Learn: Tenant Restrictions v2
- Microsoft Learn: Microsoft Graph activity logs overview
- ESET Research: OilRig's persistent attacks using cloud service powered downloaders
- Symantec: Graph API threats
- NIST: SP 800-53 Rev. 5
Related NHI Mgmt Group resources: Command and Control (C2) Guide · Beaconing and C2 Detection Guide · Discord and Telegram Bot Tokens Security Guide · OAuth Token Theft Incident Playbook · Sliver, Havoc and Brute Ratel C2 Frameworks Detection Guide