Bug 16165 - vfs_streams_xattr Hardcoded Prefix Length Out-of-Bounds Read on Custom Prefix
Summary: vfs_streams_xattr Hardcoded Prefix Length Out-of-Bounds Read on Custom Prefix
Status: ASSIGNED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: VFS Modules (show other bugs)
Version: 4.24.3
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Jennifer Sutton
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-07-09 02:42 UTC by Douglas Bagnall
Modified: 2026-11-01 06:19 UTC (History)
2 users (show)

See Also:


Attachments
patch for master (976 bytes, patch)
2026-07-17 03:15 UTC, Jennifer Sutton
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Douglas Bagnall 2026-07-09 02:42:35 UTC
Tristan reports:

streams_xattr Hardcoded Prefix Length Out-of-Bounds Read on Custom Prefix
=========================================================================
CVSS 3.1: 5.3 (AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:N/A:L)
CWE: CWE-125 (Out-of-bounds Read)
Auth: Authenticated SMB user
Version: Samba 4.24.3, master HEAD (custom streams_xattr:prefix configured)

File: source3/modules/vfs_streams_xattr.c, streams_xattr_fstreaminfo(), line 1280

Root Cause:

The function correctly uses config->prefix_len to filter xattr names,
but then strips the prefix using the hardcoded default prefix length
(strlen("user.DosStream.") = 16) instead of the configured prefix
length. When a shorter custom prefix is configured, the hardcoded
offset reads past the actual stream name.

    // Line 1271: correctly uses config->prefix_len for filtering
    if (strncmp(names[i], config->prefix, config->prefix_len) != 0) {
        continue;
    }

    // Line 1280: WRONG - uses hardcoded default prefix length (16)
    ret = streams_xattr_get_ea_value_fsp(
        names, config, smb_fname->fsp,
        names[i] + strlen(SAMBA_XATTR_DOSSTREAM_PREFIX),  // hardcoded 16
        &val);
    // Should be: names[i] + config->prefix_len

Data Flow:

  Admin sets streams_xattr:prefix = "user.S." (8 bytes)
  -> xattr "user.S.mystream" (15 bytes) matches filter (correct)
  -> names[i] + 16 reads 1 byte past null terminator
  -> for shorter xattr names, reads further past the end

Impact:

When a custom prefix shorter than the 16-byte default is configured,
every stream enumeration reads past xattr name strings. This corrupts
stream names returned to SMB clients and can read adjacent heap memory.

Lab verified: code trace confirmed hardcoded vs configurable prefix length.
Comment 1 Jennifer Sutton 2026-07-17 03:15:04 UTC
Created attachment 19118 [details]
patch for master
Comment 2 Douglas Bagnall 2026-07-17 03:22:30 UTC
> CVSS 3.1: 5.3 (AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:N/A:L)

4.2.
Comment 3 TristanInSec 2026-07-22 13:16:38 UTC
(In reply to Douglas Bagnall from comment #2)

You are right, 4.2 -- I miscalculated the original score. AC:H is correct since it requires a non-default streams_xattr:prefix configuration.

(In reply to Jennifer Sutton from comment #1)

Patch looks correct -- replacing strlen(SAMBA_XATTR_DOSSTREAM_PREFIX) with config->prefix_len at the strip point matches the strncmp filter above.

Reviewed-by: Tristan Madani <tristan@talencesecurity.com>
Comment 4 Andrew Bartlett 2026-10-26 02:06:26 UTC
This is just a bug in my view.  

The CVSS score is less than 5.0, the impacts appear as soon as the setting is changed (so why would you set this, let alone keep it if things do not work during even cursory testing). 

Moving to non-embargo non-security to open up if there are no objections.
Comment 5 TristanInSec 2026-10-30 21:22:49 UTC
(In reply to Andrew Bartlett from comment #4)

Hi Andrew,
No objection.
Comment 6 Andrew Bartlett 2026-11-01 06:11:00 UTC
[Bulk message on a number of bugs being made public at once]

The embargo is being removed from this bug.  

That is not to say that the issue is not a real bug, but some things are better dealt with in public, where the normal process is both more available to external contributors and much, much more efficient.  

If you have a patch for this issue, please do contribute it via our normal GitLab process:

https://wiki.samba.org/index.php/Contribute#Submitting_Patches_via_GitLab

All patches to Samba must follow our copyright policy:

https://www.samba.org/samba/devel/copyright-policy.html

Thanks to all who report issues to Samba, we value your patience as we, along with the rest of the Open Source and Free Software communities, work though the reported issues.