Conversation
This branch has not been deployed
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.
mtail turns fields captured from log lines into metric label values, and the graphite, statsd and collectd exporters serialize those into line-oriented push protocols through formatLabels. That helper only rewrites the key and label separator characters, so any other protocol-significant byte in a value passes straight through untouched. Those values are attacker-controlled: the bundled apache_combined program captures the HTTP User-Agent with [[:print:]]+, which includes spaces, and a captured request path or filename can carry a space or a control byte just as easily. In graphite a space ends the metric path early so the rest of the value is parsed as the numeric sample and timestamp, and an embedded newline emits a second, fully forged metric record on the same connection, which is enough to spoof arbitrary series on the backend. I noticed it while reading how the separators were being escaped and realised whitespace and control characters were never covered by that same pass. The fix replaces whitespace and control runes in both keys and values with the replacement string already used for the separators, kept inside formatLabels so graphite, statsd and collectd are all covered without changing their call sites.