- insider-threat
- credential-harvesting
- data-exfiltration
- evidence-destruction
- aws-abuse
- macos
Insider Used Claude Code AI Agent to Harvest Credentials, Exfiltrate HR Data, and Destroy Evidence Before Departure
Account user_1 on macOS device ws-001 used the Claude Code AI coding assistant to direct a sustained series of commands, all under local interactive sessions, that collectively constitute credential harvesting, sensitive HR data collection via obfuscated remote execution, EC2 infrastructure termination, crontab modification of another user, deletion of personal compensation files, and evidence…
Time and cost estimates are based on a Tier-2 SOC analyst model and actual investigation telemetry. Individual results vary by analyst experience, tooling, and environment.
Initial Signal
On September 30, 2026, Microsoft Defender for Endpoint triggered an alert on macOS device ws-001 for account user_1: "Suspicious access of sensitive files." The alert captured a grep command, executed through the Claude Code AI coding assistant, searching ~/.zsh_history for credential patterns. The full command observed was: grep -E 'token|secret|password|api_key|aws_key|Bearer' ~/.zsh_history. This is MITRE T1552.003 (Unsecured Credentials: Bash History).
What made this signal worth investigating was not just the single grep command, but the pattern it revealed when correlated with subsequent process creation records. Over the next three days, the same account, operating through Claude Code sessions, executed commands to scan a file named credentials_[REDACTED].md for AWS keys and GitHub tokens (e.g., grep -E 'AWS_|GITHUB_TOKEN|ghp_' ~/credentials_[REDACTED].md), read a secrets file at ~/.claude/.[user_1_file_1]_secrets.txt, send base64-encoded Python scripts via AWS SSM to extract HR employee data from a Docker container (accessing HR_employees.db, HR_role_info.db, and HR_emp_structure.db), terminate EC2 instances using multiple AWS profiles, modify another user's crontab with administrator privileges, delete personal compensation files (user1_compensation_[REDACTED].xlsx, Paystub.pdf, user1_letter_[REDACTED].pdf), and execute cleanup scripts. All commands appeared in MDE process creation records; none were blocked.
The use of Claude Code as an AI agent to orchestrate these actions is operationally significant: the insider directed the AI assistant to perform multi-stage malicious tasking (credential harvesting, data collection, infrastructure destruction, and evidence cleanup), reducing manual effort and increasing the breadth and speed of the operation.
The investigation spanned 7 minutes 39 seconds of autonomous analysis across 43 invocations querying Microsoft Defender XDR, Defender for Endpoint, and Microsoft Entra, correlating 633 records to establish that all logon events were local-only, all commands executed successfully, and the activity pattern was consistent with a departing insider acting with deliberate knowledge of unauthorized intent.
The Questions We Asked
What follows is the path the agent walked to reach its verdict. Pivots and dead ends both made the cut. Routine steps that just ruled out the obvious are grouped together so you can skim past them.
Did anyone already triage this?
Negative findingCould this be normal work?
PivotWhat are the details of this Microsoft Defender for Endpoint alert?1 recordgrep -E 'token|secret|password|api_key|aws_key|Bearer' ~/.zsh_history. This is credential harvesting behavior (MITRE T1552.003), not normal business operations.user1_compensation_[REDACTED].xlsx, Paystub.pdf), modifying user_2 crontab entries, and terminating EC2 instances; none of these constitute normal business operations.HR_employees.db, HR_role_info.db, HR_emp_structure.db), employee names, job titles, departments, and org hierarchy accessed outside normal HR systems.Does this fall outside the user's role?
PivotWhat processes with this SHA256 were created according to Microsoft Defender for Endpoint?100 recordscredentials_[REDACTED].md for secrets (grep -E 'AWS_|GITHUB_TOKEN|ghp_' ~/credentials_[REDACTED].md), searching for salary/compensation files in [user_1_dir_1], modifying user_2 crontab, and running cleanup scripts; these collectively indicate malicious insider activity.HR_employees.db, HR_emp_structure.db) is not within the expected scope of any normal role, even a senior technical role.[user_1_profile_3], [user_1_profile_1], and [user_1_profile_2], suggesting a senior technical role that might legitimately access AWS infrastructure and some organizational data.Does the data access exceed the role?
PivotWhat Microsoft Defender for Endpoint alerts have been triggered for this Machine ID?2 recordsHR_employees.db, HR_role_info.db, HR_emp_structure.db) via base64-encoded remote execution scripts is not aligned with any core role responsibility; this is HR data that should only be accessed through proper HR systems.credentials_[REDACTED].md (scanning it for secrets via Claude Code) and deleted personal compensation files (user1_compensation_[REDACTED].xlsx, Paystub.pdf); these are not core responsibilities of any role and indicate credential collection and evidence destruction.Three checks, mostly ruling out benign explanations.
credentials_[REDACTED].md and ~/.claude/.[user_1_file_1]_secrets.txt, deleting compensation documents (user1_compensation_[REDACTED].xlsx, Paystub.pdf), modifying another user's crontab with admin privileges, and terminating EC2 instances.Did anything actually stop?
PivotWhat Microsoft Defender for Endpoint alerts have been triggered for this Machine ID?2 recordsDo we have enough to call it?
What are the details of this Microsoft Defender for Endpoint alert?1 recordgrep -E 'token|secret|password|api_key|aws_key|Bearer' ~/.zsh_history), providing sufficient evidence to make a determination.credentials_[REDACTED].md), crontab modification, and personal file deletion (user1_compensation_[REDACTED].xlsx, Paystub.pdf), sufficient evidence to make a determination.HR_employees.db, HR_role_info.db, HR_emp_structure.db) provides additional corroborating evidence of the scope and intent of the activity.Is there malware on the system?
PivotWhat threats were detected by antivirus on this device according to Microsoft Defender for Endpoint?ssm_exec_[REDACTED].sh script was created in Claude Code's scratchpad, copied to the user's home directory, and executed with administrator privileges via osascript; this could be considered malicious code created and executed on the system.Is the account owner responsible?
PivotWhat machine logon events exist for this device according to Microsoft Defender for Endpoint?17 recordsuser1_compensation_[REDACTED].xlsx, Paystub.pdf); this confirms user_1 IS user_1, the legitimate account owner acting with their own credentials.credentials_[REDACTED].md for secrets and to modify another user's crontab with admin privileges; these are actions the user could reasonably be expected to know are unauthorized and malicious.Is there evidence of deliberate malicious intent?
PivotWhat processes with this SHA256 were created according to Microsoft Defender for Endpoint?100 recordscredentials_[REDACTED].md scanned via Claude Code), concealment via cleanup scripts, access outside role (user_2 crontab modification), and evidence destruction (deleting user1_compensation_[REDACTED].xlsx, Paystub.pdf).HR_employees.db, HR_role_info.db, HR_emp_structure.db) sent through AWS SSM demonstrates both systematic collection and deception; the obfuscation is a deliberate attempt to conceal the nature of the data access.Are sensitive resources involved?
What Microsoft Defender for Endpoint alerts have been triggered for this Machine ID?2 recordsHR_employees.db, HR_role_info.db, HR_emp_structure.db) is sensitive HR data containing personal information about all employees including names, job titles, departments, locations, and org hierarchy.~/.claude/.[user_1_file_1]_secrets.txt file and credentials_[REDACTED].md are explicitly credential/secrets files; accessing and scanning these for AWS keys, GitHub tokens, and API keys involves highly sensitive credential data.Key Pivots
Detection Opportunities
The high-fidelity detection signals from this investigation, sanitized for general use. Each MITRE ID links to the official technique reference.
| Technique | Tactic | Context |
|---|---|---|
T1552.003Unsecured Credentials: Bash History | Credential Access | Flag grep, cat, or find commands targeting shell history files (.zsh_history, .bash_history, .history) or credential-related file names (secrets, credentials, tokens, keys). Alert on patterns searching for credential indicators like 'token', 'secret', 'password', 'api_key', 'aws_key', or 'Bearer'. Baseline normal shell history access and alert on deviations, especially when combined with subsequent data exfiltration or cleanup commands. Pay particular attention when these commands are spawned as child processes of AI coding assistants such as Claude Code. |
T1059.006Command and Scripting Interpreter: Python | Execution | Monitor for Python processes spawned with base64-encoded arguments or scripts, especially when invoked via AWS SSM send-command or similar remote execution mechanisms. Alert on Python scripts that access database files, database connections, or HR/personnel data stores. Flag patterns where Python is used to read sensitive data files and pipe output to encoding utilities (base64, gzip) before transmission. Alert when such processes are initiated by AI coding assistant processes (e.g., Claude Code) rather than interactive terminal sessions. |
T1053.006Scheduled Task/Job: Cron | Persistence | Alert on crontab modifications by users with elevated privileges targeting other users' cron jobs. Flag removal or modification of scheduled tasks, especially those related to logging, monitoring, or security tools. Monitor for crontab edits that occur in conjunction with credential harvesting or file deletion activities. Establish baseline crontab entries and alert on unexpected changes. |
T1531Account Access Removal | Impact | Monitor AWS CloudTrail for ec2:TerminateInstances API calls from unusual accounts or profiles, especially those not typically associated with infrastructure management. Alert on bulk terminations or terminations of instances tagged as production or critical. Correlate with other suspicious activities like credential access or data exfiltration in the same time window. |
T1070.004Indicator Removal: File Deletion | Defense Evasion | Flag deletion of files with names matching compensation, payroll, or personal financial patterns (Paystub, salary, bonus, compensation, expense). Alert on bulk file deletions in home directories or shared drives, especially when preceded by credential access or data collection activities. Monitor for use of secure deletion utilities (shred, srm) or rm commands with force flags on sensitive file types. |
Verdict Reasoning
The verdict of Malicious Insider Activity at high confidence rests on the following mutually corroborating signals:
1. Credential harvesting confirmed by grep commands targeting shell history and credentials_[REDACTED].md for tokens, secrets, passwords, and API keys, a known attack technique (T1552.003) not consistent with normal development work
2. HR data exfiltration via base64-encoded remote execution scripts sent through AWS SSM to access HR_employees.db, HR_role_info.db, and HR_emp_structure.db, sensitive personal information accessed outside normal HR systems
3. Infrastructure destruction through EC2 instance termination using multiple AWS profiles, combined with crontab modification of another user and deletion of personal compensation files (user1_compensation_[REDACTED].xlsx, Paystub.pdf, user1_letter_[REDACTED].pdf), a multi-category pattern of evidence destruction and sabotage
4. All 17 logon events are local interactive sessions via loginwindow, confirming the legitimate account owner (not an external attacker) performed these actions
5. All commands were executed through Claude Code, the AI coding assistant, which the insider used to delegate and accelerate multi-stage malicious tasking
6. No security control blocked any activity, and all commands appear in process creation records confirming execution. Confidence is High rather than Confirmed because the inference that user_1 directed these commands (rather than, for example, a sophisticated prompt injection attack that caused the Claude Code AI agent to act autonomously) rests on local-only logons and personal file deletion, not direct attestation; additionally, no platform intelligence confirms or denies an authorized offboarding process that could explain some subset of the activity
Lessons
- 01Legitimate tools in malicious hands require behavioral context. This investigation involved only standard macOS utilities (grep, zsh, Python, AWS CLI) and legitimate cloud services (AWS SSM, EC2), orchestrated through the Claude Code AI coding assistant. No malware was detected. The malicious intent emerged from the pattern of activity (credential harvesting, HR data exfiltration via obfuscation, infrastructure destruction, and evidence cleanup), not from the tools themselves. Detection strategies that rely solely on file reputation or known malware signatures will miss insider threats. Correlate process creation events across multiple categories (credential access, data collection, infrastructure changes, file deletion) to identify the behavioral pattern, not just individual commands.
- 02AI coding assistants can be directed to perform multi-stage malicious tasking. In this case, the insider used Claude Code, Anthropic's AI coding assistant, to orchestrate credential harvesting, HR data exfiltration, infrastructure destruction, and evidence cleanup across a four-day window. Claude Code is a legitimate, widely-used developer tool; its presence in process creation records is not itself suspicious. What is suspicious is the nature of the commands it spawns: grep against shell history for credential patterns, base64-encoded Python payloads sent via AWS SSM, EC2 termination calls, and crontab modifications targeting other users. When investigating insider threat activity on developer endpoints, enumerate child processes of AI coding assistant binaries (claude, cursor, copilot, etc.) with the same scrutiny you would apply to any other process. The AI assistant reduces the manual effort required to execute multi-stage operations and can increase the breadth and tempo of malicious activity.
- 03Base64 encoding is a red flag for data exfiltration, not obfuscation. The insider directed Claude Code to send Python scripts via AWS SSM send-command with base64-encoded payloads to access HR employee data stored in database files (
HR_employees.db,HR_role_info.db,HR_emp_structure.db). Base64 is not encryption (it's easily decoded), but its presence in command-line arguments is a strong signal of deliberate concealment. When you see base64-encoded data in process creation records, especially in conjunction with cloud API calls or remote execution mechanisms, decode it immediately. In this case, the decoded payloads revealed direct access to database files containing employee names, job titles, and organizational hierarchy. - 04Personal file deletion is evidence destruction, not cleanup. The account deleted files named
Paystub.pdf,user1_compensation_[REDACTED].xlsx, anduser1_letter_[REDACTED].pdf, personal compensation documents. This is not routine file management. When you see deletion of personal financial or HR-related files in the same timeframe as credential harvesting and infrastructure sabotage, treat it as evidence destruction. The combination of credential collection, HR data exfiltration, and personal file deletion is a strong indicator of a departing insider acting with knowledge of unauthorized intent. - 05Local-only logons don't rule out malicious intent. All 17 logon events for this account were successful local interactive sessions via loginwindow, no remote access, no credential compromise. This confirmed the legitimate account owner performed the actions, not an external attacker. However, local-only logons do not indicate benign activity. An authorized user with legitimate credentials can still act maliciously. The presence of local-only logons should shift your investigation focus from 'who is this?' to 'why would they do this?' and 'what are they trying to hide?'
- 06Crontab modification of other users is a privilege escalation red flag. The account modified user_2's crontab with administrator privileges to remove entries from
monitor_cleanup_[REDACTED].sh. This is not a normal administrative task; it's targeted tampering with another user's scheduled jobs. When you see one user modifying another user's cron jobs, especially with elevated privileges and in the context of other suspicious activity, treat it as an attempt to disable monitoring, logging, or security controls. Establish baseline crontab entries and alert on unexpected modifications, particularly removals.