aws: Fix improper url substring validation #9174
Open
+34
−4
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.
Cloud Custodians base notifier is susceptible to an improper URL string validation which may allow an attacker to trick Cloud Custodian into leaking data by sending messages to URLs under the attackers control. The issue allows an attacker who can add items to the transport queue to control the URL that the base notifier sends payloads to. Besides the potential for leaking data, an attacker could also manipulate subsequent workflow by crafting a malicious response to Cloud Custodian.
The issue requires high privileges to exploit: Permissions to deploy policies are necessary.
The issue lies in the two first branches of
send_sqs
. Assuming that an attacker can control thequeue
variable defined on line 384, they can get past the first conditional check on line 385-387 ifqueue
does not start with the stringhttps://queue.amazonaws.com
. The second conditional checks whetherqueue.amazonaws.com
is a substring ofqueue
. An attacker can bypass that in a number of ways, either by crafting a subdomain of their own domain, for examplequeue.amazonaws.com.malicious-url.cc
, or by including a URL parameter, for example:malicious-url.cc?queue.amazonaws.com
. The conditional check on line 388 will return true andqueue_url
will be assigned the attackers URL.send_sqs
will proceed to line 407, and the client will sent the message to the attacker-controlled URL on line 416.This PR fixes that by changing the conditional check for the URL validation.