feat: impersonator middleware feature/usability improvements#353
feat: impersonator middleware feature/usability improvements#353leo9800 wants to merge 4 commits intomar10:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #353 +/- ##
=======================================
Coverage 43.66% 43.66%
=======================================
Files 31 31
Lines 4967 4967
=======================================
Hits 2169 2169
Misses 2798 2798 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thanks and sorry for the delay. |
44a2fcd to
484d22f
Compare
mar10
left a comment
There was a problem hiding this comment.
Thanks and sorry for the delay.
Currently I don't have much resources for this project and I cannot fully assess the potential security implications.
Since you implemented the original 'impersonator' as separate, optional (opt-in) middleware marked as 'experimental, that was ok, but the docker and c extension should rather be moved in a separate location.
Signed-off-by: Leo <i@hardrain980.com>
… system users (uid <= 999) sample_wsgidav.yaml: configuration entry for the feature above Signed-off-by: Leo <i@hardrain980.com>
…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 <i@hardrain980.com>
…ages Signed-off-by: Leo <i@hardrain980.com>
484d22f to
ae33f5f
Compare
this patch tackles 3 major issues of the current implementation of impersonator:
1. handling additional groups
unix users could retrieve groups they belongs with
idcommand, 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:the current implementation, wsgidav only call
os.setegid(1000)when impersonating asleoon 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:
3. docker capability issues
docker's
--cap-add(orcap_add:in docker-compose.yml) does not add the capabilities to the ambient set, therefore the capability is dropped uponfork()/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.