Skip to content

Conversation

@leo9800
Copy link
Contributor

@leo9800 leo9800 commented Dec 12, 2025

this patch tackles 3 major issues of the current implementation of impersonator:

1. handling additional groups

unix users could retrieve groups they belongs with id command, it is common that a user belongs to multiple additional groups than the one which named identical to him/herself. here below is an example retrieving my groups on my linux workstation:

$ id
uid=1000(leo) gid=1000(leo) groups=1000(leo),150(wireshark),970(libvirt),971(docker),998(wheel)

the current implementation, wsgidav only call os.setegid(1000) when impersonating as leo on this machine, while other groups, incl. wireshark, docker, etc, should also be added.

this patch handles such cases with os.initgroups() to properly add additional groups accordingly (to /etc/group) when impersonating.

2. rejecting system users

uids <= 999 on unix systems are generally preserved for system daemon uses, a sysadmin may not want someone being capable to impersonate as such users. (probably due to misconfiguration of domain controller, etc)

this patch adds an option to reject impersonating-as-system-users attemps:

impersonator:
    reject_system_users: true

3. docker capability issues

docker's --cap-add (or cap_add: in docker-compose.yml) does not add the capabilities to the ambient set, therefore the capability is dropped upon fork()/execve(), (which is behind gunicorn's worker spawning) rendering the approach described in #343 (comment) not feasible.

this patch included a statically-linked helper program in C to achieve this in containers.

suid-wrapper nobody wsgidav -c /path/to/wsgidav.yaml

… system users (uid <= 999)

sample_wsgidav.yaml: configuration entry for the feature above

Signed-off-by: Leo <[email protected]>
…d CAP_SETGID

docker `--add-cap` (or `add_cap` in docker-compose.yml) could not set ambient capabilities
and therefore the SUID/SGID caps are not inherited by the child process spawned by gunicorn.

this wrapper mimics what `capsh` do in mar10#343

Signed-off-by: Leo <[email protected]>
@codecov
Copy link

codecov bot commented Dec 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.12%. Comparing base (f12b2ec) to head (44a2fcd).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #353      +/-   ##
==========================================
+ Coverage   44.06%   44.12%   +0.06%     
==========================================
  Files          29       29              
  Lines        4893     4893              
==========================================
+ Hits         2156     2159       +3     
+ Misses       2737     2734       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant