virtualsquare / virtualsquare/picotcp

TCP reassembly issues when handling data overlaps

Open
#64 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
76
Forks
23
Avg merge
13h 52m
Merged PRs (30d)
3

Description

Dear picoTCP development team,

During some research work we conducted with Gilles Guette (IMT Atlantique), Pierre Chifflier (ANSSI) and Johan Mazel (ANSSI), we analyzed picoTCP 1.7.0 (tass-belgium/picotcp) and picoTCP 2.1 (virtualsquare/picotcp) reassembly when processing overlapping and non-overlapping TCP data segments.
We observed multiple problems that impact differently picoTCP versions.
Since we could not find a dedicated email address to report the issues, we contact the main picoTCP contributors.

You can find PCAP and plot files attached that illustrate the described issues.

Testing setup

The testing scenarii have the following common characteristics:

    1. a handshake is initiated from 192.168.56.140 host to 192.168.57.143 picoTCP host, targetting its TCP Echo port 7.
    1. the test case's data segments are sent from the initiator. (*)
    1. the initiator resets the TCP connection with a RST+ACK packet, whose sequence number is located after to the test case's rightmost data byte (or at the beginning of the first hole if applicable).
      Every packet that picoTCP host echoes back is acknowledged by the initiator.

(*) this step may change across testing scenario.

Issue 1: original payload truncation on the right (observed with and without parallelization testing)

We remark from picoTCP reassemblies that it can reconstruct an original data segment only if all the segments are in order and contiguous. Indeed, if any segment is out-of-order, picoTCP echoes some data but not the maximum possible amount of data. picoTCP ignores any data segment that overlaps an already received data segment.
This observed behavior may be due to implementation choices. Is this behavior intended?

Here is what the latest TCP RFC standard 9293 state about overlapping data-related processing:

  • in part 4 "Glossary" (https://datatracker.ietf.org/doc/html/rfc9293#section-4), part of the "receive window" definition states that "the local TCP endpoint considers that segments overlapping the range RCV.NXT to RCV.NXT + RCV.WND - 1 carry acceptable data or control. Segments containing sequence numbers entirely outside this range are considered duplicates or injection attacks and discarded.".
  • in part 3.10 "Event processing" (https://datatracker.ietf.org/doc/html/rfc9293#section-3.10-9), there is a TCP implementation example. It is said about overlapping segments that "When a segment overlaps other already received segments, we reconstruct the segment to contain just the new data and adjust the header fields to be consistent".

Consequently, even if the specification is not really crystal clear about the behaviour implementations must adopt in the presence of overlapping data segments, we believe that accepting overlapping data segments is the most RFC-compliant behaviour. This is not the observed picoTCP behavior that ignore any overlapping data segment.
Moreover, picoTCP must fully reassemble out-of-ordered data segments (i.e., without data truncation).

This issue impacts picoTCP 1.7 and 2.1. See tests 7, 8, 9, 10, and 168.

plot.zip
pcap.zip

Issue 2: original payload truncation on the left (observed only with parallelization testing)

We observe this issue in the following testing scenario:

  • 2.a. a non-overlapping segment is sent with data "0" from relative sequence number 1 to 2. We name this segment Start.
  • 2.b. the test case's (overlapping or non-overlapping) data chunks are sent from the initiator.

We note that the Start segment's data is not always echoed back whereas some test case's chunks are echoed back. This is problematic since the test case's chunk data starts to the right of Start's beginning.

This issue impacts only picoTCP 2.1. See test cases 382 and 478.

Issue 3: duplicates in payload (observed only with parallelization testing)

PicoTCP echoes back some already echoed data in some test cases. These duplicates are located at a wrong sequence number.

This issue impacts picoTCP 1.7 and 2.1. See test cases 376 and 456.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the TCP reassembly behavior with the attached PCAP and plot files, focusing on test cases 7, 8, 9, 10, 168, 382, 478, 376, and 456. Trace the TCP reassembly path implicated by those tests and define done as preserving overlapping and out-of-order data, retaining the leftmost payload, and avoiding duplicate echoed data at incorrect sequence numbers.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
networking
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.