Skip to content

TCP._make_mptcp_capable writes length 20/32 where RFC 8684 gives 12/20, and now packs wrong bytes rather than crashing #567

Description

@JarryShaw

TCP._make_mptcp_capable writes an MP_CAPABLE length that is wrong in both branches. Found while fixing #541, which unmasked it; filed separately.

The arithmetic

pcapkit/protocols/transport/tcp.py:2669:

length=20 if rkey is None else 32,

RFC 8684 section 3.1 gives MP_CAPABLE as 12 octets without the receiver's key and 20 octets with it. So both branches are wrong, and confusingly the no-key branch writes 20 — which is the correct value for the other case.

Why it appears now

It was entirely masked. Before #541, MPTCP declared kind/length only under typing.TYPE_CHECKING, so the maker's length= was dropped with UnknownFieldWarning and packing died on KeyError: 'length' before the value could reach the wire. #541 declares them as real fields, so the length now lands — and lands wrong.

That makes this the more dangerous of the two defects #541 exposed: unlike #566, which raises, this one packs successfully with wrong bytes. A caller gets an MP_CAPABLE option whose length octet disagrees with its own payload and no exception to warn them.

Coverage

A test asserting the packed byte length of MP_CAPABLE for both the key-present and key-absent cases, against RFC 8684 section 3.1 rather than against current behaviour. Proven to fail without the fix, exit code read from a file.

Worth checking the sibling _make_mptcp_* helpers' length arithmetic in the same pass: #541 established that all eleven share a common history of never having had their lengths exercised, so this may not be the only one. The four packed-byte assertions #541 added for ADD_ADDR (1e08340101020304 at length 8, 1e0a34010102030401bb at 10, and the IPv6 forms at 20 and 22) are the pattern to follow.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions