hardening: validate EXTERNAL_RESOLVER as IP addresses - #384
Draft
dash14 wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
EXTERNAL_RESOLVERdecides where every allowed name is resolved, and its value is substituted straight into the generated HAProxy config and into/etc/resolv.conf. It was never checked to be an address, so a value carrying a newline could open a directive of its own in the file it landed in. Each engine now refuses anything that is not an IP address, and takes the container down with it rather than starting on a config it did not generate.Changes
universal:init-haproxy-cfgvalidates every entry before building thenameserverlines.inspect:init-inspect-cfgvalidates the list before handing it to the config generator.explicit:resolvConfis split out ofwriteResolvConfand validates each entry withnetip.ParseAddr.universalandinspectpreviously disagreed on.Test plan
binddirective takes the container down at startup with a message naming the offending entry, instead of reaching the config.