Repository navigation
fix(linbo-torrent): never hand machine account files to nobody - #182
Conversation
|
Thanks for this one, and for the thorough description. It is a security fix independent of #178, so we'll review and release it on its own, ahead of the per-school group work. I reviewed it and ran the tests locally: all shell test files OK. I also checked the two Existing installations are only fixed by the next Before merging, please add a linuxmuster-tools#44 is independent of this PR. Neither has to wait for the other. |
48a06ed to
4434588
Compare
|
Thanks for the review and for running the tests. I added the |
*.macct files hold the samba password hashes of an image's machine account. The [linbo] rsync module serves LINBODIR as nobody without login, so a .macct owned by nobody can be downloaded by anyone on the network, even with mode 600. update_permissions() chowned the whole images dir to nobody and gave only images/<image>/*.macct back to root: - .macct files further down stayed nobody-owned after every run, e.g. the copies rsync-post-upload.sh keeps in images/<image>/backups/<timestamp>/ and those below images/.incoming/. - The others were nobody-owned between the recursive chown and the chown back to root. - Without any .macct, chown and chmod failed on the unexpanded glob and printed errors. - A symlink named *.macct in an image dir was followed by chown and chmod. Now .macct files at any depth below the images dir are made root:root 600 first and left out of the nobody chown. Symlinks are not followed (chown -h, as chown -R did before). images/.incoming, the staging dir of the central image sync (linuxmuster-tools), is left out of the nobody chown too: the image sync keeps it root 700 while an upload waits there, and every run gave it back to nobody. Its .macct files are still made root:root 600. Everything else is chowned as before. rsync-post-upload.sh created a new .macct with the default umask and set mode 600 only afterwards, so it was readable with mode 644 for a moment. An existing .macct was written in place and kept its mode until the chmod. The file is now removed and created anew with mode 600. Signed-off-by: Tom Lehmann <tom.lehmann@netzint.de> Assisted-by: Claude
4434588 to
b760996
Compare
…n upgrade linbo-torrent handed *.macct files below the images dir (backups, .incoming) to nobody before #182, and the [linbo] rsync module serves LINBODIR as nobody without login, so their samba password hashes could be downloaded. #182 fixes update_permissions(), but files already on disk are only corrected on the next linbo-torrent run, and the package configure step restarts linbo-torrent only when its config changed. Set every *.macct below the images dir to root:root 600 on configure, so a server is fixed right after the upgrade. Symlinks are not followed (-type f). Signed-off-by: thomas@linuxmuster.net Assisted-by: Claude
Problem
*.macctfiles hold the Samba password hashes (unicodePwd,supplementalCredentials) of an image's machine account. The[linbo]rsync module servesLINBODIRasnobodywithout login, so a.macctowned bynobodycan be downloaded by anyone who can reach rsync, even with mode 600.update_permissions()inlinbo-torrentchowned the whole images directory tonobodyand gave onlyimages/<image>/*.macctback to root:.macctfiles further down stayednobody-owned after every run, e.g. the copiesrsync-post-upload.shkeeps inimages/<image>/backups/<timestamp>/and those belowimages/.incoming/.nobody-owned between the recursive chown and the chown back to root..macct,chownandchmodfailed on the unexpanded glob and printed errors.*.macctin an image directory was followed bychownandchmod.rsync-post-upload.shwrote a new.macctwith the default umask and set mode 600 afterwards, so it was readable with mode 644 for a moment. An existing.macctwas written in place and kept its mode until thechmod.Change
.macctfiles at any depth below the images directory are maderoot:root600 first and left out of thenobodychown, so they are nevernobody-owned, not even for a moment. Symlinks are not followed (chown -h, aschown -Rdid before).images/.incoming, the staging directory of the central image sync, is left out of thenobodychown too. The image sync keeps it root 700 while an upload waits there. The.macctfiles in it are still maderoot:root600.rsync-post-upload.shremoves an existing.macctand creates the new one with mode 600.Companion fix for the central image sync: linuxmuster/linuxmuster-tools#44 creates staged and synced
.macctfilesroot:root0600 and keepsimages/.incomingroot 0700.Files already on disk are fixed by the next
linbo-torrentrun (e.g.linbo-torrent restart), or directly with:Testing
tests/shell/test_linbo-torrent.sh, 7 tests:.macctroot:root 600 at any depth, never handed tonobody, other files tonobodyas before,.incomingleft alone, opentracker directory to its user, no errors without any.macct, symlinks not followed.chownis stubbed since the tests don't run as root. 5 of them fail against7.4; the other 2 check that nothing else changes.sh tests/shell/run.shandbusybox ash tests/shell/run.sh: all test files OK..macctand.incoming.