C2 is the traffic an attacker uses to keep controlling a device after a breach. Here's how it works and how to spot and stop it (no attack tooling or operation details).
Where it sits in the attack flow
C2 isn't the breach itself — it comes after it.
The important point: the outbound traffic in (2) is the chance to detect and cut. Preventing a breach 100% is hard, but there's room to notice and stop it at the outbound-traffic stage.
C2 vs backdoor vs botnet
These terms get mixed up. Split by role, they look like this.
| Term | What it means | Relation to C2 |
|---|---|---|
| C2 (C&C) | The remote-control channel between an attacker and a compromised device, and the server that sends commands | — |
| Backdoor | An entry point left on a device that bypasses normal authentication | Often talks to C2 to receive commands |
| Botnet | A large group of hijacked devices that take commands from the same C2 at once | C2 controls many devices from one place |
| RCE | A vulnerability that lets someone run arbitrary code remotely | One way to get the breach that comes before C2 |
| Beacon | A short message a device sends to C2 at regular intervals | A sign that C2 is still active |
Why it blends in with normal traffic
MITRE ATT&CK, which catalogs attacker techniques, treats C2 as its own stage (TA0011): the adversary trying to communicate with compromised systems to control them. A typical technique it lists is using everyday protocols such as web and DNS traffic to blend in with existing traffic and avoid detection and filtering.
That's why blocking specific port numbers isn't enough. The mitigations ATT&CK lists are filtering network traffic and network intrusion prevention. In practice, two ideas work:
- Limit by destination: decide which destinations a server may reach with an allowlist, and block other outbound traffic
- Notice by shape: look not at the content but at destination, interval, volume and which program is talking
How to spot it (clues)
| Clue | What to look at |
|---|---|
| Beaconing (periodic traffic) | Regular outbound traffic to the same destination at intervals |
| Unfamiliar destinations | Suspicious domains/IPs (match against known-bad = IOCs) |
| Odd DNS | Queries to unfamiliar domains; abnormally heavy DNS |
| Unexpected paths | Outbound traffic over unexpected ports/protocols |
How to defend
Don't get breached in the first place (the basics)
Restrict outbound traffic (egress)
Monitor DNS and traffic logs
Match and block known-bad destinations
Real example: when outbound traffic was the clue
In the Codecov compromise (2021) covered on this site, a distributed script run in CI was tampered with, and secrets were reportedly sent from customers' CI environments to an outside server for about two months. Because the tampered code wasn't the customers' own, reviewing their code wouldn't have caught it.
The clue that can be checked afterwards is outbound traffic from CI to an unfamiliar destination. If CI's outbound traffic had been limited to the destinations it needed, with everything else logged, there was room to block the sending or notice it sooner. Whether it's C2 or data theft, a post-breach attack has to talk to the outside to achieve its goal.
How to check in your own environment
- List current outbound connections: on Windows,
Get-NetTCPConnection -State Establishedshows each destination and itsOwningProcess(the ID of the program talking), andGet-Process -Id <ID>gives the program's name. On Linux,ss -tunpdoes the same - Review cloud outbound rules: for example, AWS's default security group allows all outbound traffic. Write down what your server really needs to reach (OS updates, payment or email APIs, and so on) and restrict the rest
- Check DNS query history: in your router's or DNS service's logs, look for queries to unfamiliar domains repeating at regular intervals
- Count by destination: aggregate proxy or firewall logs per destination and look for small amounts of traffic at the same interval all day. When you find one, check who owns the destination to tell whether it's a legitimate update check
- Match against published destinations: search your logs for C2 destinations (IOCs) published by authorities or vendors
This site's view: protect outbound traffic too, and confirming 'no C2' is part of the investigation
The biggest lesson the C2 concept brings is that defense isn't only about preventing the breach. Even when perfect prevention is hard, there's room to restrict outbound traffic and notice suspicious callbacks. On this site we keep "a design that doesn't get breached (patching, least privilege, MFA)" as the main goal, while also holding egress control and traffic monitoring as a final layer. Note that when a breach is suspected, confirming there's no resident C2 (a backdoor or rogue periodic traffic) is a key step. To conclude "the impact was limited," you can't skip checking outbound traffic.
Sources (primary)
- MITRE ATT&CK, "Command and Control (TA0011)" — attack.mitre.org (definition of the C2 stage)
- MITRE ATT&CK, "Application Layer Protocol (T1071)" — attack.mitre.org (blending into existing traffic, and mitigations such as traffic filtering)
- AWS, "Default security groups for your VPCs" — docs.aws.amazon.com (default outbound rules)
- Sources for Codecov are listed in the case article
Read next
- Cases: The Codecov compromise (2021) · The Capital One breach (2019)
- Glossary: What is EDR · What is a backdoor (the foothold that talks to C2) · What is RCE · What is an IOC · What is an IOA · What is ransomware · What is malware