Skip to content

Fix out-of-bounds index in TLV processing - #898

Merged
davidv1992 merged 3 commits into
mainfrom
fix/long-tlv-list
Nov 20, 2026
Merged

davidv1992 merged 3 commits into
mainfrom
fix/long-tlv-list

Conversation

@squell

@squell squell commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Originally reported by Ömer Yusuf Yıldırım (@omerysfyldrm)

I have strong reason to believe the test case in the first commit is LLM-generated (but not by me)

@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.13%. Comparing base (c894331) to head (b8a976e).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #898      +/-   ##
==========================================
+ Coverage   64.03%   65.13%   +1.10%     
==========================================
  Files          62       62              
  Lines        8093     7988     -105     
==========================================
+ Hits         5182     5203      +21     
+ Misses       2911     2785     -126     
Flag Coverage Δ
fuzz 14.53% <0.00%> (-0.69%) ⬇️
fuzz-message_sound 14.53% <0.00%> (-0.69%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@squell

squell commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Relevant summary:

When the PTP Path Trace option is enabled, statime parses the PathTrace TLV of an
incoming Announce message and collects its clock-identity entries into a
fixed-capacity ArrayVec of 128 elements. The number of entries is taken directly
from the length of an attacker-controlled TLV and is never bounded before the collect.
A single crafted Announce carrying 129 or more 8-byte entries overflows the
ArrayVec, and arrayvec's FromIterator panics. In statime-linux the panic
unwinds the port's async task, so the affected PTP port stops synchronizing — a remote,
unauthenticated denial of service against time synchronization.

The in-code comment at the collect site asserts the opposite:

// Cannot panic as `list` is large enough to contain up to a whole message
path_trace_ds.list = tlv
   .value
   .chunks_exact(8)
   .map(|ci| ClockIdentity(<[u8; 8]>::try_from(ci).unwrap()))
   .collect();

That invariant does not hold on the receive path (see "Why the 'cannot panic' comment is wrong").

@davidv1992
davidv1992 added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit fe8cb88 Nov 20, 2026
4 checks passed
@davidv1992
davidv1992 deleted the fix/long-tlv-list branch November 20, 2026 13:14
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.

3 participants