I've recently seen bandit complaining about B104:
Binding to all network interfaces can potentially open up a service to traffic on unintended interfaces, that may not be properly documented or secured. This plugin test looks for a string pattern “0.0.0.0” that may indicate a hardcoded binding to all network interfaces.
>> Issue: Possible binding to all interfaces.
Severity: Medium Confidence: Medium
Location: ./examples/binding.py:4
3 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
4 s.bind(('0.0.0.0', 31137))
5 s.bind(('192.168.0.1', 8080))
What does it mean to "open up a service to traffic on unintended interfaces"?
I've seen this for a Flask application with app.run(host="0.0.0.0")
. What should one write instead?
(As a sidenote: This is not used in production. This is mainly for simply testing during development. But I'm uncertain if gunicorn might have the same issue with a similar configuration)