Skip to content

Fix out-of-bounds write when parsing tcp.flags#302

Merged
qdeslandes merged 1 commit into
facebook:mainfrom
qdeslandes:fix_tcp_flags_parsing
Jul 9, 2025
Merged

Fix out-of-bounds write when parsing tcp.flags#302
qdeslandes merged 1 commit into
facebook:mainfrom
qdeslandes:fix_tcp_flags_parsing

Conversation

@qdeslandes

Copy link
Copy Markdown
Contributor

The payload pointer is converted into an enum bf_tcp_flag * value and set to 0 (*flag = 0). However, the payload is 1 byte while a bf_tcp_flag enum type is 4, leading to out-of-bounds access.

Use uint8_t to represent the payload, and add a static assertion to enum bf_tcp_flag to ensure we never have more than 8 values to ensure the bitmask can still fit in uint8_t.

The payload pointer is converted into an `enum bf_tcp_flag *` value and
set to 0 (`*flag = 0`). However, the payload is 1 byte while a
`bf_tcp_flag` enum type is 4, leading to out-of-bounds access.

Use `uint8_t` to represent the payload, and add a static assertion to
`enum bf_tcp_flag` to ensure we never have more than 8 values to ensure
the bitmask can still fit in `uint8_t`.
@qdeslandes qdeslandes merged commit b97d9ae into facebook:main Jul 9, 2025
27 checks passed
@qdeslandes qdeslandes deleted the fix_tcp_flags_parsing branch July 9, 2025 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants