Bug 16089 - SPOOLSS SetPrinter Level 3: NULL pointer dereference via empty security descriptor
Summary: SPOOLSS SetPrinter Level 3: NULL pointer dereference via empty security descr...
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Printing (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: printing-maintainers
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-05-27 02:56 UTC by Douglas Bagnall
Modified: 2026-11-01 06:13 UTC (History)
2 users (show)

See Also:


Attachments
original report (1.42 KB, text/markdown)
2026-05-27 02:56 UTC, Douglas Bagnall
no flags Details
Patch proposal - s3:spoolss: check for NULL security descriptor in update_printer_sec() (1.51 KB, patch)
2026-06-18 14:03 UTC, TristanInSec
no flags Details
Patch proposal - v2 - s3:spoolss: check for NULL security descriptor in update_printer_sec() (1.56 KB, patch)
2026-07-22 14:23 UTC, TristanInSec
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Douglas Bagnall 2026-05-27 02:56:49 UTC
Created attachment 18996 [details]
original report

Tristan (TristanInSec@gmail.com) reports (as attached):

`_spoolss_SetPrinter` in `source3/rpc_server/spoolss/srv_spoolss_nt.c` handles level 3 by calling `update_printer_sec()` without checking if `secdesc_ctr->sd` is NULL. Level 2 has the correct check:

 case 2:
    if (r->in.secdesc_ctr->sd)              // level 2: correct NULL check
        result = update_printer_sec(...);

 case 3:
    return update_printer_sec(...);           // level 3: no check

Inside `update_printer_sec()`, `sec_desc_merge()` is called at line 6352 with the NULL sd. `sec_desc_merge()` in `libcli/security/secdesc.c:137` immediately dereferences it:

 owner_sid = new_sdb->owner_sid ? ...    // new_sdb is NULL -> crash

Same root cause as findings 5 and 7: `sec_desc_buf.sd` is NULL when `sd_size=0`.

## Trigger

Send spoolss_SetPrinter with level=3 and `sec_desc_buf { sd_size=0, sd=NULL }` on a printer handle with PRINTER_ACCESS_ADMINISTER.
Comment 1 Douglas Bagnall 2026-05-27 02:59:27 UTC
Maybe "print server administrator can crash the print server" is not a security bug.

In any case the suggested CVSS of 4.9 (AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:N/A:H), which falls under our threshold for a security release.
Comment 3 TristanInSec 2026-05-28 22:36:56 UTC
Fair point Douglas. Printer admin crashing the print server is a pretty limited impact scenario, and I haven't seen secondary entry point.

Since this is the exact same root cause as bugs 16088 (SAMR, CVSS 6.5) and 16090 (SRVSVC, CVSS 6.5), it would make sense to fix all three as part of the same commit or patch series: "add NULL checks for wire-deserialized sec_desc_buf.sd before dereferencing." The level 2 handler in the same function already has the correct pattern, so the level 3 fix is a one-line addition matching that existing check.

Even if this one does not warrant a separate advisory, fixing it alongside the others prevents a future reporter from filing the same bug class again.
Comment 4 Douglas Bagnall 2026-05-31 03:01:20 UTC
(In reply to TristanInSec from comment #3)
> Even if this one does not warrant a separate advisory, fixing it alongside the others prevents a future reporter from filing the same bug class again.

Yes. We will keep this embargoed in the meantime.
Comment 5 TristanInSec 2026-06-18 14:03:47 UTC
Created attachment 19023 [details]
Patch proposal - s3:spoolss: check for NULL security descriptor in update_printer_sec()
Comment 6 TristanInSec 2026-07-08 17:51:29 UTC
Hi,

Just to follow up on this case.

Please also let me know if I can do anything else.

Best,
Tristan
Comment 7 Andreas Schneider 2026-07-13 12:37:59 UTC
Thank you very much for providing a patch. I think we should modify line 6242

if (secdesc_ctr == NULL || secdesc_ctr->sd == NULL) {
   DBG_DEBUG("Invalid security descriptor");
   ...
Comment 8 TristanInSec 2026-07-22 14:23:31 UTC
Created attachment 19126 [details]
Patch proposal - v2 - s3:spoolss: check for NULL security descriptor in update_printer_sec()
Comment 9 TristanInSec 2026-07-22 14:24:12 UTC
(In reply to Andreas Schneider from comment #7)

Hi Andreas,

Good suggestion thanks! Combining both checks into the existing guard is cleaner. Updated patch (v2) attached, merging the sd NULL check into the existing secdesc_ctr NULL check and using DBG_DEBUG.
Comment 10 Andreas Schneider 2026-09-11 10:34:38 UTC
lgtm now :-)
Comment 11 TristanInSec 2026-09-11 19:03:07 UTC
(In reply to Andreas Schneider from comment #10)

Thanks for the review
Comment 12 Andrew Bartlett 2026-11-01 06:11:16 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.