Bug 16104 - SAMR unix password sync substitutes account name into passwd program shell command without unsafe masking
Summary: SAMR unix password sync substitutes account name into passwd program shell co...
Status: ASSIGNED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: DCE-RPCs and pipes (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Jennifer Sutton
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-06-13 04:59 UTC by Douglas Bagnall
Modified: 2026-11-01 06:13 UTC (History)
1 user (show)

See Also:


Attachments
proposed patch for master (3.27 KB, patch)
2026-07-28 01:18 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-06-13 04:59:15 UTC
Tridge writes:

SAMR password change can carry a mapped username into unix password sync; passwd program expands %u with plain talloc_string_sub() and executes /bin/sh -c as root.

- source3/rpc_server/samr/srv_samr_chgpasswd.c:249-260
- source3/rpc_server/samr/srv_samr_chgpasswd.c:599-626
- source3/rpc_server/samr/srv_samr_chgpasswd.c:1167-1270
- source3/rpc_server/samr/srv_samr_nt.c:1893-2101


- Attacker role: Remote SAMR password-change caller for an account whose passdb/Unix username contains shell-sensitive syntax, or an actor able to create/map such an account.
- Entrypoint: SAMR ChangePasswordUser2, OemChangePasswordUser2, or ChangePasswordUser3.
- Trust boundary: Remote account names and passdb usernames cross into a root Unix password-sync shell command.

Attacker outcome: SAMR password change can carry a mapped username into unix password sync; passwd program expands %u with plain talloc_string_sub() and executes /bin/sh -c as root.

#### Severity

Final severity is **high**. This breaks a privileged integrity, authorization, filesystem, or remote daemon boundary with a concrete sink in repository code.

#### Remediation

Apply the check_password_script unsafe-character validation/masking to passwd program %u, reject unsafe account names before password sync, and avoid root shell command construction for password changes. Add regression coverage that exercises the attacker-controlled input at the listed entry point and asserts the validation, authorization, containment, or size check occurs before the dangerous sink.


| Severity | high |
| Confidence | high |
Comment 1 Douglas Bagnall 2026-06-13 05:05:49 UTC
This is the SAMR password change RCE variant that depends on the *unix* username containing shell metacharacters.
Comment 2 Jennifer Sutton 2026-07-27 21:25:23 UTC
The affected code does not appear to be tested.
Comment 3 Jennifer Sutton 2026-07-28 01:18:49 UTC
Created attachment 19136 [details]
proposed patch for master

Not tested because we have no tests for ‘unix password sync’.
Comment 4 Andrew Bartlett 2026-10-30 10:08:26 UTC
(In reply to Douglas Bagnall from comment #1)
I think we can disqualify this as a security bug.  Certainly should be fixed, but if your unix usernames contain shell meta-characters, there are bigger issues.
Comment 5 Andrew Bartlett 2026-11-01 06:11:19 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.