Skip to content

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

Merged
ericwb merged 5 commits intoPyCQA:mainfrom
raj3shp:logging_config_insecure_listen
Apr 2, 2022
Merged

Adding logging.config.listen() plugin with examples#874
ericwb merged 5 commits intoPyCQA:mainfrom
raj3shp:logging_config_insecure_listen

Conversation

@raj3shp
Copy link
Copy Markdown
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
Copy Markdown
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_......

Comment thread bandit/plugins/logging_config_insecure_listen.py Outdated
Comment thread bandit/plugins/logging_config_insecure_listen.py Outdated
Comment thread bandit/plugins/logging_config_insecure_listen.py Outdated
Comment thread bandit/plugins/logging_config_insecure_listen.py Outdated
Comment thread bandit/plugins/logging_config_insecure_listen.py
Comment thread bandit/plugins/logging_config_insecure_listen.py Outdated
Comment thread bandit/plugins/logging_config_insecure_listen.py
@raj3shp raj3shp requested a review from ericwb April 2, 2022 19:23
Copy link
Copy Markdown
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
Copy Markdown
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.

2 participants