Commit graph

4099 commits

Author SHA1 Message Date
Wim Taymans
0816d4a2fd security: reduce MAX_PERMISSIONS to limit alloca stack usage
Memory Safety: Medium

The parse_permissions_struct macro in protocol-native uses alloca()
to allocate space for permissions received from protocol messages.
With MAX_PERMISSIONS=4096 and sizeof(struct pw_permission)=8, this
could allocate up to 32KB on the stack from a single message. Combined
with parse_dict (up to 16KB), a crafted message could consume ~48KB
of stack space.

Reduce MAX_PERMISSIONS from 4096 to 1024 (matching MAX_DICT) to limit
the maximum stack allocation to 8KB. This is still more than sufficient
for any legitimate permission update - typical systems have far fewer
than 1024 objects that need individual permission entries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-29 13:58:04 +02:00
Wim Taymans
c3c11e4c76 security: add max packet limit to netjack2 recv_data loop
Input Validation: High

The netjack2_recv_data loop terminates based on the is_last flag
from received network packets. A malicious peer could continuously
send packets with is_last=0, causing the receive loop to run
indefinitely and blocking the audio processing thread. This is
a denial of service vulnerability.

Add a maximum packet count (1024) per receive cycle. This is
well above what any legitimate netjack2 session would produce
but prevents a malicious peer from stalling the processing thread.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-29 13:58:02 +02:00
Wim Taymans
110495ed9f security: fix unchecked write_event return value in RTP MIDI
Memory Safety: Critical

write_event() returns a negative int on error (-ENOSPC or -ERANGE),
but its return value was added directly to the uint32_t len variable
without checking. A negative return value would wrap len to a very
large number due to unsigned integer conversion, causing subsequent
buffer writes to go far out of bounds. This could lead to stack
corruption and potential code execution.

Fix by checking the return value of write_event() before using it.
If write_event() fails, abort the flush operation safely.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-29 13:57:45 +02:00
Wim Taymans
739e2d1107 netjack2: handle sync_wait errors
netjack2_driver_sync_wait can return an negative value on error, don't
do any processing in that case instead of wrapping around the negative
value into a huge unsigned int and breaking things..
2026-04-29 13:56:11 +02:00
Wim Taymans
3d414960c2 security: clamp netjack2 sync.frames to quantum limit
Clamp sync.frames to quantum_limit in both sync_wait functions so all
recv paths (float, int, opus, and the fallback memset in recv_data) use
a bounded frame count. A malicious remote could send a large sync.frames
causing buffer overflows in recv_int, recv_opus, and the unfilled-buffer
memset.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 13:42:49 +02:00
Wim Taymans
593132e434 security: fix error path resource leaks in netjack2 manager
Fix handle_follower_available to properly clean up on all error paths
after the follower has been added to the list. Add missing NULL checks
for pw_properties_copy and check the netjack2_init return value.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 13:21:21 +02:00
Wim Taymans
4ac5364004 security: add max followers limit to netjack2 manager
Add a configurable netjack2.max-followers property (default 64) to
limit the number of concurrent followers, preventing resource exhaustion
from unbounded follower connections.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 13:10:46 +02:00
Wim Taymans
7dee2c158f security: fix integer overflow in netjack2 opus encoded size calculation
Cast the denominator to uint64_t to prevent sample_rate * 8 from
overflowing uint32_t, which could produce a tiny denominator and
an inflated max_encoded_size.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 12:39:37 +02:00
Wim Taymans
be4fe881e3 security: validate opus encoded length in netjack2 recv
Validate that the encoded length from the network does not exceed
the available encoded data region before passing it to the opus
decoder.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 12:37:55 +02:00
Wim Taymans
3a77f9c28a security: fix OOB read in netjack2 MIDI buffer parsing
Validate that the midi buffer metadata fits within the buffer size
before computing the offset, preventing a size_t underflow. Also
bounds-check non-inline event data pointers against the validated
buffer region.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 12:30:37 +02:00
Wim Taymans
0186bccdce netjack2: account for overhead
The period calculation now subtracts the per-port int32_t overhead
from max_size before computing how many float samples fit. This guarantees
active_ports * (period * sizeof(float) + sizeof(int32_t)) <= max_size, so
packet_size = sizeof(header) + active_ports * sub_period_bytes <= mtu.

sub_cycle is bounded by nframes / sub_period_size, matching the sender's
num_packets = nframes / sub_period_size. Also ensure sub_period_size != 0
to avoid division by 0.
2026-04-29 12:27:29 +02:00
Wim Taymans
2af9e879a7 netjack2: use peer params name and follower_name
peer->params.name and peer->params.follower_name are null-terminated
by nj2_session_params_ntoh, whereas the raw params->name from the network
packet had no such guarantee.
2026-04-29 11:59:55 +02:00
Wim Taymans
2fee779161 security: add missing NULL check after calloc in sendspin-recv
Memory Safety: Medium

The ring buffer allocation in the sendspin receiver module was not
checked for NULL. If calloc fails (e.g., due to a large stride value
from network-controlled audio format parameters), the code proceeds
to use the NULL pointer, causing a crash.

Also changed calloc(1, size*stride) to calloc(size, stride) so that
calloc itself checks for multiplication overflow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-28 13:03:21 +02:00
Wim Taymans
a12cc84df4 security: fix integer overflow in PulseAudio message read_arbitrary
Memory Safety: High

The read_arbitrary() bounds check used `m->offset + len > m->length`
where len is an attacker-controlled uint32_t read from the PulseAudio
protocol message. When m->offset is small and len is close to
UINT32_MAX, the addition wraps around to a small value, bypassing
the bounds check. This allows read_arbitrary() to return a pointer
within the message buffer but report an enormous length to the caller,
leading to out-of-bounds memory reads.

Fixed by rearranging the arithmetic to use subtraction:
`len > m->length - m->offset`, which cannot overflow since
m->offset <= m->length is maintained as an invariant.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-28 12:56:28 +02:00
Wim Taymans
3b7e9b0779 security: replace atoi() with validated parsing in RAOP module
Input Validation: Medium

The RAOP sink module used atoi() to parse port numbers from RTSP
Transport headers received over the network. atoi() does not validate
input and its int return was silently truncated to uint16_t, meaning
out-of-range or negative values could produce unexpected port numbers.

Replaced RTSP Transport header port parsing with strtoul() plus range
validation (1-65535). Replaced the raop.port property parsing with
spa_atou32() and range checking. Replaced raop.latency.ms parsing with
spa_atou32() for consistency with safe parsing patterns used elsewhere
in the codebase.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-28 12:16:06 +02:00
Wim Taymans
a1aa9b0d75 security: replace atoi() with spa_atou32() for RTP session parameters
Input Validation: Medium

The RTP-SAP module used atoi() to parse rtp.rate, rtp.channels,
rtp.ssrc, and rtp.ts-offset properties into uint32_t fields. atoi()
returns int, which has undefined behavior on overflow and silently
converts negative values. When assigned to uint32_t, a negative result
wraps to a large value.

These properties can originate from received SDP announcements over the
network. Replaced with spa_atou32() which properly validates the input
and rejects non-numeric or out-of-range values. This is consistent with
how the same function already handles rtp.framecount using spa_atou32().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-28 12:14:46 +02:00
Wim Taymans
7465199fff security: replace unsafe atoi() with validated parsing in websocket
Input Validation: High

The WebSocket HTTP reply parser used atoi() to parse the Content-Length
header from network data. atoi() does not detect overflow or invalid
input, and its int return value was assigned to a size_t, meaning a
negative value from a malicious server would silently convert to a very
large unsigned value, potentially causing excessive memory allocation.

Replaced with spa_atou32() which validates the entire string is a valid
number and fits in uint32_t, plus an explicit upper bound (16 MB) on
content length to prevent resource exhaustion.

Similarly, pw_websocket_listen() used atoi() to parse the port number
into a uint16_t without validation. Replaced with spa_atou32() and a
range check against 65535.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-28 12:14:36 +02:00
Wim Taymans
39ac8cf996 filter-chain: improve docs about LADSPA 2026-04-28 11:32:53 +02:00
Wim Taymans
5faf043f6c roc-source: handle some errors better 2026-04-27 18:44:04 +02:00
Wim Taymans
c889edf172 roc-source: start/stop receiving in streaming/pause
Only start receiving packets when we are streaming.

Otherwise the ROC source will start receiving and queueing packets and
consume a lot of memory while we don't read the packets from the queue.

Likewise, stop receiving packets when we pause.

Fixes #5250
2026-04-27 18:29:39 +02:00
Wim Taymans
ebe9b087ad security: replace strcat with bounds-explicit memcpy in pulse utils
Memory Safety: Low

Although the preceding length check ensures the strcat is safe, using
strcat makes the bounds guarantee implicit. Replace with memcpy using
the already-computed length, making the bounded copy explicit and
avoiding a redundant scan of the destination string.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 16:14:23 +02:00
Wim Taymans
d456be1943 security: fix strcpy into fixed-size buffer in netjack2 driver
Memory Safety: Low

strcpy() into the fixed-size params.type[8] buffer has no bounds
checking. While the current literal string "params" fits exactly,
this pattern is fragile and would silently overflow if the string
were ever changed. Use snprintf() with sizeof() for bounds safety,
consistent with how params.name and params.follower_name are
handled on the lines immediately following.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 16:13:34 +02:00
Wim Taymans
9b845f4415 security: fix unsafe atoi() on network RTSP status code
Input Validation: Medium

atoi() on network-received data returns 0 on parse failure, which is
indistinguishable from a valid "0" input. It also accepts negative
values and does not detect overflow. Replace with strtol() and
validate that the status code is in the valid HTTP/RTSP range
(100-599) to prevent protocol state confusion from malformed
responses.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 16:13:14 +02:00
Wim Taymans
ca0fa1e4e1 security: fix missing NULL check after strdup in module-raop-discover
Memory Safety: Medium

strdup() can return NULL on allocation failure. The return value was
used without checking, which would cause a NULL pointer dereference
(crash) when the name is later compared with spa_streq(). Add a NULL
check and free the partially-allocated struct on failure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 16:12:47 +02:00
Wim Taymans
67f1e3a889 combine-stream: add combine.mode = monitor
Add a monitor mode that creates an Audio/Source combining audio from the
monitor ports of all Audio/Sink nodes. This allows capturing everything
that is being played back across all sinks into a single source.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 13:36:35 +02:00
Wim Taymans
87ee525b01 security: limit RTSP content-length and check allocation in RAOP client
Input Validation / Memory Safety: Medium

The RTSP client used for RAOP/AirPlay communication accepted arbitrarily
large Content-Length values from the remote server without any upper
bound. A malicious or compromised AirPlay server could specify a very
large Content-Length, causing the client to allocate unbounded memory
and potentially exhaust system resources (denial of service).

Additionally, the return value of pw_array_add() was not checked. If
the allocation failed, the subsequent memcpy would dereference a NULL
pointer, causing a crash.

Add a 64KB limit on Content-Length (more than sufficient for RTSP
control messages) and check the pw_array_add return value.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 13:30:36 +02:00
hackerman-kl
74b6f237d1 milan-avb: mvu certification number Disclamer to avoid any confusion 2026-04-27 10:56:44 +00:00
hackerman-kl
30711940c4 milan-avb: aecp: route VENDOR_UNIQUE_COMMAND through msg_info table 2026-04-27 10:56:44 +00:00
hackerman-kl
a16f3d704e milan-avb: aecp-vendor-unique-milan-v12: dispatch via per-cmd table per Milan v1.2 Section 5.4.4 2026-04-27 10:56:44 +00:00
hackerman-kl
deeea620f6 milan-avb: aecp-aem: GET_AS_PATH placeholder per IEEE 1722.1-2021 Section 7.4.41 2026-04-27 10:56:44 +00:00
hackerman-kl
df1605a333 milan-avb: entity-model: advertise VENDOR_UNIQUE_SUPPORTED in capabilities 2026-04-27 10:56:44 +00:00
hackerman-kl
d8b9a0f5ab milan-avb: aecp-aem: GET_STREAM_INFO CDL excludes 12-octet AVTPDU common 2026-04-27 10:56:44 +00:00
hackerman-kl
c967b39f18 milan-avb: avdecc: drop dead debug gate around avb_log_state 2026-04-27 10:56:44 +00:00
hackerman-kl
9c0007173b milan-avb: stream: wire Milan Section 5.4.5 stream counters, TX heartbeat, and MAX_TRANSIT_TIME plumbing 2026-04-27 10:56:44 +00:00
hackerman-kl
16d793db38 milan-avb: acmp: fixing the missing stream deactivate 2026-04-27 10:56:44 +00:00
hackerman-kl
de17f14da4 milan-avb: introducing GET_AS_PATH and GET/SET_MAX_TRANSIT 2026-04-27 10:56:44 +00:00
hackerman-kl
197bab7931 milan-avb: hook stream output to MSRP listener_observed + add max_transit_time_ns 2026-04-27 10:56:44 +00:00
hackerman-kl
a5fbeef6f8 milan-avb: add AVDECC stream_format decoder in aecp-aem.h 2026-04-27 10:56:44 +00:00
hackerman-kl
d9f8bacc76 milan-avb: AEM non-success replies preserve command payload size 2026-04-27 10:56:44 +00:00
hackerman-kl
25e3556050 milan-avb: ACMP status use the status of the FSM rather than the connection count to decide if bound or not 2026-04-27 10:56:44 +00:00
hackerman-kl
52c6c0a0cf milan-avb: GET_STREAM_INFO: fixing the bound state according tol the ACMP status 2026-04-27 10:56:44 +00:00
hackerman-kl
0bf4864d84 milan-avb: move teh descriptor FAM at the end of the structure to avoid overflow 2026-04-27 10:56:44 +00:00
hackerman-kl
4d33f57325 milan-avb: msrp: add debug msrp_talker back 2026-04-27 10:56:44 +00:00
hackerman-kl
ce42b7c1da milan-avb: msrp: mark listener stream-info dirty on TA/TF registrar change 2026-04-27 10:56:44 +00:00
hackerman-kl
995def4927 milan-avb: msrp: log notify_* at info level by default 2026-04-27 10:56:44 +00:00
hackerman-kl
76e7806251 milan-avb: cmd-get-set-stream-info: treat LV registrar as still registering 2026-04-27 10:56:44 +00:00
hackerman-kl
9f81c82100 milan-avb: avdecc: drive periodic timer at 100 ms 2026-04-27 10:56:44 +00:00
hackerman-kl
df62776308 milan-avb: mrp: set vector lva bit on outgoing LeaveAll frames 2026-04-27 10:56:44 +00:00
hackerman-kl
5c9a06c03d milan-avb: mrp: registrar treats RX_IN as a registration event 2026-04-27 10:56:44 +00:00
hackerman-kl
3b820add3b milan-avb: acmp-milan-v12: 'tmr_delay no saved packet' to debug, it may
happen
2026-04-27 10:56:44 +00:00