secdev / secdev/scapy

StrFixedLenField with incomplete packet

Open
#4,450 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
12.6k
Forks
2.2k
Avg merge
1d 4h
Merged PRs (30d)
56

Description

Brief description

Interactions between StrFixedLenField and raw packet cache cause some inconsistencies when some packet field is or is not modified. This should probably be fixed by a modification of StrFixedLenField but a choice needs to be made between two possible behaviours.

Scapy version

all (at least from 2.3.1 to 2.6.0rc1)

Python version

all

Operating system

all

Additional environment information

No response

How to reproduce
from scapy.packet import Packet
from scapy.fields import StrFixedLenField

class P(Packet):
    fields_desc = [
        StrFixedLenField('a', None, length=1),
        StrFixedLenField('b', None, length=1),
        ]

p = P(b'0')
s0 = p.build()
p.a = b'1'
s1 = p.build()
print(s0, s1)
Actual result

b'0' b'1\x00'

Expected result

Either b'0\x00' b'1\x00' (if StrFixedLenField shall always be of the given length) or b'0' b'1' (if incomplete StrFixedLenField are to be remembered as incomplete)

Related resources

No response

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 interaction between Packet.build, the raw packet cache, and the two StrFixedLenField instances using the example in the issue. Decide which incomplete-field behavior is intended, then make the resulting builds consistent and verify both builds against the selected expected output.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.