Safeguard
Application Security•

DNS Calculation: Ports Derived from DNS Answers (T1568.003)

Malware can compute its C2 port from the IP in a DNS reply. What MITRE documents for T1568.003 and how Sysmon DNS events help you spot it.

Safeguard Security Team
2 min read

Egress filtering assumes you know which ports a destination should use. MITRE T1568.003, DNS Calculation, breaks that assumption. It sits under command and control and applies to Linux, macOS, Windows and ESXi.

How attackers use it

Instead of a fixed port or the literal address returned, the malware performs a calculation on the IP address in a DNS result to decide which IP and port to use for command and control. MITRE gives one example: take the first three octets of the address in a DNS response and use those values to calculate the port. The result can bypass egress filtering that relies on expected port numbers.

How to detect it

Look for connections to derived or unusual ports that were never explicitly resolved, especially from suspicious processes. MITRE suggests correlating Sysmon DNS events (Event ID 22) with process creation and socket activity on Windows. On Linux, inspect resolver and audit logs for outbound connections to ports computed from DNS answers, since odd ephemeral port use shortly after a DNS query can be a clue. On macOS, use unified logs and watch non-browser apps making repeated connections that break their usual pattern. On ESXi, compare syslog with VM traffic baselines.

How to reduce the risk

MITRE lists no specific mitigation. Tight egress rules that allow only known destinations and ports, plus process-aware network logging, shrink the room such a channel has to hide.

Quick check

Which Sysmon event ties a DNS query to a process?

Event ID 22, DNS query. Correlate it with process creation and socket activity to see what connected next.

Sources

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.