An **out-of-bounds read** flaw has been found in the process_host_announce() function in source3/nmbd/nmbd_incomingdgrams.c of the NetBIOS browse handling in the **Samba** package. The function reads the announcement comment without checking that the comment is inside the datagram. The read continues until it finds a zero byte. The same missing check applies to a local master announcement. A network attacker or user who can reach nmbd can send one datagram to UDP port 138 and nmbd can stop and stay stopped until it is started again, leading to a denial of service.
AI_ONLY_REPORT
package: samba-4.23.5-105.el10
------
Summary: Reachable OOB read in `nmbd` election parsing via crafted SMB
mailslot offset/length: crafted `DataOffset`/`DataLength` values can cause
`process_election()` to parse an effectively empty election body and read
past the valid browse payload, likely causing `nmbd` crash or instability.
Requirements to exploit: A target deployment running `nmbd` and accepting
NetBIOS datagram traffic on UDP/138. An attacker must be able to send a
crafted `SMBtrans` mailslot datagram to `\\MAILSLOT
BROWSE` with
`DataOffset` and `DataLength` chosen so `ANN_Election` is dispatched with
no valid election body. No authentication or user interaction is required.
Component affected: SRPM package `samba-4.23.5-105.el10`; `nmbd`
browse/election parsing in `source3/nmbd/nmbd_packets.c`
(`process_dgram()`, `process_browse_packet()`) and
`source3/nmbd/nmbd_elections.c` (`process_election()`).
Version affected: `samba-4.23.5-105.el10` in configurations where `nmbd` is
running and reachable on UDP/138
Patch available: no released package fix established; proposed patch
included below
Version fixed: unknown
Upstream coordination: Not notified.
CVSS: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L - 5.3 (MEDIUM)
AV:N - Reachable over the network via NetBIOS datagram traffic to
UDP/138 when `nmbd` is active.
AC:L - The required `DataOffset`/`DataLength` manipulation is
straightforward and does not depend on a race or unusual environmental
condition.
PR:N - No privileges or prior authentication are required.
UI:N - No user interaction is required.
S:U - The impact is confined to the `nmbd` service.
C:N - The available evidence does not demonstrate disclosure of
attacker-inaccessible data.
I:N - The issue is an out-of-bounds read; no integrity impact is
demonstrated.
A:L - The demonstrated consequence is crash or instability potential in
`nmbd`, not proven full system compromise.
Impact: Important. The demonstrated outcome is an unauthenticated remote
denial of service condition in a network-facing daemon. No code execution
or direct confidentiality/integrity impact is established, so this does not
meet Critical, but Red Hat guidance classifies remotely triggerable denial
of service as Important for affected deployments. Reachability depends on
`nmbd` being enabled and reachable.
Embargo: yes
Reason: The issue is pre-auth reachable over the network in
configurations running `nmbd`, and public disclosure before a fix would
provide a low-complexity service disruption technique against exposed
deployments.
Acknowledgement: Aisle Research
Vulnerability Details: `process_election()` performs fixed-offset reads
from attacker-controlled election data and then pulls a fixed-size NetBIOS
name from `buf+13`, but it does not receive or validate the election body
length before doing so.
```c
/* source3/nmbd/nmbd_elections.c */
void process_election(struct subnet_record *subrec, struct packet_struct
*p, const char *buf)
{
int version = CVAL(buf,0);
uint32_t criterion = IVAL(buf,1);
int timeup = IVAL(buf,5)/1000;
...
pull_ascii_nstring(server_name, sizeof(server_name), buf+13);
}
```
`process_browse_packet()` dispatches `ANN_Election` directly as
`process_election(subrec, p, buf+1)` without any minimum-length validation
for the election body.
```c
/* source3/nmbd/nmbd_packets.c */
case ANN_Election:
debug_browse_data(buf, len);
process_election(subrec, p, buf+1);
break;
```
The reachable condition supported by the available material is in
`process_dgram()`: attacker-controlled `DataOffset` and `DataLength` are
only checked against generic in-range constraints. A datagram with
`DataLength == 1` and `DataOffset` pointing to the last byte of
`dgram->data` still passes these checks. If that last byte is
`ANN_Election`, `process_election()` receives `buf+1` at or beyond the end
of the valid browse payload and the fixed reads above become out of bounds.
```c
/* source3/nmbd/nmbd_packets.c */
len = SVAL(buf,smb_vwv11);
buf2 = smb_base(buf) + SVAL(buf,smb_vwv12);
if (len <= 0 || len > dgram->datasize) return;
if (buf2 < dgram->data || (buf2 >= dgram->data + dgram->datasize)) return;
if ((buf2 + len < dgram->data) || (buf2 + len > dgram->data +
dgram->datasize)) return;
```
The provided evidence supports an out-of-bounds read with likely
availability impact in `nmbd`. It does not currently establish a write
primitive, code execution, or a direct confidentiality impact.
Steps to reproduce:
1. Build and run `nmbd` with AddressSanitizer enabled
(`-fsanitize=address`) in a controlled test environment and make UDP/138
reachable.
2. Send a NetBIOS datagram carrying an `SMBtrans` mailslot request to
`\\MAILSLOT
BROWSE` with `DataLength` (`smb_vwv11`) set to `1`,
`DataOffset` (`smb_vwv12`) pointing to the last byte of `dgram->data`, and
that final byte set to `ANN_Election` (`0x08`).
3. Observe that `process_dgram()` accepts the datagram under the current
range checks and `process_browse_packet()` dispatches
`process_election(subrec, p, buf+1)`.
4. Confirm that `process_election()` then reads past the valid election
payload. ASan should report an out-of-bounds read; non-ASan builds may
instead show crash or instability.
Mitigation: Disable `nmbd` where it is not required, or filter untrusted
NetBIOS datagram traffic so external or untrusted hosts cannot reach
UDP/138 and the `\\MAILSLOT
BROWSE` parsing path until a fix is available.
Proposed Fix: Propagate the election payload length into
`process_election()` and reject undersized election bodies before any
fixed-offset reads or NetBIOS name parsing.
```diff
diff --git a/source3/nmbd/nmbd_proto.h b/source3/nmbd/nmbd_proto.h
@@
-void process_election(struct subnet_record *subrec, struct packet_struct
*p, const char *buf);
+void process_election(struct subnet_record *subrec, struct packet_struct
*p, const char *buf, int buf_len);
diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c
@@
case ANN_Election:
debug_browse_data(buf, len);
process_election(subrec, p, buf+1);
+ process_election(subrec, p, buf+1, len > 1 ? len - 1 : 0);
break;
diff --git a/source3/nmbd/nmbd_elections.c b/source3/nmbd/nmbd_elections.c
@@
-void process_election(struct subnet_record *subrec, struct packet_struct
*p, const char *buf)
+void process_election(struct subnet_record *subrec, struct packet_struct
*p, const char *buf, int buf_len)
{
struct dgram_packet *dgram = &p->packet.dgram;
+ const int min_len = 13 + (int)sizeof(nstring); /* fixed fields +
16-byte NetBIOS name */
+
+ if (buf_len < min_len) {
+ DEBUG(2,("process_election: ignoring short election packet from %s
(len=%d need>=%d)\n",
+ inet_ntoa(p->ip), buf_len, min_len));
+ return;
+ }
+
int version = CVAL(buf,0);
uint32_t criterion = IVAL(buf,1);
int timeup = IVAL(buf,5)/1000;
```
------
This report was generated using AI technology. Always review AI-generated
content prior to use
AI_ONLY_REPORT package: samba-4.23.5-105.el10 ------ Summary: Reachable OOB read in `nmbd` election parsing via crafted SMB mailslot offset/length: crafted `DataOffset`/`DataLength` values can cause `process_election()` to parse an effectively empty election body and read past the valid browse payload, likely causing `nmbd` crash or instability. Requirements to exploit: A target deployment running `nmbd` and accepting NetBIOS datagram traffic on UDP/138. An attacker must be able to send a crafted `SMBtrans` mailslot datagram to `\\MAILSLOT BROWSE` with `DataOffset` and `DataLength` chosen so `ANN_Election` is dispatched with no valid election body. No authentication or user interaction is required. Component affected: SRPM package `samba-4.23.5-105.el10`; `nmbd` browse/election parsing in `source3/nmbd/nmbd_packets.c` (`process_dgram()`, `process_browse_packet()`) and `source3/nmbd/nmbd_elections.c` (`process_election()`). Version affected: `samba-4.23.5-105.el10` in configurations where `nmbd` is running and reachable on UDP/138 Patch available: no released package fix established; proposed patch included below Version fixed: unknown Upstream coordination: Not notified. CVSS: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L - 5.3 (MEDIUM) AV:N - Reachable over the network via NetBIOS datagram traffic to UDP/138 when `nmbd` is active. AC:L - The required `DataOffset`/`DataLength` manipulation is straightforward and does not depend on a race or unusual environmental condition. PR:N - No privileges or prior authentication are required. UI:N - No user interaction is required. S:U - The impact is confined to the `nmbd` service. C:N - The available evidence does not demonstrate disclosure of attacker-inaccessible data. I:N - The issue is an out-of-bounds read; no integrity impact is demonstrated. A:L - The demonstrated consequence is crash or instability potential in `nmbd`, not proven full system compromise. Impact: Important. The demonstrated outcome is an unauthenticated remote denial of service condition in a network-facing daemon. No code execution or direct confidentiality/integrity impact is established, so this does not meet Critical, but Red Hat guidance classifies remotely triggerable denial of service as Important for affected deployments. Reachability depends on `nmbd` being enabled and reachable. Embargo: yes Reason: The issue is pre-auth reachable over the network in configurations running `nmbd`, and public disclosure before a fix would provide a low-complexity service disruption technique against exposed deployments. Acknowledgement: Aisle Research Vulnerability Details: `process_election()` performs fixed-offset reads from attacker-controlled election data and then pulls a fixed-size NetBIOS name from `buf+13`, but it does not receive or validate the election body length before doing so. ```c /* source3/nmbd/nmbd_elections.c */ void process_election(struct subnet_record *subrec, struct packet_struct *p, const char *buf) { int version = CVAL(buf,0); uint32_t criterion = IVAL(buf,1); int timeup = IVAL(buf,5)/1000; ... pull_ascii_nstring(server_name, sizeof(server_name), buf+13); } ``` `process_browse_packet()` dispatches `ANN_Election` directly as `process_election(subrec, p, buf+1)` without any minimum-length validation for the election body. ```c /* source3/nmbd/nmbd_packets.c */ case ANN_Election: debug_browse_data(buf, len); process_election(subrec, p, buf+1); break; ``` The reachable condition supported by the available material is in `process_dgram()`: attacker-controlled `DataOffset` and `DataLength` are only checked against generic in-range constraints. A datagram with `DataLength == 1` and `DataOffset` pointing to the last byte of `dgram->data` still passes these checks. If that last byte is `ANN_Election`, `process_election()` receives `buf+1` at or beyond the end of the valid browse payload and the fixed reads above become out of bounds. ```c /* source3/nmbd/nmbd_packets.c */ len = SVAL(buf,smb_vwv11); buf2 = smb_base(buf) + SVAL(buf,smb_vwv12); if (len <= 0 || len > dgram->datasize) return; if (buf2 < dgram->data || (buf2 >= dgram->data + dgram->datasize)) return; if ((buf2 + len < dgram->data) || (buf2 + len > dgram->data + dgram->datasize)) return; ``` The provided evidence supports an out-of-bounds read with likely availability impact in `nmbd`. It does not currently establish a write primitive, code execution, or a direct confidentiality impact. Steps to reproduce: 1. Build and run `nmbd` with AddressSanitizer enabled (`-fsanitize=address`) in a controlled test environment and make UDP/138 reachable. 2. Send a NetBIOS datagram carrying an `SMBtrans` mailslot request to `\\MAILSLOT BROWSE` with `DataLength` (`smb_vwv11`) set to `1`, `DataOffset` (`smb_vwv12`) pointing to the last byte of `dgram->data`, and that final byte set to `ANN_Election` (`0x08`). 3. Observe that `process_dgram()` accepts the datagram under the current range checks and `process_browse_packet()` dispatches `process_election(subrec, p, buf+1)`. 4. Confirm that `process_election()` then reads past the valid election payload. ASan should report an out-of-bounds read; non-ASan builds may instead show crash or instability. Mitigation: Disable `nmbd` where it is not required, or filter untrusted NetBIOS datagram traffic so external or untrusted hosts cannot reach UDP/138 and the `\\MAILSLOT BROWSE` parsing path until a fix is available. Proposed Fix: Propagate the election payload length into `process_election()` and reject undersized election bodies before any fixed-offset reads or NetBIOS name parsing. ```diff diff --git a/source3/nmbd/nmbd_proto.h b/source3/nmbd/nmbd_proto.h @@ -void process_election(struct subnet_record *subrec, struct packet_struct *p, const char *buf); +void process_election(struct subnet_record *subrec, struct packet_struct *p, const char *buf, int buf_len); diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c @@ case ANN_Election: debug_browse_data(buf, len); process_election(subrec, p, buf+1); + process_election(subrec, p, buf+1, len > 1 ? len - 1 : 0); break; diff --git a/source3/nmbd/nmbd_elections.c b/source3/nmbd/nmbd_elections.c @@ -void process_election(struct subnet_record *subrec, struct packet_struct *p, const char *buf) +void process_election(struct subnet_record *subrec, struct packet_struct *p, const char *buf, int buf_len) { struct dgram_packet *dgram = &p->packet.dgram; + const int min_len = 13 + (int)sizeof(nstring); /* fixed fields + 16-byte NetBIOS name */ + + if (buf_len < min_len) { + DEBUG(2,("process_election: ignoring short election packet from %s (len=%d need>=%d)\n", + inet_ntoa(p->ip), buf_len, min_len)); + return; + } + int version = CVAL(buf,0); uint32_t criterion = IVAL(buf,1); int timeup = IVAL(buf,5)/1000; ``` ------ This report was generated using AI technology. Always review AI-generated content prior to use