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

Remove ENV environment variable from badenv table #267

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Conobi
Copy link

@Conobi Conobi commented May 23, 2023

The ENV variable was banned and not usable with sudo -E.
It doesn't serve any appropriate safety measure anymore, and by default (without --preserve-env=ENV) it can leads to issues passing the ENV variable, which is used in many CI/CD procedures to separate development/staging/production environments.

@millert
Copy link
Collaborator

millert commented May 23, 2023

Are you disabling env_reset in sudoers? If so, can't you just remove ENV from the env_delete list? If not I don't see why this would be a problem.

@Conobi
Copy link
Author

Conobi commented May 23, 2023

Are you disabling env_reset in sudoers? If so, can't you just remove ENV from the env_delete list? If not I don't see why this would be a problem.

No, I keep the env_reset enabled by default in my sudoers.
This problem happens when doing this:

$ FOO=production sudo -E env | grep "FOO"
FOO=production
$ ENV=production sudo -E env | grep "ENV"
# Returns nothing, because of the obsolete rule
$ ENV=production sudo -E --preserve-env=ENV env | grep "ENV"
ENV=production
# Returns the specified value, but a bit hacky and not documented

@millert
Copy link
Collaborator

millert commented Jun 21, 2023

If you need ENV to be preserved for "sudo -E" you can use a line like the following in sudoers:

Defaults env_delete -= ENV

Since setting ENV allows arbitrary commands to be run outside of sudo control I'm not convinced that it should be removed from the env_delete list.

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

Successfully merging this pull request may close these issues.

2 participants