Skip to content
Category: Red Team9 min read

Pivoting and Tunneling: A Blue-Team Guide to Detection and Hardening

Por Lucas Andrade ·

A defensive guide to network pivoting and tunneling: how lateral movement works, the logs and Event IDs that reveal it, and the segmentation and hardening that stop it.

In this article

Pivoting and tunneling are the techniques an intruder uses to turn a single foothold into reach across an entire network. Once an attacker controls one machine, they rarely stop there: the real prize usually sits deeper, on hosts that are not directly reachable from the internet. This article looks at pivoting and tunneling from a blue-team perspective — understanding the mechanism in order to detect it, contain it, and design networks that make it hard. We will not walk through operational attack steps; instead we focus on the telemetry the behavior produces, the log sources and Event IDs that reveal it, and the segmentation and hardening controls that blunt it. If you defend an enterprise network, recognizing the signature of lateral movement is one of the highest-leverage detections you can build.

What pivoting and tunneling actually mean

Pivoting is the practice of using a compromised host as a stepping stone to reach other systems that the attacker cannot touch directly. The first machine becomes a relay: traffic that originates from the attacker is forwarded through it into network segments that were supposed to be isolated. Tunneling is the closely related idea of wrapping one protocol inside another so it slips past filtering. A connection that a firewall would normally block can be encapsulated inside a protocol the firewall allows — HTTPS, DNS, SSH, or ICMP — so that from the outside it looks like ordinary, permitted traffic. Together, these techniques let an adversary treat your internal network as if they had a desk inside the office, even though every packet is really flowing through a foothold they should never have had.

For defenders the key insight is that both techniques generate unusual relationships between hosts. A workstation suddenly acting as a router, a server opening long-lived outbound sessions to a place it has never contacted, or a spike of DNS queries with abnormally long names — these are relational anomalies, not signature matches. Detection therefore leans heavily on baselining normal behavior and alerting on deviation, rather than on catching a specific string.

How it works at a high level

At a conceptual level, pivoting relies on some form of traffic forwarding. The compromised host listens on a port and relays whatever arrives to another destination, or it establishes an outbound channel to attacker-controlled infrastructure and then accepts instructions to reach inward. Proxy-based pivoting turns the foothold into a general-purpose gateway so many internal services become reachable through one connection. Tunneling adds a disguise layer: the forwarded traffic is encapsulated so that inspection devices see the outer, allowed protocol rather than the inner, forbidden one. DNS tunneling, for example, smuggles data inside the names and responses of DNS lookups; ICMP tunneling hides it in ping payloads; HTTP(S) tunneling blends command traffic into web requests that look like normal browsing.

The reason this matters defensively is that each disguise leaves a residue. Encapsulation is never free: it changes packet sizes, timing, entropy, request frequency, and the ratio of requests to legitimate application results. A DNS resolver that suddenly answers thousands of queries for a single unusual domain, or an internal host holding an SSH session open for hours to an external address, is producing exactly the kind of statistical fingerprint that a well-instrumented environment can catch.

The attack surface: where pivoting happens

Pivoting thrives on flat networks. When every host can talk to every other host on any port, a single compromise is enough to reach domain controllers, databases, backup servers, and management interfaces. Common enablers include overly permissive east-west firewall rules, shared local administrator credentials that let one machine authenticate to many, exposed remote-management protocols (RDP, SSH, WinRM, SMB), and jump hosts that are trusted by too many segments. Cloud environments add their own pivot paths: over-scoped instance roles, peered VPCs without proper security groups, and metadata services that can hand out credentials. Every one of these is a place where the defender can add friction.

Detection: logs, Event IDs and telemetry

Detecting pivoting is about spotting hosts behaving out of character. On Windows, watch Security Event ID 4624 (logon) with attention to logon types 3 (network) and 10 (remote interactive) originating from workstations that should never initiate such logons, and 4648 (logon with explicit credentials), which frequently accompanies credential relaying. Event ID 4688 (process creation) and Sysmon Event ID 1 reveal tunneling utilities and unexpected use of built-in tools like ssh.exe, netsh port-proxy configurations, or PowerShell forwarding. Sysmon Event ID 3 (network connection) is invaluable: it ties a process to the socket it opened, so you can see a browser-less process holding an outbound session, or a workstation making connections that only a router should make.

On the network side, your richest signal is flow data. NetFlow, IPFIX, or Zeek connection logs let you baseline who-talks-to-whom and alert when a host starts relaying. Look for long-lived sessions, connections that carry far more bytes than a control channel should, and internal hosts that suddenly appear as the source of scans across many ports. For DNS tunneling, monitor for high query volume to a single domain, abnormally long or high-entropy subdomain labels, an unusual ratio of TXT or NULL record requests, and clients that bypass your internal resolvers. For encrypted tunnels, TLS metadata and JA3/JA3S fingerprints help you flag sessions whose client signature does not match any sanctioned software. EDR platforms tie these together by correlating the process, the parent lineage, and the network connection into a single behavioral story.

A practical detection strategy combines three layers: identity anomalies (accounts and machines authenticating in patterns they never used before), process anomalies (living-off-the-land binaries invoked with forwarding arguments), and network anomalies (new pairings, long durations, protocol/port mismatches such as non-DNS traffic on port 53). Any one alone produces noise; correlated, they produce high-confidence alerts.

Mitigation and hardening

The single most effective control against pivoting is network segmentation. Divide the environment into zones with default-deny rules between them, and permit only the specific east-west flows that business functions require. Microsegmentation — enforcing policy per workload rather than per subnet — shrinks the blast radius so that owning one host no longer means owning the segment. Complement this with strict egress filtering: internal hosts should reach the internet only through controlled proxies, and protocols like DNS should be forced through inspected internal resolvers so that direct outbound DNS from arbitrary hosts is blocked and alertable.

Identity hardening removes the fuel that pivoting runs on. Eliminate shared local administrator passwords with a solution such as Windows LAPS, enforce the tiered administration model so that high-privilege credentials never touch low-trust machines, and require phishing-resistant multi-factor authentication on all remote-access and management paths. Restrict lateral protocols: disable SMBv1, limit RDP and WinRM to designated jump hosts, and use host-based firewalls to deny workstation-to-workstation traffic that has no business reason. Keep systems patched so that a foothold cannot be widened through unpatched services, and apply the principle of least privilege to cloud roles and service accounts so a stolen token opens few doors.

Common pitfalls for defenders

Teams often assume that a perimeter firewall and endpoint antivirus are enough; both are largely blind to authorized-looking internal traffic. Another frequent mistake is logging without retention or correlation — the Event IDs above are worthless if they roll over in a day or live in silos that no analytic ever joins. Allowing unrestricted outbound DNS and HTTPS "because everything needs the internet" hands attackers ready-made tunnels. Trusting jump hosts implicitly, failing to monitor east-west traffic at all, and treating cloud metadata endpoints as harmless are recurring gaps. Finally, many organizations never test their own detections; a purple-team exercise that safely exercises pivoting behavior in a controlled lab is the fastest way to learn whether your telemetry actually fires.

A practical defensive checklist

1. Segment the network with default-deny east-west rules and adopt microsegmentation for critical workloads. 2. Force all outbound traffic through inspected proxies and internal DNS resolvers; block and alert on direct outbound DNS/ICMP. 3. Deploy Sysmon (Event IDs 1 and 3) and centralize flow logs (NetFlow/IPFIX/Zeek) with meaningful retention. 4. Build correlated detections for logon anomalies (4624/4648), port-proxy and tunneling tools, and new host-to-host pairings. 5. Baseline DNS per client and alert on high volume, long labels, high entropy, and unusual record types. 6. Eliminate shared local admin credentials, adopt tiered admin, and enforce phishing-resistant MFA. 7. Restrict RDP/SSH/WinRM/SMB to hardened jump hosts and deny workstation-to-workstation lateral traffic. 8. Least-privilege every cloud role and protect metadata services. 9. Patch aggressively. 10. Validate detections with regular, authorized purple-team exercises.

FAQ

Is all tunneling malicious? No. VPNs, SSH administration, and many legitimate applications use tunneling every day. That is exactly why detection must be based on context — which host, which process, which destination, and whether the behavior matches an established baseline — rather than on the mere presence of an encapsulated protocol. The goal is to distinguish sanctioned tunnels from unsanctioned ones, not to ban the concept.

Can encryption stop attackers from tunneling? Encryption protects confidentiality but does not prevent tunneling; adversaries actually prefer encrypted channels because payload inspection is impossible. Defenders respond with metadata analysis (session duration, byte volume, timing, TLS fingerprints), strict egress control through proxies that terminate or broker connections, and behavioral correlation on the endpoint, where the traffic exists in plaintext before it is wrapped.

Conclusion

Pivoting and tunneling are how a single compromised host becomes a network-wide incident, and they succeed most easily where networks are flat, egress is unrestricted, and internal traffic goes unmonitored. The defensive answer is layered and unglamorous: segment aggressively so one foothold cannot reach everything, control and inspect egress so disguised channels have nowhere to hide, instrument endpoints and flows so unusual relationships surface quickly, and harden identity so stolen credentials open few doors. Build correlated detections across identity, process, and network signals, retain the logs long enough to investigate, and rehearse against your own defenses with authorized exercises. Do that, and lateral movement stops being an invisible glide across your estate and becomes a loud, catchable event.

Related posts

No comments yet

Be the first to comment.

Leave a comment

Sign in with your Canverly account to comment. You can use the same account on any site in the network.

Sign in with Canverly