Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NET-11737 - sec vulnerability - remediate ability to use bexpr to filter results without ACL read on endpoint #21950

Merged
merged 3 commits into from
Nov 20, 2024

Conversation

jmurret
Copy link
Member

@jmurret jmurret commented Nov 18, 2024

Description

Allows bexpr filters constructed from user input only on data that the user is authorized to read.

Effect on the meaning X-Consul-Results-Filtered-By-ACLs when used with filter

With this change, when using the filter query parameter, the meaning of X-Consul-Results-Filtered-By-ACLs changes in the following way:

  • currently it means there are other resources that you do not have access to that match your filter
  • the new meaning will be there are other resources that you do not have access to that may or may not match your filter

In essence, the X-Consul-Results-Filtered-By-ACLs header response as though there was no filter.

Let's assume this set up:

  • 10 Intentions exist
  • 5 of them have a DestinationName starting with web-
  • filter query param is set to:
DestinationName+matches+`web-.*`
  • the ACL token has read access to 1 intention with a DestinationName of api-2

In the current implementation on the main branch, you would have this logic flow:

  • filter param gets 0 of the 10 intentions
  • ACL filter then operates on an empty array and leaves X-Consul-Results-Filtered-By-ACLs set to false
  • response has zero items and X-Consul-Results-Filtered-By-ACLs is set to false

In changing the logic, the flow would now be:

  • ACL filter then removes 5 items and sets the X-Consul-Results-Filtered-By-ACLs to true
  • filter param then matches zero results
  • response has zero items and X-Consul-Results-Filtered-By-ACLs is set to true
  • at this point, X-Consul-Results-Filtered-By-ACLs indicates there are more resources that the token has access to, but there is no guarantee that the filter query parameter would filter them out.

We will need to document this in our docs as well as the change in behavior in our changelog.

Testing & Reproduction steps

List of Effected Code

Based on GitHub

These references show up in the search for go-expr used in the vulnerability report, but do not create and run filters, they only use an evaluator to validate the syntax is valid and do not expose object data:

PR Checklist

  • updated test coverage
  • external facing docs updated
  • appropriate backport labels added
  • not a security concern

@jmurret jmurret added backport/ent/1.15 Changes are backported to 1.15 ent backport/ent/1.18 Changes are backported to 1.18 ent backport/1.20 Changes are backported to 1.20 backport/ent/1.19 Changes are backported to 1.19 ent labels Nov 18, 2024
@@ -22,33 +21,6 @@ import (
"github.com/hashicorp/consul/agent/structs"
)

var ConfigSummaries = []prometheus.SummaryDefinition{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

random unused code in the file I was modifying.

@jmurret jmurret marked this pull request as ready for review November 19, 2024 00:02
@jmurret jmurret requested review from a team as code owners November 19, 2024 00:02
Copy link
Member

@sarahalsmiller sarahalsmiller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a big one to cover, thanks for tackling it and adding tests.

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @jmurret! a backport is missing for this PR [21950] for versions [1.15,1.18,1.19,1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/ent/1.15 Changes are backported to 1.15 ent backport/ent/1.18 Changes are backported to 1.18 ent backport/ent/1.19 Changes are backported to 1.19 ent backport/1.20 Changes are backported to 1.20
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants