M1: dalek 4, fuzzing and fixes, tsc-model with server flavor

- curve25519-dalek-ng -> curve25519-dalek 4.
- fuzz/: cargo-fuzz targets for packets, commands and the license chain,
  plus a nightly workflow. Fixes for the panics they found: empty
  license, unchecked license property bounds, wrong index in the C2S
  audio invalid-codec error.
- tsc-model: ServerVersion/ServerFlavor/Capabilities parsed from
  virtualserver_version; tsctl shows the flavor in the tree header.
- CI lints every non-vendored crate via scripts/own-crates.sh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
This commit is contained in:
Claude committed 2026-09-25 13:40:56 +00:00
1 parent 369cbde85d
commit aa19afbcd0
24 files changed
+1835 -57

No files matched your search

+9
View File
@@ -51,3 +51,12 @@ against or offered back to upstream.
`notifystreamsignaling`, `notifystreamclientjoined`, `notifystreamclientleft`) and
commands (`setupstream`, `stopstream`, `streamsignaling`, `respondjoinstreamrequest`,
`removeclientfromstream`). See `docs/protocol-notes/ts6-streaming.md`.
5. **`curve25519-dalek-ng` → `curve25519-dalek` 4** (`tsproto-types`, `tsproto`). The `-ng`
fork is unmaintained; the API is the same apart from the basepoint table being a
reference. Verified by the license-chain unit tests and a live TeamSpeak 6 handshake.
6. **Panics on malformed input found by fuzzing** (`fuzz/`):
- `tsproto/src/license.rs`: an empty license (`initivexpand2 l=`) indexed `data[0]`;
license properties indexed past the end or with start > end. All property reads
are bounds-checked now.
- `tsproto-packets/src/packets.rs`: the invalid-codec error for short C2S audio
packets read `content[4]` instead of the codec byte `content[2]`.
+10 -2
View File
@@ -659,7 +659,7 @@ impl<'a> AudioData<'a> {
Ok(AudioData::C2S {
id,
codec: CodecType::from_u8(content[2])
.ok_or_else(|| Error::InvalidCodec(content[4]))?,
.ok_or_else(|| Error::InvalidCodec(content[2]))?,
data: &content[3..],
})
}
@@ -679,7 +679,7 @@ impl<'a> AudioData<'a> {
return Err(Error::PacketContentTooShort(content.len()));
}
let codec =
CodecType::from_u8(content[2]).ok_or_else(|| Error::InvalidCodec(content[4]))?;
CodecType::from_u8(content[2]).ok_or_else(|| Error::InvalidCodec(content[2]))?;
if newprotocol {
if content.len() < 14 {
return Err(Error::PacketContentTooShort(content.len()));
@@ -1187,6 +1187,14 @@ impl OutAudio {
#[cfg(test)]
mod tests {
#[test]
fn short_c2s_audio_with_invalid_codec_is_an_error() {
// Packet id + invalid codec byte, shorter than the old error path indexed.
for p_type in [PacketType::Voice, PacketType::VoiceWhisper] {
assert!(AudioData::parse(p_type, false, Direction::C2S, &[0, 1, 0xff]).is_err());
}
}
use super::*;
fn test_audio_roundtrip(dir: Direction, data: &AudioData) {
+1 -1
View File
@@ -20,7 +20,7 @@ include = [
[dependencies]
base64 = "0.22"
bitflags = { version = "2", features = ["serde"] }
curve25519-dalek-ng = "4"
curve25519-dalek = { version = "4", features = ["rand_core"] }
elliptic-curve = { version = "0.13", features = ["ecdh"] }
generic-array = "0.14"
num-bigint = "0.4"
+4 -4
View File
@@ -3,9 +3,9 @@ use std::convert::TryInto;
use std::{cmp, fmt, str};
use base64::prelude::*;
use curve25519_dalek_ng::constants;
use curve25519_dalek_ng::edwards::{CompressedEdwardsY, EdwardsPoint};
use curve25519_dalek_ng::scalar::Scalar;
use curve25519_dalek::constants;
use curve25519_dalek::edwards::{CompressedEdwardsY, EdwardsPoint};
use curve25519_dalek::scalar::Scalar;
use elliptic_curve::sec1::{FromEncodedPoint, ToEncodedPoint};
use generic_array::GenericArray;
use generic_array::typenum::Unsigned;
@@ -522,7 +522,7 @@ impl EccKeyPrivEd25519 {
impl<'a> From<&'a EccKeyPrivEd25519> for EccKeyPubEd25519 {
fn from(priv_key: &'a EccKeyPrivEd25519) -> Self {
Self((&constants::ED25519_BASEPOINT_TABLE * &priv_key.0).compress())
Self((constants::ED25519_BASEPOINT_TABLE * &priv_key.0).compress())
}
}
+1 -1
View File
@@ -21,7 +21,7 @@ include = [
aes = "0.8"
base64 = "0.22"
omnom = "3"
curve25519-dalek-ng = "4"
curve25519-dalek = { version = "4", features = ["rand_core"] }
eax = "0.5"
futures = "0.3"
generic-array = "0.14"
@@ -1,7 +1,7 @@
use base64::prelude::*;
use clap::Parser;
use curve25519_dalek_ng::edwards::CompressedEdwardsY;
use curve25519_dalek_ng::scalar::Scalar;
use curve25519_dalek::edwards::CompressedEdwardsY;
use curve25519_dalek::scalar::Scalar;
#[derive(Parser, Debug)]
#[command(author, about)]
+1 -1
View File
@@ -1,5 +1,5 @@
//! Handle packet splitting and cryptography
use curve25519_dalek_ng::edwards::EdwardsPoint;
use curve25519_dalek::edwards::EdwardsPoint;
use eax::aead::consts::{U16, U8};
use eax::{AeadInPlace, Eax, KeyInit};
use generic_array::GenericArray;
+21 -13
View File
@@ -3,8 +3,8 @@ use std::fmt;
use std::io::Cursor;
use std::str;
use curve25519_dalek_ng::edwards::EdwardsPoint;
use curve25519_dalek_ng::scalar::Scalar;
use curve25519_dalek::edwards::EdwardsPoint;
use curve25519_dalek::scalar::Scalar;
use num_derive::{FromPrimitive, ToPrimitive};
use num_traits::{FromPrimitive as _, ToPrimitive as _};
use omnom::{ReadExt, WriteExt};
@@ -165,7 +165,9 @@ impl Licenses {
pub fn parse(data: Vec<u8>) -> Result<Self> { Self::parse_internal(data, true) }
pub fn parse_internal(data: Vec<u8>, check_expired: bool) -> Result<Self> {
let version = data[0];
let Some(&version) = data.first() else {
return Err(Error::TooShort(0, "empty license"));
};
if version != 0 && version != 1 {
return Err(Error::UnsupportedVersion(version));
}
@@ -510,17 +512,20 @@ impl License {
) -> Result<impl Iterator<Item = Result<LicenseProperty<'a>>> + 'b> {
if let InnerLicense::Ts5Server { properties } = &self.inner {
Ok(properties.iter().map(move |p| {
// Every access is bounds-checked: the data comes from the server.
let get = |start: usize, end: usize| {
data.get(start..end).ok_or(Error::TooShort(data.len(), "license property"))
};
let o = BLOCK_MIN_LEN + 2 + p;
let len = data[o];
let header = get(o, o + 3)?;
let (len, id, typ) = (header[0], header[1], header[2]);
let len_usize = len as usize;
let id = data[o + 1];
let typ = data[o + 2];
// Check length
if let Some(expected) = match typ {
// String, check that it is null-terminated
0 => {
if data[o + len_usize] != 0 {
if get(o + len_usize, o + len_usize + 1)?[0] != 0 {
return Err(Error::NonterminatedString);
}
None
@@ -540,14 +545,14 @@ impl License {
return Err(Error::WrongPropertyType { id, expected: 1, actual: typ });
}
Ok(LicenseProperty::Unknown1(
(&data[o + 3..o + 3 + 4]).read_be().map_err(Error::Deserialize)?,
get(o + 3, o + 3 + 4)?.read_be().map_err(Error::Deserialize)?,
))
}
2 => {
if typ != 0 {
return Err(Error::WrongPropertyType { id, expected: 0, actual: typ });
}
let s = str::from_utf8(&data[o + 3..o + len_usize])
let s = str::from_utf8(get(o + 3, o + len_usize)?)
.map_err(Error::DeserializeString)?;
Ok(LicenseProperty::Issuer(s))
}
@@ -556,12 +561,10 @@ impl License {
return Err(Error::WrongPropertyType { id, expected: 1, actual: typ });
}
Ok(LicenseProperty::MaxClients(
(&data[o + 3..o + 3 + 4]).read_be().map_err(Error::Deserialize)?,
get(o + 3, o + 3 + 4)?.read_be().map_err(Error::Deserialize)?,
))
}
_ => {
Ok(LicenseProperty::Unknown { id, typ, data: &data[o + 3..o + len_usize] })
}
_ => Ok(LicenseProperty::Unknown { id, typ, data: get(o + 3, o + len_usize)? }),
}
}))
} else {
@@ -844,6 +847,11 @@ impl LicenseBlockBuilder<'_, '_> {
#[cfg(test)]
mod tests {
#[test]
fn empty_license_is_an_error() {
assert!(super::Licenses::parse(Vec::new()).is_err());
}
use super::*;
use base64::prelude::*;