TCP Flags Explained: SYN, ACK, FIN, RST and Spotting Abnormal Flags
TCP flags are single-bit control fields in the TCP header that tell the other side what a segment is for. RFC 9293 defines eight: SYN starts a connection, ACK confirms received data, FIN closes a connection gracefully, RST aborts it, PSH asks for immediate delivery, URG marks urgent data, and ECE and CWR handle congestion signals.
Topic: Networking in IT Infrastructure · Explainer
Also covers: Network Security, Penetration Testing, Security Tools, Authorized Labs & CTFs
Quick answer: TCP flags are single-bit control fields in the TCP header that tell the other side what a segment is for. RFC 9293 defines eight: SYN starts a connection, ACK confirms received data, FIN closes a connection gracefully, RST aborts it, PSH asks for immediate delivery, URG marks urgent data, and ECE and CWR handle congestion signals. Normal traffic follows predictable flag patterns, such as the SYN, SYN-ACK, ACK handshake. Combinations that never occur in real conversations, such as no flags at all, SYN with FIN, or FIN, PSH and URG together, usually point to scanning or crafted packets, so defenders alert on them.
Key takeaways
- RFC 9293 is the current TCP standard and defines the control bits.
- SYN, ACK, FIN and RST drive the connection life cycle.
- ECE and CWR support Explicit Congestion Notification (RFC 3168).
- Illegal flag combinations are strong signs of reconnaissance.
- Firewalls, IDS rules and packet filters can detect and drop them.
Table of Contents
- What Are TCP Flags?
- What Does Each TCP Flag Mean?
- How Do Flags Open and Close a Connection?
- Which Flag Combinations Are Abnormal?
- How Do Defenders Detect Abnormal Flags?
- How Do You Defend Against SYN Floods?
- Why Does Authorisation Matter When Testing?
- References
What Are TCP Flags?
Every TCP segment carries a header with ports, sequence and acknowledgement numbers, a window size and a set of control bits. RFC 9293, which replaced RFC 793 in 2022, defines these bits. Each is on (1) or off (0), and together they describe the purpose of the segment.
What Does Each TCP Flag Mean?
| Flag | Name | Purpose |
|---|---|---|
| SYN | Synchronise | Start a connection and set the initial sequence number |
| ACK | Acknowledge | Acknowledgement number is valid; set on almost every segment after the first |
| FIN | Finish | Sender has no more data; graceful close |
| RST | Reset | Abort the connection or refuse a request to a closed port |
| PSH | Push | Pass data to the application without waiting |
| URG | Urgent | Urgent pointer is valid; rarely used today (RFC 6093) |
| ECE | ECN-Echo | Signal congestion or ECN capability (RFC 3168) |
| CWR | Congestion Window Reduced | Sender has slowed down in response to ECE |
An older ninth bit, NS, was experimental and is no longer used.
How Do Flags Open and Close a Connection?
- Open: client sends SYN, server replies SYN-ACK, client sends ACK. Data can now flow.
- Transfer: segments carry ACK, often with PSH when the application sends a burst.
- Graceful close: each side sends FIN and receives an ACK, usually four segments.
- Abrupt close: one side sends RST, for example when an application crashes or a port is closed.
Which Flag Combinations Are Abnormal?
| Pattern | Flags set | Why it is suspicious |
|---|---|---|
| Null | None | Every valid segment has at least one flag |
| FIN only | FIN without ACK | A real close always acknowledges data |
| Xmas | FIN, PSH, URG | No legitimate stack sends this mix |
| SYN-FIN | SYN and FIN | Opening and closing at once is contradictory |
| SYN-RST | SYN and RST | Contradictory; crafted packet |
| Many SYNs, few ACKs | SYN | Port sweep or SYN flood |
| ACK with no session | ACK | Probing firewall rules |
These patterns are how tools probe for open ports and map firewalls, which MITRE tracks as T1046, network service discovery.
How Do Defenders Detect Abnormal Flags?
In Wireshark, these display filters use fields from the TCP field reference:
tcp.flags == 0x000 # null
tcp.flags.fin == 1 and tcp.flags.psh == 1 and tcp.flags.urg == 1 # Xmas
tcp.flags.syn == 1 and tcp.flags.fin == 1 # SYN-FIN
tcp.flags.syn == 1 and tcp.flags.ack == 0 # new connection attempts
On a Linux sensor you own, tcpdump can watch for the same patterns:
sudo tcpdump -n 'tcp[tcpflags] == 0'
sudo tcpdump -n 'tcp[tcpflags] & (tcp-syn|tcp-fin) == (tcp-syn|tcp-fin)'
IDS tools such as Snort match flags with the flags rule option, and stateful firewalls drop segments that do not fit a known connection. Alert on volume as well as pattern: one host sending SYNs to hundreds of ports in seconds deserves a ticket.
How Do You Defend Against SYN Floods?
A SYN flood sends many SYNs and never completes the handshake, filling the server's queue of half-open connections. RFC 4987 lists mitigations: SYN cookies, larger backlogs, shorter timeouts, filtering spoofed sources and upstream DDoS protection. On Linux, check that SYN cookies are on:
sysctl net.ipv4.tcp_syncookies
Why Does Authorisation Matter When Testing?
Sending crafted packets to systems you do not own can breach Sections 43 and 66 of India's IT Act 2000. Test only with written permission and a defined scope, and keep logs, since CERT-In expects 180 days of retention.
For the full header layout, see our complete guide to TCP header flags, and compare transports in TCP vs UDP. Our SOC and network security training covers packet analysis in labs.
References
Frequently Asked Questions
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Wow
0
Sad
0
Angry
0