Skip to content
Adam Omar Saleh

Chronos Security logo, as used by CSCTF 2026CSCTF 2026Forensics

Code Red Freight

Patti Fernandez fell for a device-code phishing lure. The attacker used the stolen device-code token to Entra-join their own machine (D3VC0DE-R3L4Y), obtained a Primary Refresh Token on it, created a forwarding inbox…

Competition
Chronos Security logo, as used by CSCTF 2026CSCTF 2026
Category
ForensicsMedium
Source status
Source-documented · not platform-verified
Document
PDF edition4 min read

Brief

The challenge

Category
FORENSICS
Difficulty
Medium
Points
270
Author
Marius Merai
File
code_red_freight.zip

Tarnovel Rail Freight's defence-consignment manifests are reaching an outside mailbox. The dispatcher noticed nothing. You have her identity, mailbox-audit exports, and the email she clicked. Identify the device the adversary controls, the rule leaking manifests, and the number of files they downloaded.

Flag format: CSCTF{<device_name>_<rule_name>_<download_count>}

Challenge page
Challenge page

TL;DR

Patti Fernandez fell for a device-code phishing lure. The attacker used the stolen device-code token to Entra-join their own machine (D3VC0DE-R3L4Y), obtained a Primary Refresh Token on it, created a forwarding inbox rule (M4N1F3ST-L3AK → ragubarden@proton.me), and downloaded 4 files. Everything the attacker did comes from 203.0.113.77 (Montreal), while Patti always works from 198.51.100.24 (Romania).

01

Evidence

Text
logs/AuditLogs_2026-10-29-Patti_Fernandez.csv        Entra audit loglogs/InteractiveSignIns_2026-10-28_2026-10-29.csv    Entra sign-inslogs/NonInteractiveSignIns_2026-10-28_2026-10-29.csv Entra sign-inslogs/UnifiedAuditLog_Patti.csv                       Purview unified audit loglure/email_phish.png, lure/devicecode_phish.png

02

The lure

A fake OneDrive share from "Jordan Smith" <ragubarden@proton.me>, sent 29/10 at 14:58, links to 5harepoint.cz:

Phishing email
Phishing email

The landing page asks the victim to enter code CXR7QK2WD at microsoft.com/devicelogin. That is classic device-code phishing: the victim authenticates, and the attacker's waiting client receives the tokens.

Device-code page
Device-code page

03

The attacker's device

The interactive sign-ins show the moment the code was redeemed. At 15:04:52 and 15:04:55 UTC there are sign-ins with Original transfer method = deviceCodeFlow to Microsoft Authentication Broker → Device Registration Service, from 203.0.113.77 (Montreal, CA). Patti's normal IP is 198.51.100.24 (Romania).

Ten seconds later the Entra audit log shows a device join:

Time (UTC)ActivityDeviceIP
15:05:02Add registered owner / users to deviceD3VC0DE-R3L4Y—
15:05:03Register device (Azure AD join)D3VC0DE-R3L4Y, Device Id 95caec44-c8af-4786-976c-73bd33d9d143203.0.113.77

After that, sign-ins from 203.0.113.77 carry Device ID 95caec44…, Join Type "Azure AD joined", and Incoming token type primaryRefreshToken. The attacker turned a one-time device code into a persistent PRT on a device they control.

The other registered device, R3M0TE-W0RK-PC, was joined on 28/10 from Patti's own IP with no device-code flow. It's her legitimate machine and a decoy.

04

The leaking rule

The UAL has two New-InboxRule events:

Time (UTC)RuleIPAction
2026-10-28 07:34Newsletters198.51.100.24move newsletters to a folder (benign)
2026-10-29 15:28M4N1F3ST-L3AK203.0.113.77ForwardTo: ragubarden@proton.me, StopProcessingRules: True

The malicious rule also records DeviceId: 95caec44-c8af-4786-976c-73bd33d9d143, which ties it straight to D3VC0DE-R3L4Y, and it forwards to the same address that sent the phishing email.

05

Downloads

Filtering the UAL for FileDownloaded, all four events come from 203.0.113.77 in the hijacked session. There are no duplicate record IDs, and no other operation mentions downloads.

Time (UTC)FileSite
15:20:24Notes.docxPatti's OneDrive
15:20:30Investor Relations Meeting Presentation.pptxPatti's OneDrive
15:20:49aerialshot.jpgMark8ProjectTeam
15:21:36Local Resource Guide.docxbenefits

Download count: 4.

Solve script

solve.py:

Python
import csvimport json​LOGS = "extracted/code_red_freight/logs/"ATTACKER_IP = "203.0.113.77"​for row in csv.DictReader(open(LOGS + "AuditLogs_2026-10-29-Patti_Fernandez.csv", encoding="utf-8-sig")):    if row["Activity"] == "Register device":        print("device :", row["Target1DisplayName"], row["IPAddress"], row["AdditionalDetail5Value"])​ual = [json.loads(r["AuditData"]) for r in csv.DictReader(open(LOGS + "UnifiedAuditLog_Patti.csv", encoding="utf-8-sig"))]​for a in ual:    if a["Operation"] == "New-InboxRule":        params = {p["Name"]: p["Value"] for p in a["Parameters"]}        print("rule   :", params["Name"], a["ClientIP"], params)​downloads = [a for a in ual if a["Operation"] == "FileDownloaded" and a["ClientIP"].startswith(ATTACKER_IP)]for a in downloads:    print("dl     :", a["CreationTime"], a["SourceFileName"])print("count  :", len(downloads))

Output:

Text
device : D3VC0DE-R3L4Y 203.0.113.77 95caec44-c8af-4786-976c-73bd33d9d143device : R3M0TE-W0RK-PC 198.51.100.24 3f8c1a7b-9d24-4e65-b0a1-7c2e5f9d8a43rule   : M4N1F3ST-L3AK 203.0.113.77:17091 {... 'ForwardTo': 'ragubarden@proton.me', ...}rule   : Newsletters 198.51.100.24:51224 {... 'MoveToFolder': 'Newsletters', ...}dl     : 2026-10-29T15:20:30 Investor Relations Meeting Presentation.pptxdl     : 2026-10-29T15:20:49 aerialshot.jpgdl     : 2026-10-29T15:21:36 Local Resource Guide.docxdl     : 2026-10-29T15:20:24 Notes.docxcount  : 4

Flag

Flag

CSCTF{D3VC0DE-R3L4Y_M4N1F3ST-L3AK_4}

Source-documented · not platform-verified

Takeaways

  • Device-code phishing shows up in sign-in logs as Original transfer method = deviceCodeFlow. A Device Registration Service sign-in right after it means the attacker is joining a device to mint a PRT.

  • Pivot on the attacker IP and Device ID: the same DeviceId appears in the Entra device join, the non-interactive sign-ins, and the Exchange New-InboxRule record.

  • Each artifact comes with a benign twin (R3M0TE-W0RK-PC, the Newsletters rule). Separate them by IP, time, and auth flow.

PDF edition

Writeup PDF

Formatted edition of this walkthrough, built from my source notes · 6 pages.