Skip to content

dot15d4: fix aux_sec_header incorrect parsing#4969

Merged
gpotter2 merged 3 commits into
secdev:masterfrom
T3pp31:fix/dot15d4-aux-sec-header-parsing
Apr 28, 2026
Merged

dot15d4: fix aux_sec_header incorrect parsing#4969
gpotter2 merged 3 commits into
secdev:masterfrom
T3pp31:fix/dot15d4-aux-sec-header-parsing

Conversation

@T3pp31
Copy link
Copy Markdown
Contributor

@T3pp31 T3pp31 commented Apr 14, 2026

Summary

Fixes #4928

  • Fix ConditionalField lambdas in Dot15d4Data, Dot15d4Beacon, and Dot15d4Cmd that used is True identity check instead of truthiness check. In Python 3, 1 is True evaluates to False because is checks object identity, so aux_sec_header was never parsed even when fcf_security == 1.
  • Add extract_padding() to Dot15d4AuxSecurityHeader so remaining bytes after the header fields are returned to the parent packet instead of being consumed as payload.

Test plan

  • Added test: Dot15d4AuxSecurityHeader trailing bytes become Padding, not Raw
  • Added test: Beacon with fcf_security=1 correctly parses aux_sec_header (issue reproduction case)
  • Added test: Data build & dissect round-trip with aux_sec_header
  • Added test: Cmd build & dissect round-trip with aux_sec_header
  • Added test: Beacon with fcf_security=0 has aux_sec_header is None
  • All 65 existing + new tests pass (PASSED=65 FAILED=0)

Fix two bugs preventing correct parsing of 802.15.4 frames with the
security bit set:

1. Replace `is True` identity check with truthiness check in
   ConditionalField lambdas for Dot15d4Data, Dot15d4Beacon, and
   Dot15d4Cmd. In Python 3, `1 is True` is False because `is` checks
   object identity, not equality, so aux_sec_header was never parsed.

2. Add extract_padding() to Dot15d4AuxSecurityHeader so that remaining
   bytes after the header fields are returned to the parent packet
   instead of being consumed as payload.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.31%. Comparing base (66ef96a) to head (65e9d39).
⚠️ Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
scapy/layers/dot15d4.py 80.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4969   +/-   ##
=======================================
  Coverage   80.31%   80.31%           
=======================================
  Files         381      381           
  Lines       93630    93640   +10     
=======================================
+ Hits        75202    75211    +9     
- Misses      18428    18429    +1     
Files with missing lines Coverage Δ
scapy/layers/dot15d4.py 79.59% <80.00%> (+0.02%) ⬆️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

T3pp31 added 2 commits April 14, 2026 22:53
The encrypted beacon payload cannot be parsed as ZigBeeBeacon, which
raises an exception when conf.debug_dissector is True (as in CI).
When sec_sc_seclevel >= 4 (ENC, ENC-MIC-*), the payload after
aux_sec_header is encrypted and must not be passed to upper layer
dissectors (SixLoWPAN, ZigBee, etc.). Add encrypted payload checks
to guess_payload_class() in Dot15d4Data, Dot15d4Beacon, and
Dot15d4Cmd.
@T3pp31
Copy link
Copy Markdown
Contributor Author

T3pp31 commented Apr 15, 2026

The only remaining failure (ubuntu-latest 3.12 non_root) was an infrastructure timeout during apt-get install linux-modules-extra in the runner setup phase (The operation was canceled.), not a test failure. All 23 other CI jobs pass. A re-run should clear it.

Copy link
Copy Markdown
Member

@gpotter2 gpotter2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR ! LGTM.

@gpotter2 gpotter2 merged commit 8fc7fc9 into secdev:master Apr 28, 2026
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dot15d4 aux_sec_header incorrect parsing

2 participants