Repository navigation
cf-execd: Rejected runagent socket requests injecting cf-runagent args - #6506
Open
Dhanu-dynamic wants to merge 1 commit into
Open
Dhanu-dynamic wants to merge 1 commit into
Dhanu-dynamic wants to merge 1 commit into
Conversation
HandleRunagentRequest() reads one line from runagent.socket, the host to
hail, and for a non-localhost request builds the command
<bindir>/cf-runagent -b -H <request>
which cf_popen() runs as root after ArgSplitCommand() splits it into argv
on whitespace, treating quotes as delimiters. The request was used
verbatim, so one containing a space, tab or quote appends further
arguments to cf-runagent. A caller allowed on the socket through
runagent_socket_allow_users (cfapache on an Enterprise hub) is only meant
to pick a host, but a request like "host -f /tmp/evil.cf" makes
cf-runagent load another policy as root, and injected "-D", "-s" or
"--remote-bundles" reach the remote agents, which the socket interface is
documented not to allow. There is no shell, so this is argument injection,
not command injection.
Refuse any request containing whitespace or a quote character before
building the command, which no host name, IP, host:port or comma-separated
host list contains. The same JSON error reply as the other failure paths
is sent.
Changelog: Title
Signed-off-by: Dhanraj E <dhanraj@labs.digiscrypt.com>
|
Thank you for submitting a PR! Maybe @craigcomstock can review this? |
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.
HandleRunagentRequest() reads one line from runagent.socket, the host to
hail, and for a non-localhost request builds the command
which cf_popen() runs as root after ArgSplitCommand() splits it into argv
on whitespace, treating quotes as delimiters. The request was used
verbatim, so one containing a space, tab or quote appends further
arguments to cf-runagent. A caller allowed on the socket through
runagent_socket_allow_users (cfapache on an Enterprise hub) is only meant
to pick a host, but a request like "host -f /tmp/evil.cf" makes
cf-runagent load another policy as root, and injected "-D", "-s" or
"--remote-bundles" reach the remote agents, which the socket interface is
documented not to allow. There is no shell, so this is argument injection,
not command injection.
Refuse any request containing whitespace or a quote character before
building the command, which no host name, IP, host:port or comma-separated
host list contains. The same JSON error reply as the other failure paths
is sent.