Bug 16120 - source4 GPO fetcher converts SMB listing names into local paths without canonical containment proof
Summary: source4 GPO fetcher converts SMB listing names into local paths without canon...
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Python (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Douglas Bagnall
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-06-14 23:03 UTC by Douglas Bagnall
Modified: 2026-11-01 06:16 UTC (History)
1 user (show)

See Also:


Attachments
WIP patch removing source4/lib/policy, using libgpo instead in python (110.91 KB, patch)
2026-07-15 02:04 UTC, Douglas Bagnall
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-14 23:03:15 UTC
Tridge writes:

A hostile SYSVOL/SMB server can return backslash traversal names that pass the raw ../ filter, become local slash traversal during gp_get_files(), and drive mkdir() or O_CREAT|O_TRUNC writes outside the GPO cache.


- source4/lib/policy/gp_filesys.c:81-92 rejects . / .. and strstr(info->name, "../") before appending info->name with backslashes.
- source4/lib/policy/gp_filesys.c:290-299 converts backslashes to slashes and concatenates with local_path.
- source4/lib/policy/gp_filesys.c:305-325 mkdirs directories or fetches files to the constructed local path.
- source4/lib/policy/gp_filesys.c:215-217 opens local_dst with O_WRONLY|O_CREAT|O_TRUNC.

#### Dataflow

Attacker role: Malicious or compromised SYSVOL/SMB policy source able to control directory entry names returned to a Samba GPO fetch client.

Entrypoint: gp_fetch_gpt() connects to the GPO share, calls gp_do_list(), and receives entry names through smbcli_list() and gp_list_helper().

Trust boundary: Remote SMB directory-entry names cross into local policy-cache path construction and local mkdir/open sinks.

Controls and counterevidence:
- gp_list_helper ignores literal . and .. and rejects the raw substring ../ before the later separator conversion.
- GP_MAX_DEPTH limits recursion depth.
- Honest SMB servers may not emit names containing path separators.
- No realpath/commonpath/openat containment check is applied after backslash-to-slash conversion.

Exploit steps:
1. Control or compromise the SYSVOL/SMB source used for GPO fetching.
2. Return an entry name containing backslash traversal such as ..\outside, which is not matched by the raw ../ check.
3. Let gp_get_files() convert backslashes to local slashes and concatenate the result with the local cache path.


Attacker outcome: A hostile SYSVOL/SMB server can return backslash traversal names that pass the raw ../ filter, become local slash traversal during gp_get_files(), and drive mkdir() or O_CREAT|O_TRUNC writes outside the GPO cache.


Counterevidence: The path requires a malicious or compromised SYSVOL/SMB source; ordinary servers may not return entry names containing path separators, and recursion depth is capped.

#### Remediation

Normalize separators before filtering, reject any path separator or traversal component in listing names, and enforce final containment using canonical paths or openat-style fd traversal. 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 | medium |
| Confidence | high |
Comment 1 Douglas Bagnall 2026-07-15 02:04:55 UTC
Created attachment 19100 [details]
WIP patch removing source4/lib/policy, using libgpo instead in python

I wrongly categorised this as "Python", which automatically assigned it to me, but I will keep it because I was working on a fix a while ago.

There is no vulnerability, AFAICT, because

> Entrypoint: gp_fetch_gpt() connects to the GPO share,

there are no callers of gp_fetch_gpt(). 

In fact there are no users of this code at all.
Comment 2 Andrew Bartlett 2026-08-08 09:41:53 UTC
Remove non-security bug from the security tracking bug.
Comment 3 Andrew Bartlett 2026-11-01 06:11:32 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.