Skip to content

Conversation

@blueberry-pi
Copy link
Contributor

@blueberry-pi blueberry-pi commented May 8, 2025

Description

As reported in VAULT-35716, policies created with allowed_parameters or denied_parameters do not work as expected if the request assigns a list of values to the allowed/denied parameter instead of a single value.

eg. with a policy:

path "identity/group" {
  capabilities = ["create", "update", "list", "read"]
  denied_parameters = {
    "name" = ["admin_group_*", "ADMIN_GROUP_*", "admin_automation", "ADMIN_AUTOMATION"]
    "policies" = ["*admin-automation-policy*", "*admin-policy*"]    
    
  }
}

a request with parameters {"name":"test_policy_list","policies": ["admin-policy", "admin-automation-policy"], "type": "external"}' should be denied but is allowed because we do not expect policies could be a list of values and attempt to compare the entirety of it as a single value against *admin-automation-policy* and then against *admin-policy*.

AFAICT nothing in our documentation prohibits using a list of values, but we do not handle the case. This PR checks if the input is a slice type, and if so, iterates through it so each value in the slice is being checked against the allow/deny list.

TODO only if you're a HashiCorp employee

  • Backport Labels: If this fix needs to be backported, use the appropriate backport/ label that matches the desired release branch. Note that in the CE repo, the latest release branch will look like backport/x.x.x, but older release branches will be backport/ent/x.x.x+ent.
    • LTS: If this fixes a critical security vulnerability or severity 1 bug, it will also need to be backported to the current LTS versions of Vault. To ensure this, use all available enterprise labels.
  • ENT Breakage: If this PR either 1) removes a public function OR 2) changes the signature
    of a public function, even if that change is in a CE file, double check that
    applying the patch for this PR to the ENT repo and running tests doesn't
    break any tests. Sometimes ENT only tests rely on public functions in CE
    files.
  • Jira: If this change has an associated Jira, it's referenced either
    in the PR description, commit message, or branch name.
  • RFC: If this change has an associated RFC, please link it in the description.
  • ENT PR: If this change has an associated ENT PR, please link it in the
    description. Also, make sure the changelog is in this PR, not in your ENT PR.

@blueberry-pi blueberry-pi requested a review from a team as a code owner May 8, 2025 00:17
@blueberry-pi blueberry-pi requested a review from ldilalla-HC May 8, 2025 00:17
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label May 8, 2025
@blueberry-pi blueberry-pi force-pushed the vault-35716-acl-list-fix branch from ad25ea6 to 487dcd8 Compare May 8, 2025 00:32
@github-actions
Copy link

github-actions bot commented May 8, 2025

CI Results:
All Go tests succeeded! ✅

@github-actions
Copy link

github-actions bot commented May 8, 2025

Build Results:
All builds succeeded! ✅

@@ -0,0 +1,4 @@
```release-note:bug
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm treating this as a bug though it's unclear if we intended for this to work. Let me know if it fits better as an improvement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to change since it is a difference in behavior that could cause previously passing requests to now fail

@blueberry-pi blueberry-pi requested a review from Copilot May 14, 2025 08:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the issue where policy parameter checks fail when a parameter value is provided as a list. Key changes include updating the test cases to use a map-based structure for parameters and refactoring the parameter matching logic to correctly handle slice types for both allowed and denied policy assertions.

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
vault/acl_test.go Updated test cases to support map-based parameters and additional slice test scenarios.
vault/acl.go Refactored parameter matching functions to distinguish between allowed and denied lists and handle slice types appropriately.
Files not reviewed (1)
  • changelog/30551.txt: Language not supported

}

func valueInParameterList(v interface{}, list []interface{}) bool {
func valueInAllowedParameterList(v interface{}, list []interface{}) bool {
Copy link

Copilot AI May 14, 2025

Choose a reason for hiding this comment

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

[nitpick] The recursive use of valueInParameterList inside valueInAllowedParameterList may cause confusion. Consider renaming or refactoring the helper functions to clearly separate slice handling from single value comparisons.

Copilot uses AI. Check for mistakes.
}

func valueInSlice(v interface{}, list []interface{}) bool {
func valueInDeniedParameterList(v interface{}, list []interface{}) bool {
Copy link

Copilot AI May 14, 2025

Choose a reason for hiding this comment

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

[nitpick] The similar recursion pattern in valueInDeniedParameterList using valueInParameterList could be refactored for improved clarity. Clarifying the distinct handling for slices versus single values would enhance maintainability.

Copilot uses AI. Check for mistakes.
@blueberry-pi
Copy link
Contributor Author

Closing for now as making changes to how policies behave will require more in-depth discussions with engineering and product

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed pr/no-milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant