Skip to content
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

add deprecation warning for allow_superuser: true #16555

Open
wants to merge 2 commits into
base: 8.x
Choose a base branch
from

Conversation

kaisecheng
Copy link
Contributor

@kaisecheng kaisecheng commented Oct 15, 2024

Release notes

Add deprecation warning to allow_superuser: true. Starting from version 9, this will be disabled by default. To avoid disruption during the upgrade, set 'allow_superuser' to true now if you wish to continue running as superuser temporarily after the upgrade.

What does this PR do?

  • add deprecation warning when the current user id is 0 and allow_superuser is unset
  • refactor existing deprecation log

Why is it important/What is the impact to the user?

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files (and/or docker env variables)
  • I have added tests that prove my fix is effective or that my feature works

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Use cases

Screenshots

Logs

Comment on lines +486 to +489
deprecation_logger.deprecated("WARNING: You are currently running Logstash with superuser privileges. " +
"Starting from version 9, this will be disabled by default. " +
"To avoid disruption during the upgrade, set 'allow_superuser' to true now if you wish to continue running as superuser temporarily after the upgrade. " +
"Note that this is not recommended for security reasons.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would a bit simplify the statement.

Suggested change
deprecation_logger.deprecated("WARNING: You are currently running Logstash with superuser privileges. " +
"Starting from version 9, this will be disabled by default. " +
"To avoid disruption during the upgrade, set 'allow_superuser' to true now if you wish to continue running as superuser temporarily after the upgrade. " +
"Note that this is not recommended for security reasons.")
deprecation_logger.deprecated("WARNING: You are currently running Logstash with superuser privileges which is not recommended for security reasons. " +
"Starting from version 9, this will not be allowed by default unless 'allow_superuser' is intentionally set to true.")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karenzone could you suggest how to do the deprecation communication? We want to suggest user to set 'allow_superuser' to true now for preparing v9 upgrade. The setting is optional at this moment, I am not sure how to deliver the message.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karenzone We are changing the behaviour when someone attempts to run Logstash as a superuser.

Running Logstash as a superuser is not recommended for security reasons, as it breaks the "Principle of Least Privilege", and increases any potential attack surface.

The current behaviour is to allow users to run as as a superuser by default, adding a setting allow_superuser:false to lock that down that has to be done specifically, potentially leading to a situation where Logstash could be run as root inadvertently.

In 9.0, we are going to switch the behaviour such that it has to be a conscious decision to allow Logstash to be run as a "superuser" that the user has to allow explicitly by setting allow_superuser to true

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the ping and clarification, @kaisecheng and @robbavey. I'll take a look.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the question and the additional clarification. It seems like @mashhurs is on the right track with his suggestion. I started with his suggestion and iterated on it.

Does this achieve your goals:

"Starting from version 9, running with superuser privileges is not permitted unless you explicitly set 'allow_superuser' to true, thereby acknowledging the possible security risks."

If not, please let me know and we'll get it right.

if setting("allow_superuser")
deprecation_logger.deprecated("NOTICE: Running Logstash as superuser is not recommended and won't be allowed in the future. Set 'allow_superuser' to 'false' to avoid startup errors in future releases.")
deprecation_logger.deprecated("NOTICE: Running Logstash as superuser will be completely disallowed in future versions. " +
"To prepare for this and avoid startup errors in future releases, it is strongly recommended to set 'allow_superuser' to false now " +
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karenzone please also consider this message. Both deprecation logs can print together.

@karenzone karenzone self-requested a review October 18, 2024 19:51
Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

@jsvd jsvd self-requested a review October 28, 2024 09:51
Copy link
Contributor

@karenzone karenzone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some suggested text for your consideration. Please let me know if this achieves your goals. If not, we'll take another shot at it.

Comment on lines +486 to +489
deprecation_logger.deprecated("WARNING: You are currently running Logstash with superuser privileges. " +
"Starting from version 9, this will be disabled by default. " +
"To avoid disruption during the upgrade, set 'allow_superuser' to true now if you wish to continue running as superuser temporarily after the upgrade. " +
"Note that this is not recommended for security reasons.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the question and the additional clarification. It seems like @mashhurs is on the right track with his suggestion. I started with his suggestion and iterated on it.

Does this achieve your goals:

"Starting from version 9, running with superuser privileges is not permitted unless you explicitly set 'allow_superuser' to true, thereby acknowledging the possible security risks."

If not, please let me know and we'll get it right.

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

Successfully merging this pull request may close these issues.

6 participants