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

Adding logging.config.listen() plugin with examples #874

Merged
merged 5 commits into from Apr 2, 2022

Conversation

raj3shp
Copy link
Contributor

@raj3shp raj3shp commented Apr 2, 2022

Hi,
I would like to contribute a plugin based on Python's security consideration regarding logging.

The actual issue (usage of eval()) is when logging.config.fileConfig is called on an untrusted configuration file. However, it seems very obvious that configuration files are critical for security so will be write-protected to authorised users. The interesting attack vector is possible when an application exposes socket server to listen for configuration file from a network socket that a local attacker can exploit.

So this plugin checks for usage of logging.config.listen without verify argument which allows integrity checking or encryption/decryption capability to prevent abuse.

(all tox tests passed)

Copy link
Member

@ericwb ericwb left a comment

Choose a reason for hiding this comment

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

Thanks for the additional plugin. I've noted some things to correct.

Also, you'll need to add a doc under doc/source/plugins/b612_......

bandit/plugins/logging_config_insecure_listen.py Outdated Show resolved Hide resolved
bandit/plugins/logging_config_insecure_listen.py Outdated Show resolved Hide resolved
bandit/plugins/logging_config_insecure_listen.py Outdated Show resolved Hide resolved
bandit/plugins/logging_config_insecure_listen.py Outdated Show resolved Hide resolved
bandit/plugins/logging_config_insecure_listen.py Outdated Show resolved Hide resolved
@raj3shp raj3shp requested a review from ericwb April 2, 2022 19:23
Copy link
Contributor Author

@raj3shp raj3shp left a comment

Choose a reason for hiding this comment

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

Thanks for the review. I've pushed the changes. Cheers!

Copy link
Member

@ericwb ericwb left a comment

Choose a reason for hiding this comment

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

LGTM

@ericwb ericwb merged commit d2fa394 into PyCQA:main Apr 2, 2022
@raj3shp raj3shp deleted the logging_config_insecure_listen branch April 2, 2022 23:44
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.

None yet

2 participants