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

[Fleet] GET fleet/agent_policies returns space ids unavailable to the user #201400

Open
jillguyonnet opened this issue Nov 22, 2024 · 1 comment
Labels
bug Fixes for quality problems that affect the customer experience Team:Fleet Team label for Observability Data Collection Fleet team

Comments

@jillguyonnet
Copy link
Contributor

This was discovered while investigating #193827.

Description

GET fleet/agent_policies always returns all space ids assigned to each agent policy. This means that a user with access to only some of these spaces is able to see the ids of unavailable spaces.

In contrast, GET fleet/agent_policies/<policyId> returns ? for space ids unavailable to the user.

Expectation

GET fleet/agent_policies should return ? for unavailable spaces.

Explanation

This difference comes from the Saved Object API.

GET fleet/agent_policies is handled by agentPolicy.list, which uses soClient.find, which returns all the space ids:

agentPoliciesSO = await soClient.find<AgentPolicySOAttributes>({
...baseFindParams,
filter,
});

In contrast, GET fleet/agent_policies/<policyId> is handled by agentPolicy.get, which uses soClient.get, which returns ? for unavailable space ids:

const agentPolicySO = await soClient.get<AgentPolicySOAttributes>(savedObjectType, id);

Steps to reproduce

  1. Define a custom space (Space1).
  2. Create an agent policy and assign it to the Default and Space1 spaces.
  3. Create a role with Kibana access to Space1 only.
  4. Create a user with that role.
  5. Log in with the user and check the output of these requests in Dev Tools:

GET fleet/agent_policies

{
...
      "space_ids": [
        "default",
        "space1"
      ],
...
}

GET fleet/agent_policies/<policyId>

{
...
      "space_ids": [
        "space1",
        "?"
      ],
...
}
@jillguyonnet jillguyonnet added bug Fixes for quality problems that affect the customer experience Team:Fleet Team label for Observability Data Collection Fleet team labels Nov 22, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Team:Fleet Team label for Observability Data Collection Fleet team
Projects
None yet
Development

No branches or pull requests

2 participants