Skip to content

fix: reject Close packets with unexpected payloads#105

Open
immanuwell wants to merge 1 commit into
dragonflyoss:mainfrom
immanuwell:fix/close-payload-validation
Open

fix: reject Close packets with unexpected payloads#105
immanuwell wants to merge 1 commit into
dragonflyoss:mainfrom
immanuwell:fix/close-payload-validation

Conversation

@immanuwell

Copy link
Copy Markdown
Contributor

Description

Tighten Close decoding a bit. Right now Vortex::try_from accepts Close packets with extra bytes, which is kinda wonky because Close is documented and serialized as zero length.

Related Issue

Closes #104

Motivation and Context

This is easy to trigger in practice. The malformed packet is only 10 bytes total, so no quota or hard limit gets in the way. Any buggy peer can send it.

Repro on main:

use bytes::{Bytes, BytesMut};
use vortex_protocol::{Header, Vortex};
use vortex_protocol::tlv::Tag;

let header = Header::new(Tag::Close, 4);
let header_bytes: Bytes = header.into();
let value = Bytes::from_static(b"test");

let mut packet_bytes = BytesMut::new();
packet_bytes.extend_from_slice(&header_bytes);
packet_bytes.extend_from_slice(&value);

let packet = Vortex::try_from(packet_bytes.freeze());

Before this patch it parses as Vortex::Close(_) and drops the payload on re encode. After this patch it returns InvalidLength. tiny fix, but it keeps the codec honest.

Screenshots (if appropriate)

n/a

Signed-off-by: immanuwell <pchpr.00@list.ru>
@immanuwell immanuwell force-pushed the fix/close-payload-validation branch from aea721c to 5887f75 Compare June 16, 2026 17:05
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.

bug: Vortex::try_from accepts malformed Close packets with payloads

1 participant