skip to content

An attacker resends a TCP segment with different data - why can an IDS and the server rebuild different requests, and what must you configure per host?

level: juniorimportance: should knowfreq 48%

answer

  1. the standard leaves one case undefined
  2. duplicate bytes, different content
  3. the behaviour belongs to the host, not the protocol
  4. the sensor has to imitate a stack it cannot query
  5. so the setting is keyed to address ranges

basics

~20 s

TCP does not define which copy of overlapping bytes wins, so different stacks keep different data - some the original, some the newer. A sensor several hops upstream must imitate the destination's choice, which means a reassembly policy set per address range.

solid answer

~50 s

A TCP connection is a byte stream cut into segments, and a segment may legitimately be retransmitted. Nothing in the standard says what a receiver must do when a retransmitted segment covers bytes it already holds but carries *different* data. Real stacks diverged: some keep the bytes they saw first, some let the later data overwrite, and others break ties by which segment starts at the lower offset. IP fragments with overlapping offsets have the same problem. An IDS sitting several hops away cannot ask the destination which behaviour it implements, so it has to guess - and if it guesses wrong, the attacker chooses which of the two rebuilds is real: a harmless one for the sensor, the attack for the server. That is why sensors carry a target-based reassembly policy keyed to address ranges rather than one global setting: your estate is not one stack, so the map has to say which range behaves like which family.

code

text · 10 lines
text
# one TCP connection, all three segments delivered to sensor and server
seq=1   len=6   data: GET /h
seq=7   len=6   data: ome.ht
seq=7   len=6   data: ../../          <- covers bytes 7..12 again, different content
...

keep-first rebuild    -> GET /home.ht
later-overwrites      -> GET /../../

# the sensor holds one policy; the destination implements the other one

go deeper

for a junior

Be ready to say plainly that a receiver can get the same byte positions twice with different content, that the standard does not name a winner, and that the sensor therefore has to be told what the destination will do.

for a middle

Explain the actual families of behaviour - keep the original, let later data overwrite, resolve by lower offset - and why the same host can resolve fragment overlap and segment overlap differently.

for a senior

Show how you would keep the address-range map honest as the estate changes, and what you do about ranges you cannot classify: dynamic client pools, translated addresses, and freshly acquired networks.

for a principal

Frame it as a maintained assertion about the estate rather than a one-off configuration, and be able to argue when the right answer is to stop predicting and remove the ambiguity from the traffic instead.

## The ambiguity is in the standard, not in the attack TCP presents a byte stream, but it moves that stream as segments carrying sequence numbers. Retransmission is normal and expected, so a receiver routinely gets bytes it already has. The specifications tell a receiver how to handle duplicate data; they do not settle what a receiver must do when the duplicate covers the same sequence range but contains *different bytes*. That case should never happen on a healthy network - and it is trivial to produce on purpose, because the attacker is the sender and can write whatever it likes into its own segments. IP fragmentation carries the identical hole. Fragments are placed by offset, and two fragments can claim overlapping offset ranges with conflicting content. Again the standard does not name a winner. ## The stacks resolved it differently and kept the difference When implementers filled the gap, they filled it in incompatible ways. Broadly there are three behaviours: - **keep what arrived first** - the original bytes stand, later overlapping data is discarded; - **let later data overwrite** - the most recent copy replaces what was held; - **break the tie by offset** - prefer the fragment or segment starting at the lower offset, falling back to arrival order when the starts are equal. Sensor configuration gives these families the names of the operating systems they were observed to match, because they were derived by testing real stacks rather than read out of any vendor document. That is worth knowing, but memorising the list is not the point of the question and an interviewer will not reward reciting it. The point is that the behaviour is a property of *the destination host*, not of the protocol, so it is not derivable from the packets themselves. ## Why the sensor is the one that suffers An IDS is not the destination. It watches from several hops upstream, and it must produce a single reconstruction of the stream before any content decision can be made. It has three bad options: pick one behaviour globally and be wrong for part of the estate; hold every plausible reconstruction at once and pay for the memory and the false alerts; or be told, per address range, which behaviour to imitate. The third is what real deployments do, and it is where the price lives. The attacker's move follows directly. Send the harmless bytes in one segment, the attack bytes in an overlapping one, and time or order them so that the sensor's rule for resolving the overlap and the server's rule select different content. The sensor sees a request that matches nothing. The server sees the request the attacker meant to send. No exploit was needed against the sensor - only a correct guess about which stack the destination runs, and that is cheap to obtain. Note that this does not require the attacker to be on the path or in the middle of anything. They are the client. They control their own transmission, including sending overlapping data that no normal stack would ever emit. ## What the per-range map actually asserts, and how it rots The reassembly-policy map is a table saying *this address range reassembles like family X*. It is an assertion about the operating systems living at those addresses, and it was true on the day someone derived it from an inventory. It rots in ordinary, unexciting ways: - a subnet is renumbered and the range now holds a different build; - a dynamically addressed client range holds two builds at once, and an address does not identify a host for longer than a lease; - an address translation device hides many hosts of different kinds behind one address, and a map keyed to addresses cannot express that at all; - two estates merge and one of them has no inventory you can read. Nobody is funded to re-derive it after every move, which is why it is common to find a sensor whose map has quietly described the wrong estate for years. ## The claim direction to get right An alert raised on reassembled content proves that *the sensor's reconstruction* contained the pattern. It does not prove the destination assembled the same bytes, and the absence of an alert does not prove the destination did not. Once you accept that the reconstruction is a prediction, the correct posture follows: treat the policy map as a maintained assertion about the estate, and treat any range you cannot classify as a range where content matching is unreliable.

  • Does the same ambiguity exist for IP fragments, or only for TCP segments?
    Both. Fragments are placed by offset and two fragments can claim overlapping ranges with conflicting bytes, with the same undefined winner. A host may even resolve fragment overlap and segment overlap by different rules, so sensors usually carry two policy settings per range rather than one.
  • If the sensor picks the wrong policy, does it fail towards missed attacks or towards false alerts?
    Either, depending on which way the mismatch runs. If the sensor keeps benign bytes the server discards, the attack passes unremarked. If the sensor keeps attack bytes the server never accepted, you get an alert for traffic that had no effect - a false positive that costs you an investigation and, on an inline device, dropped packets.
  • Does the attacker need to be on the network path to do this?
    No. They are the client and control their own sender, so they can emit overlapping segments no ordinary stack would produce. Being on-path buys the ability to tamper with someone else's traffic, which is a different attack; here the attacker only needs to fingerprint what the destination runs.

Two clerks take the same dictation, then the speaker corrects a word. One clerk was trained to keep the first version, the other to accept the correction. Neither is wrong; they simply end up with different sentences.

saying these in an interview costs you the question

  • Says TCP forbids overlapping segments so this cannot happen
  • Thinks the sensor can query the destination for its reassembly behaviour
  • Assumes one global reassembly setting covers a mixed estate
  • Believes the attacker must be a man-in-the-middle to overlap data
  • Treats the reassembled stream as proof of what the server received

context