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.
Created attachment 19118 [details] patch for master
> CVSS 3.1: 5.3 (AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:N/A:L) 4.2.
(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>
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.
(In reply to Andrew Bartlett from comment #4) Hi Andrew, No objection.
[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.