Harden stunredis.sh by not using a local TCP port #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Your script is very helpful. However, it is not secure in a multiuser host. The script opens up a TCP port bound to the loopback device, which IMHO means that (at least without some ip[6]tables hardening) anyone on localhost can use the TCP port without having the cert and/or private key (in case of two-way trust TLS, which we use.
cert
andkey
instunnel
.). This might not seem relevant to (for example) a vagrant dev VM, but it's easy to avoid: just use a unix domain socket.stunnel
as well asredis-cli
supports it. As a bonus: the unix domain socket performs better as well.Sidenote:
stunnel
removes the socket file automatically, with a clean exit. Please judge yourself if a more resilient cleanup is needed (I don't think so, but could be wrong).