-
Notifications
You must be signed in to change notification settings - Fork 39
Run backend services from restricted web user
#811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nkiryanov а может еще
USER webпередcompilemessagesиcollectstaticпоставить?тогда созданные файлы будут принадлежать web-у. Так же, чисто теоретически, не получится сделать атаку, что какая-то хрень в них из под рута запустится.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Если правильно понимаю это безопасность не повысит: важно ведь не кто owner у файла, а каким юзером они запускаются.
Тут даже наоборот: если поставить
USER webпередcollectstatic, то не получится статику собрать, т.к. пишем её в/var/lib/django-staticи не хватит прав на запись. То есть можно права на/var/lib/django-staticна web поменять после выполнения, но кажется смысла в этом нет — я проверял что есть права на чтение у web и раздаётся ок.Но! Это удивило, но что-то не сообразил сразу сделатьissue— а сфига статика в/var/lib/django-staticсобирается. Походу у нас древняя ошибка вsettings.STATIC_ROOT— там релатив путь, хотя обычно ожидаешь абсолютный и возможно ноги из этого растут.Сделаю новый issue разобраться с этим — прежде всего интересует откуда берётся/var/lib/django-staticи куда по уму собирать. Глядишь и в Makefile не будем папку с статикой создавать, т.к. создадим в процессе bootstrap.update:
Новый issue сделал разобраться с relative статикой. Откуда
/var/lib/django-static— всё понятно (в dockerfile).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Согласен со Славой насчет
Мы создаем юзера, который запускает процесс в контейнере и может работать только со своими файлами. В этом смысле, chown`нить файлы имеет смысл, чтобы образ был целостным.
Навсякий, идея всей задачи уберечься от какого-нибудь zero-day в котором рут пользователь изнутри контейнера может получить доступ к руту хоста, а для этого нужно максимально сузить доступы основного юзера в образе.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут в голову лезет сценарий, что кто-то проник в репозиторий и деплоит код, в котором вместо джанговской
collectstaticвыполняется своя рутовая команда в кастомномcollectstatic. Как раз, чтобы прав не хватило на это.