-
Notifications
You must be signed in to change notification settings - Fork 283
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
Improve ownership and permissions of files in OpenSearch deb and rpm packages #3898
Improve ownership and permissions of files in OpenSearch deb and rpm packages #3898
Conversation
The files installed in /usr/share/opensearch do not need to be owned by the opensearch user. The default ownership from Debian packages, root:root is fine and should be preferred. Remove the post-installation line that customized these permissions. Signed-off-by: Romain Tartière <[email protected]>
The configuartion files installed by the opensearch package can contain sensitive information such as clear-text passwords (e.g. to reach an LDAP directory to authenticate users). When installing from a tarball, the configuration file are only accessible to the owner and members of the group of the file. Adjust the post-installation script to setup permissions for these files similar to the ones of the tarball. Currently, OpenSearch create files in the configuartion directory on first start (opensearch.keystore), so we cannot change the configuration directory ownership to prevent the service from tinkering with these files. Signed-off-by: Romain Tartière <[email protected]>
The OpenSearch logs may contain sensitive data. In order to prevent random users from accessing log files, Debian packages often setup the log directory so that only the service can write to it, members of the adm group can read these files, and other users are not granted access. Adjust the log directory owner and permissions to match that behavior. Signed-off-by: Romain Tartière <[email protected]>
Other users on the system have no reason to access the OpenSearch raw data files. Make sure these files are only available to the user running the service. Signed-off-by: Romain Tartière <[email protected]>
Now that the deb permissions and files ownerships are better, adjust the rpm receipe is a similar fashion for a consistent experience accross different operating systems. Signed-off-by: Romain Tartière <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #3898 +/- ##
==========================================
+ Coverage 92.03% 92.05% +0.01%
==========================================
Files 186 187 +1
Lines 5639 5662 +23
==========================================
+ Hits 5190 5212 +22
- Misses 449 450 +1 |
In deb we also set the initial permissions here: |
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.
Hi @smortex thanks for the contribution here.
I have some comments and once we clear these, I would need to run a full-ledge build on ci images with this code, to ensure it is running without issues.
Thanks.
Instead of adding and removing permission bits, use explicit values. Signed-off-by: Romain Tartière <[email protected]>
Thanks @smortex, once you address my last comment / open conversation, we can queue this up for merging. Bare in mind we might have a patch release before 2.10.0, so we might keep this PR open a bit until we enter the 2.10.0 release cycle, since there are a lot of essential changes on both deb/rpm. I will start the test on my side once all the existing conversation addressed. Thanks. |
scripts/pkg/build_templates/opensearch/deb/debmake_opensearch_install.sh
Show resolved
Hide resolved
They where changed unexpectedly in eb0e032 but while the change seems noop, better limit the number of changes to avoid unexpected regressions. Signed-off-by: Romain Tartière <[email protected]>
Hi @smortex , Add a comment and want to know if opensearch-project/OpenSearch#9447 needs to go in before this? Thanks. |
The presence of this bit on the files seems to have no consequence on the final package as the installed files do not have the SGID bit set. But for consistency with the rpm packaging, unset the bit before building the package. Signed-off-by: Romain Tartière <[email protected]>
0b460e8
to
71c7c34
Compare
@peterzhuamazon I added a commit to have the .deb and .rpm packaging doing the same stripping of the SGID bit. I am good with this PR as it is now, no need to wait for opensearch-project/OpenSearch#9447 to be merged IMHO as we have all required workarounds here. When opensearch-project/OpenSearch#9447 is merged, we can do the cleanup in this repo in a new PR. |
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.
Thanks @smortex for the help and commit to fix this issue.
Similar to the issue fixed in opensearch-project#3898, OpenSearch-Dashboards package has unexpected files owner and permissions. This ensure the installed files are not owner by the opensearch-dashboards user (preventing the program to overwrite itself with malicious code if the service has some kind of vulnerability), and make sure logs and data cannot be accessed by random users. Signed-off-by: Romain Tartière <[email protected]>
Similar to the issue fixed in opensearch-project#3898, OpenSearch-Dashboards package has unexpected files owner and permissions. This ensure the installed files are not owner by the opensearch-dashboards user (preventing the program to overwrite itself with malicious code if the service has some kind of vulnerability), and make sure logs and data cannot be accessed by random users. Signed-off-by: Romain Tartière <[email protected]>
…kages (opensearch-project#3898)" This reverts commit 35db59d.
…pensearch-project#3898) Signed-off-by: Romain Tartière <[email protected]>
…pensearch-project#3898) Signed-off-by: Romain Tartière <[email protected]> Signed-off-by: Peter Zhu <[email protected]>
…pensearch-project#3898) Signed-off-by: Romain Tartière <[email protected]> Signed-off-by: Peter Zhu <[email protected]>
Description
When installing OpenSearch from .deb or .rpm packages, the files permissions are unexpectedly relaxed allowing all local users to access all files from the OpenSearch, and allowing OpenSearch itself to update any file installed in the package.
This PR adjust the permissions so that the configuration, logs and data cannot be accessed by random users, and the application code cannot be updated by the opensearch user.
Issues Resolved
Fixes #3815