Data Exfiltration via PGP/GPG-Encrypted Email Attachments
Rather than pushing data to attacker-controlled infrastructure over SFTP/FTPS/HTTP (the channel used by purpose-built tools like StealBit and Exmatter), this sub-technique variant abuses a fully sanctioned, already-allowed corporate channel — outbound email through the organization's own mail server or SaaS mail platform (Exchange Online, Gmail) — by first encrypting the data with an asymmetric keypair (OpenPGP/GPG, or S/MIME) before attaching it. Because the ciphertext is opaque without the recipient's private key, content-based DLP, CASB, and email security gateways that rely on pattern/keyword/fingerprint matching over attachment contents cannot inspect what is being sent; they can only observe metadata (attachment extension, size, sender, recipient domain). This makes it an attractive technique for insiders exfiltrating IP to a personal or competitor mailbox, and has also been observed as a secondary channel by data-theft actors who encrypt staged archives with a public key before transfer specifically to prevent the victim organization, EDR/DLP vendor, or law enforcement from ever recovering the plaintext of what was stolen. Detection therefore has to pivot on the artifacts still visible around the encryption event: unusual attachment extensions (.gpg, .pgp, .asc, .p7m) or ASCII-armored PGP blocks, GPG/GPG4Win/Kleopatra process execution with encryption flags on a host with no prior legitimate PGP usage, importing an external party's public key immediately before using it, and bursts of such encrypted-attachment emails to external domains that exceed a single user's normal PGP-for-legitimate-purposes baseline (e.g., signing software releases, encrypting vendor communications).
What is THREAT-PGPEmail-AsymmetricEncryptedExfil Data Exfiltration via PGP/GPG-Encrypted Email Attachments?
Data Exfiltration via PGP/GPG-Encrypted Email Attachments (THREAT-PGPEmail-AsymmetricEncryptedExfil) maps to the Exfiltration tactic — the adversary is trying to steal data in MITRE ATT&CK.
This page provides production-ready detection logic for Data Exfiltration via PGP/GPG-Encrypted Email Attachments, covering the data sources and telemetry it touches: Microsoft Defender for Office 365 (EmailEvents, EmailAttachmentInfo), Microsoft Defender for Endpoint (DeviceProcessEvents). The queries below are rated high severity at medium confidence, and ship for 7 SIEM platforms — KQL, SPL, Elastic, QRadar, Sumo, YARA-L, LogScale.
MITRE ATT&CK
- Tactic
- Exfiltration
let InternalMailDomains = dynamic(["contoso.com"]); // replace with your organization's verified tenant domain(s)
let PgpExtensions = dynamic([".gpg", ".pgp", ".asc", ".p7m"]);
let GpgProcessNames = dynamic(["gpg.exe", "gpg2.exe", "gpg4win.exe", "kleopatra.exe"]);
let GpgEncryptFlags = dynamic(["--encrypt", "--recipient", "-r ", "-e "]);
let OutboundPgpAttachments = EmailEvents
| where Timestamp > ago(24h)
| where EmailDirection == "Outbound"
| join kind=inner (
EmailAttachmentInfo
| where Timestamp > ago(24h)
| where FileName has_any (PgpExtensions)
) on NetworkMessageId
| extend RecipientDomain = tostring(split(RecipientEmailAddress, "@")[1])
| where RecipientDomain !in~ (InternalMailDomains);
// Signal 1: a single outbound email with an asymmetric-encrypted attachment sent to an external recipient
let PgpEmailExfil = OutboundPgpAttachments
| extend Actor = SenderFromAddress, Target = RecipientEmailAddress, Detail = FileName, Signal = "PgpEncryptedAttachmentOutbound", RiskScore = 80
| project Timestamp, Actor, Target, Detail, Signal, RiskScore;
// Signal 2: a burst of 3+ such emails from one sender within an hour — bulk staged exfiltration rather than a single ad hoc message
let BulkPgpAttachmentBurst = OutboundPgpAttachments
| summarize AttachmentCount = count(), UniqueRecipients = dcount(RecipientEmailAddress) by SenderFromAddress, bin(Timestamp, 1h)
| where AttachmentCount >= 3
| extend Actor = SenderFromAddress, Target = "(multiple)", Detail = strcat("AttachmentCount=", tostring(AttachmentCount), " UniqueRecipients=", tostring(UniqueRecipients)), Signal = "BulkPgpAttachmentBurst", RiskScore = 90
| project Timestamp, Actor, Target, Detail, Signal, RiskScore;
// Signal 3: GPG/GPG4Win/Kleopatra encryption invoked on an endpoint — the collection/encryption step that precedes the email send
let GpgEncryptRaw = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ (GpgProcessNames)
| where ProcessCommandLine has_any (GpgEncryptFlags);
let GpgEncryptInvoked = GpgEncryptRaw
| extend Actor = DeviceName, Target = AccountName, Detail = ProcessCommandLine, Signal = "GpgEncryptInvoked", RiskScore = 55
| project Timestamp, Actor, Target, Detail, Signal, RiskScore;
// Signal 4: an external party's public key is imported into the local keyring within 15 minutes before it is used to encrypt data — just-in-time exfiltration prep, especially for a user with no prior PGP usage history
let KeyImportRaw = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ (GpgProcessNames)
| where ProcessCommandLine has "--import"
| project ImportTime = Timestamp, DeviceName, AccountName;
let GpgKeyImportThenEncrypt = GpgEncryptRaw
| join kind=inner (KeyImportRaw) on DeviceName, AccountName
| where Timestamp - ImportTime between (0min .. 15min)
| extend Actor = DeviceName, Target = AccountName, Detail = ProcessCommandLine, Signal = "GpgKeyImportThenEncrypt", RiskScore = 70
| project Timestamp, Actor, Target, Detail, Signal, RiskScore;
union PgpEmailExfil, BulkPgpAttachmentBurst, GpgEncryptInvoked, GpgKeyImportThenEncrypt
| sort by RiskScore desc, Timestamp desc Four-signal detection combining Microsoft Defender for Office 365 mail telemetry with Microsoft Defender for Endpoint process telemetry: (1) a single outbound email to an external domain carrying an attachment with a PGP/GPG or S/MIME extension (.gpg, .pgp, .asc, .p7m); (2) three or more such emails from the same sender within an hour, indicating bulk staged exfiltration; (3) GPG, GPG4Win, or Kleopatra invoked with encryption flags on an endpoint; (4) an external public key imported into the local GPG keyring within 15 minutes of that same key being used to encrypt data, a strong just-in-time exfiltration-prep indicator.
Data Sources
Required Tables
False Positives
- Legitimate business use of PGP/GPG for signing or encrypting vendor communications, software release artifacts, or financial documents — build an allowlist of known business recipients/domains and users with a documented, recurring PGP usage pattern
- Security or DevOps teams distributing GPG-encrypted credentials, API keys, or backup exports to external partners as an approved secrets-sharing workflow
- Legal or compliance teams encrypting sensitive documents (M&A due diligence, privileged communications) for external counsel using S/MIME or PGP, which is expected and should be excluded once verified
- Automated systems (CI/CD release signing, EDI/B2B integrations) that routinely invoke gpg.exe with --encrypt/--recipient as part of a scheduled, service-account-driven job
Sigma rule & cross-platform mapping
The detection logic for Data Exfiltration via PGP/GPG-Encrypted Email Attachments (THREAT-PGPEmail-AsymmetricEncryptedExfil) above is provided in a vendor-neutral
form so you can deploy it on any SIEM. The same logic is shipped here as native
KQL (Microsoft Sentinel / Defender), SPL (Splunk), Elastic (Elastic Security (EQL)), QRadar (IBM QRadar (AQL)), Sumo (Sumo Logic CSE), YARA-L (Google Chronicle / SecOps), LogScale (CrowdStrike LogScale (CQL)) queries. In Sigma terms, this detection targets the
following logsource:
logsource:
category: process_creation
product: windows Browse the community-maintained Sigma rules for this technique:
Platform-specific guides for THREAT-PGPEmail-AsymmetricEncryptedExfil
Testing Methodology
Validate this detection against 4 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1Simulate GPG Encryption of a Staged Archive with an External Recipient Key
Expected signal: Sysmon Event ID 1 for gpg.exe invoked with --quick-generate-key, --import, and --encrypt --recipient; Sysmon Event ID 11 for creation of test_pubkey.asc and staged_data.txt.gpg.
- Test 2Simulate Outbound Email of a PGP-Encrypted Attachment to an External Test Recipient
Expected signal: EmailEvents record with EmailDirection=Outbound to the external test recipient; EmailAttachmentInfo record with FileName ending in .gpg.
- Test 3Simulate a Bulk Burst of PGP-Encrypted Attachment Emails
Expected signal: Four EmailAttachmentInfo/DLP records within the same one-hour bin, each with a .gpg attachment from the same sender to external recipients.
- Test 4Simulate GPG4Win/Kleopatra Encryption on macOS via GPG Suite
Expected signal: Endpoint process telemetry (EDR/Sysmon-for-Mac equivalent) for gpg invoked with --encrypt --recipient flags, and file-creation telemetry for staged_data.txt.gpg.
Response Playbook
Triage
- Identify the sender, recipient domain, and attachment extension. Confirm whether the recipient domain is a known business partner, personal webmail (Gmail, ProtonMail, Outlook.com), or an unfamiliar domain — personal webmail recipients are the highest-signal indicator of insider IP theft.
- Check whether the sending account has any prior legitimate history of PGP/GPG usage (signing releases, encrypting vendor files). A first-time GPG invocation on a host, especially one belonging to a user in a role with access to sensitive IP (engineering, finance, M&A), is a strong anomaly.
- Pull DeviceProcessEvents/Sysmon Event ID 1 for the sending host in the hour preceding the email to look for the GpgEncryptInvoked or GpgKeyImportThenEncrypt signal — this confirms local encryption occurred on this device rather than the attachment arriving pre-encrypted from elsewhere.
- If a key import is present, extract the imported public key's user ID/email and compare it against the outbound email's recipient — a match strongly confirms the recipient's own key was used to encrypt data specifically for them.
- Check DeviceFileEvents/Sysmon Event ID 11 in the same window for creation of large archives (.zip, .7z, .tar) immediately before the .gpg/.pgp/.asc/.p7m file appears — this identifies what was staged and encrypted, and its approximate size/scope.
- Because content-based DLP cannot see inside the ciphertext, do not assume no sensitive data classification match means no sensitive data was sent — treat the metadata signal (extension, sender, external recipient) as authoritative on its own.
Containment
- If the sender is an active or recently departed employee, suspend outbound mail sending capability and disable the account pending investigation, particularly for burst/bulk signals.
- Quarantine the message in the mail flow if it has not yet left the tenant (Exchange Online transport rule / mail flow rule can hold matching attachments for review); if already delivered, this becomes a legal/HR matter rather than a technical containment action.
- Preserve the endpoint (do not wipe/reimage) — the local GPG keyring, encrypted source files, and process history are the primary evidence for what was sent and to whom.
- If a key import for an unfamiliar external identity is confirmed alongside encryption of business-critical files, treat this as a probable insider-threat case and engage HR/Legal before taking any account-level action that the employee would notice.
Evidence Collection
- The exact attachment filename, extension, size, and SHA256 hash from EmailAttachmentInfo/DLP logs, and the sender/recipient/timestamp of the message.
- The local GPG keyring contents (public keys imported, their associated email/user ID and import timestamp) via `gpg --list-keys` if the endpoint is still accessible, or the equivalent Sysmon/EDR process command-line history.
- Any pre-encryption archive or file staging activity (DeviceFileEvents/Sysmon Event ID 11) in the window before the .gpg/.pgp/.asc/.p7m file was created, to determine the scope of what was collected.
- Full process command-line and parent process chain for the gpg.exe/gpg4win/kleopatra invocation, to distinguish manual user action from a scripted/automated encryption step.
- Mail flow/transport logs confirming successful delivery (not just a send attempt) to the external recipient.
Escalation Criteria
- ! The recipient domain is a personal webmail provider or a domain with no documented business relationship with the organization.
- ! The sender has access to material non-public information, source code, customer PII, or trade secrets, and no prior legitimate PGP usage baseline exists for that user.
- ! A key import for an external identity is directly followed by encryption and email of a large or sensitive archive — treat as high-confidence intentional exfiltration and involve HR/Legal immediately.
- ! The burst signal (3+ encrypted-attachment emails within an hour) fires for a user who has resigned, been placed on a PIP, or is otherwise a known flight/insider-risk indicator per HR.
Investigation Guide
Forensic Artifacts
- >
EmailAttachmentInfo/DLP AttachmentData records showing the encrypted attachment's filename, extension, and hash - >
Local GPG keyring database (pubring.kbx/pubring.gpg) and its modification timestamp, showing when an external key was imported - >
Sysmon Event ID 1/DeviceProcessEvents for the gpg.exe, gpg2.exe, gpg4win.exe, or kleopatra.exe process launch and full command line - >
Sysmon Event ID 11/DeviceFileEvents for the creation of the source archive and the resulting .gpg/.pgp/.asc/.p7m output file - >
Mail transport/message-trace logs confirming final delivery status and timestamp for the outbound message
Tuning Guidance
Signal 1 (single encrypted attachment to an external domain) is the noisiest signal and will fire on legitimate vendor/legal/financial PGP correspondence — the false-positive rate drops sharply once a per-user, per-recipient-domain allowlist is built from the 30-day baseline hunting query above. Signal 2 (bulk burst) and Signal 4 (key import immediately before encryption) are substantially higher-fidelity and should be prioritized for alerting; Signal 4 in particular has very few legitimate causes outside of a scheduled automation job, since a human importing a stranger's key and immediately using it to encrypt data is not typical day-to-day PGP usage. Tune the burst threshold (default 3/hour) down for users in high-sensitivity roles (R&D, M&A, finance) and up for teams with a documented, high-volume legitimate PGP workflow (e.g., a security team that routinely emails encrypted credential exports).
Hunting Queries
Baseline hunt across the last 30 days for every user account that has invoked GPG/GPG4Win/Kleopatra with encryption flags, independent of any email signal — used to build the per-user PGP usage baseline referenced throughout triage, and to surface first-time users of the tool who warrant closer review.
DeviceProcessEvents
| where Timestamp > ago(30d)
| where FileName in~ ("gpg.exe", "gpg2.exe", "gpg4win.exe", "kleopatra.exe")
| where ProcessCommandLine has_any ("--encrypt", "--recipient", "-r ", "-e ")
| summarize FirstSeen = min(Timestamp), Invocations = count(), Hosts = make_set(DeviceName) by AccountName
| sort by FirstSeen asc index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1
(Image="*\\gpg.exe" OR Image="*\\gpg2.exe" OR Image="*\\gpg4win*.exe" OR Image="*\\kleopatra.exe")
(CommandLine="*--encrypt*" OR CommandLine="*--recipient*" OR CommandLine="*-r *" OR CommandLine="*-e *")
| stats earliest(_time) AS FirstSeen, count AS Invocations, values(host) AS Hosts BY User
| sort FirstSeen Atomic Red Team Tests
Generates a test GPG keypair representing an external recipient, imports its public key, and uses it to encrypt a dummy archive, simulating the on-host encryption step (Signal 3/4) that precedes emailing stolen data. Use only synthetic, non-sensitive test data.
Command
"dummy sensitive content" | Out-File C:\Temp\staged_data.txt; gpg --batch --yes --passphrase '' --quick-generate-key [email protected] default default; gpg --export --armor [email protected] > C:\Temp\test_pubkey.asc; gpg --import C:\Temp\test_pubkey.asc; gpg --batch --yes --trust-model always --encrypt --recipient [email protected] --output C:\Temp\staged_data.txt.gpg C:\Temp\staged_data.txt Cleanup
Remove-Item C:\Temp\staged_data.txt, C:\Temp\staged_data.txt.gpg, C:\Temp\test_pubkey.asc -Force -ErrorAction SilentlyContinue; gpg --batch --yes --delete-keys [email protected] 2>$null Expected Telemetry
Sysmon Event ID 1 for gpg.exe invoked with --quick-generate-key, --import, and --encrypt --recipient; Sysmon Event ID 11 for creation of test_pubkey.asc and staged_data.txt.gpg.
Expected Detection
GpgEncryptInvoked (RiskScore=55) fires on the --encrypt invocation, and GpgKeyImportThenEncrypt (RiskScore=70) fires because the --import and --encrypt commands occur on the same host/account within the 15-minute correlation window.
Sends a test email with a .gpg attachment to an external test mailbox using an approved test tenant, simulating the mail-flow side of the detection (Signal 1). Use only a controlled test mailbox you own — never a real third-party address.
Command
Send-MailMessage -From 'test-user@<YOUR_TEST_TENANT>' -To '<TEST_EXTERNAL_RECIPIENT>' -Subject 'Detection Test - PGP Attachment' -Body 'Automated detection engineering test' -Attachments 'C:\Temp\staged_data.txt.gpg' -SmtpServer '<TEST_SMTP_RELAY>' Cleanup
Remove-Item C:\Temp\staged_data.txt.gpg -Force -ErrorAction SilentlyContinue Expected Telemetry
EmailEvents record with EmailDirection=Outbound to the external test recipient; EmailAttachmentInfo record with FileName ending in .gpg.
Expected Detection
PgpEncryptedAttachmentOutbound (RiskScore=80) fires on the outbound email carrying the .gpg attachment to the external recipient domain.
Repeats the encrypted-attachment email send four times within a short window to the same or different external test recipients, simulating bulk staged exfiltration (Signal 2).
Command
for i in 1 2 3 4; do gpg --batch --yes --trust-model always --encrypt --recipient [email protected] --output /tmp/staged_$i.txt.gpg /tmp/staged_data.txt; echo 'Automated detection engineering test' | mail -s "Detection Test $i" -A /tmp/staged_$i.txt.gpg <TEST_EXTERNAL_RECIPIENT>; done Cleanup
rm -f /tmp/staged_*.txt.gpg Expected Telemetry
Four EmailAttachmentInfo/DLP records within the same one-hour bin, each with a .gpg attachment from the same sender to external recipients.
Expected Detection
BulkPgpAttachmentBurst (RiskScore=90) fires once AttachmentCount reaches the 3-per-hour threshold for the sending account.
Uses the command-line GPG Suite tooling on macOS to encrypt a dummy file with a test recipient key, validating that the endpoint signal (Signal 3) generalizes across platforms rather than being Windows-specific.
Command
echo 'dummy sensitive content' > /tmp/staged_data.txt; gpg --batch --yes --passphrase '' --quick-generate-key [email protected] default default; gpg --batch --yes --trust-model always --encrypt --recipient [email protected] --output /tmp/staged_data.txt.gpg /tmp/staged_data.txt Cleanup
rm -f /tmp/staged_data.txt /tmp/staged_data.txt.gpg; gpg --batch --yes --delete-keys [email protected] 2>/dev/null Expected Telemetry
Endpoint process telemetry (EDR/Sysmon-for-Mac equivalent) for gpg invoked with --encrypt --recipient flags, and file-creation telemetry for staged_data.txt.gpg.
Expected Detection
GpgEncryptInvoked (RiskScore=55) fires on the --encrypt invocation regardless of host operating system.
Related Detections
Tactic Hub
Detection Variants (3)
Different telemetry and tradecraft for the same technique — pick the one that matches the data you collect.
- THREAT-Exfiltration-GPGAsymmetricArchiveExfilAsymmetric Public-Key Encrypted Archive Exfiltration (GPG/OpenSSL/age)
- THREAT-Exfiltration-TLSAsymmetricNonC2TunnelBulk Exfiltration Over Ad-Hoc TLS Tunnel (openssl s_client / stunnel / socat / ncat --ssl)
- THREAT-Ransomware-AffiliateExfilToolingRansomware-Affiliate Custom Exfiltration Tooling (StealBit & Exmatter)