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

Permission Check on Log Access via UI #23786

Closed
Mac2 opened this issue Aug 9, 2024 · 1 comment · Fixed by #24973
Closed

Permission Check on Log Access via UI #23786

Mac2 opened this issue Aug 9, 2024 · 1 comment · Fixed by #24973

Comments

@Mac2
Copy link

Mac2 commented Aug 9, 2024

Nomad version

Nomad v1.8.2
BuildDate 2024-07-16T08:50:09Z
Revision 7f0822c

Operating system and Environment details

RHEL 8.6 - RHEL 8.8

Issue

When trying to access the Container Logs via "UI -> Jobname -> Taskgroup -> Allocation -> Task -> Logs" we get a "permission denied" error.
But the current policy should allow access because of "namespace:write" policy:

namespace "playground" {
  policy = "write"
  variables {
  	# give read access to all job templates related to this namespace
    path "nomad/job-templates/*" {
      capabilities = ["read","list"]
    }
  }
}
node {
  policy = "deny"
}
agent {
  policy = "deny"
}

We can prove this because log access via "UI -> Job -> View Logs (of the task)" is working as expected and if we change the policy to

node {
  policy = "read"
}
agent {
  policy = "deny"
}

accecss to logs is working also as expected. So it looks like the UI-Button is not checking correctly for the "namespace:read-logs" capability, but instead for a "node:read" policy.

Reproduction steps

Using Policy like:

namespace "playground" {
  policy = "write"
  variables {
  	# give read access to all job templates related to this namespace
    path "nomad/job-templates/*" {
      capabilities = ["read","list"]
    }
  }
}

# used for UI Access - nicht wirklich ?
node {
  policy = "deny"
}
agent {
  policy = "deny"
}
  1. trying to access logs of running container via "Jobs -> -> View Logs (in recent allocations tab)"

  2. trying to access logs of running container via "Jobs -> -> TaskGroup -> Allocation -> Task -> Logs (on top menu line)"

Expected Result

  1. Access to logs is possible (depending on namespace:read-logs capability)
  2. Access to logs is possible (depending on namespace:read-logs capability)

Actual Result

  1. Access works as expected
  2. Access is denied due to node-policy=deny

Job file (if appropriate)

Nomad Server logs (if appropriate)

Nomad Client logs (if appropriate)

thanks
Mac

@Mac2 Mac2 added the type/bug label Aug 9, 2024
@tgross
Copy link
Member

tgross commented Aug 9, 2024

Hi @Mac2! Sometimes the UI needs a bit more permissions than the CLI does because it enriches the view from other sources. But I just checked myself and the only API request being sent is /v1/client/fs/logs/$alloc_id?follow=true&offset=50000&origin=end&task=task&type=stdout. But if I send that API request with a token that has a policy without node = "read" I do get the logs. So it looks like this issue is at the UI layer. I'll bring this to the attention of the folks focused on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants