Skip to content

🐛 Openshell sandboxes can't access internal cluster services #1647

Closed

Description

@esnible

Describe the bug

Comments on the sandbox policy deployments/openshell/agents/claude-sdk-agent/policy-data.yaml indicate it can be used to enable sandbox-to-in-cluster communication, but it can't.

For example, curl httpbin.team1.svc.cluster.local:8080/status/418 is denied.

Steps To Reproduce

  • openshell sandbox create --policy deployments/openshell/agents/claude-sdk-agent/policy-data.yaml --name try-sandbox -- bash
  • (in second window) openshell sandbox get try-sandbox --policy-only
  • (in second window) oc -n team1 logs try-sandbox -f | grep DENIED
  • (in OpenShell window) curl httpbin.team1.svc.cluster.local:8080/status/418
    • receive {"detail":"GET httpbin.team1.svc.cluster.local:8080/status/418 not permitted by policy","error":"policy_denied"}
    • logged OCSF HTTP:GET [MED] DENIED -(0) -> GET http://httpbin.team1.svc.cluster.local:8080/status/418 [policy:- engine:opa] [reason:FORWARD denied GET httpbin.team1.svc.cluster.local:8080/status/418]
  • (in OpenShell window) curl httpbin.team1:8080/status/418
    • receive {"detail":"GET httpbin.team1:8080/status/418 not permitted by policy","error":"policy_denied"}
    • logged CSF HTTP:GET [MED] DENIED -(0) -> GET http://httpbin.team1:8080/status/418 [policy:- engine:opa] [reason:FORWARD denied GET httpbin.team1:8080/status/418]

Expected Behavior

A policy for in-cluster communications should be provided, and it should allow in-cluster communications.

Additional Context

  • Sandboxes start with an $HTTP_PROXY but I have this problem either way.
  • Adding explicit entries for hosts I wish to make available, such as otel-collector.kagenti-system.svc.cluster.local, also fail, so the problem is not wildcards.
  • The rules in deployments/openshell/agents/claude-sdk-agent/policy-data.yaml seem wrong, the refer to "*.svc.cluster.local" not "**.svc.cluster.local"
  • Note that there doesn't need to be a running httpbin service in the cluster to reproduce the problem -- outbound is blocked for any hostname with the same message.
  • Note that the endpoint *.team1 will prevent the shell from even starting -- OpenShell treats "team1" as a TLD, which is confusing.

Activity

  1. added
    kind/bug
    on May 22, 2026
  2. self-assigned this
    on May 22, 2026
  3. esnible commented on May 22, 2026

    @esnible
    MemberAuthor

    Note that https://github.com/kagenti/OpenShell provides many tests, but no native OPA tests, no *_test.rego files, no opa test --coverage, making it hard to determine which OPA files are blocking the traffic.

    To test this issue, I removed all the internal rules and added a policy specific to this issue:

    network_policies:
      internal:
        name: "Allow internal cluster services"
        # Note that an endpoint without a binaries list will deny everything; this allows any
        binaries:
        # Note that we allow everything; we can lock this to claude instead
        - { path: /** }
        # - { path: /usr/local/bin/claude }
        endpoints:
          - host: httpbin.team1
            port: 8080
          # Trying to get around "DENIED -(0) -> GET http://httpbin.team1:8080/status/418"
          - host: httpbin.team1.svc.cluster.local
            port: 8080

    This shows that even with zero endpoint wildcards and a binary wildcard, policy is blocked in the same way with the same message.

    Without OPA tests, it feels difficult to maintain them, and to ask Claude how to fix policy YAML to allow the desired traffic.

  4. Ladas commented on May 27, 2026

    @Ladas
    Contributor

    This directly affects our PR #1498 — the same policy file (deployments/openshell/agents/claude-sdk-agent/policy-data.yaml) uses *.svc.cluster.local wildcards that don't match in the OPA evaluator.

    Root cause: the OPA rego at sandbox-policy.rego uses glob.match() where * matches a single path segment (no dots). *.svc.cluster.local won't match litellm-model-proxy.team1.svc.cluster.local because there are multiple dot-separated segments before .svc.

    Fix options:

    1. Use **.svc.cluster.local (if OPA glob supports **)
    2. Use explicit hostnames per service: litellm-model-proxy.team1.svc.cluster.local
    3. Fix the OPA rego to use a regex or substring match instead of glob

    In our PR we work around this by having the supervisor not enforce network policy on the sandbox base image (teleport sandboxes use sleep 3600 command, not the supervised entry point). But for production agents (claude-sdk-agent, adk-agent), this blocks in-cluster LLM access.

    Related: #1669 (port vs ports normalization)

  5. added a commit that references this issue on May 27, 2026
    3cf1459
  6. esnible commented on May 27, 2026

    @esnible
    MemberAuthor

    @Ladas , I agree. The changes suggested work when I test the code using

    regorus eval \
      -d crates/openshell-sandbox/data/sandbox-policy.rego \
      -d ecs-example-policy-data.yaml \
      -i ecs-example-opa-input.yaml \
      'data.openshell.sandbox.deny_reason'

    Although local testing of the policy worked, it didn't work within the Sandbox, which suggests something is being modified as part of normalization.

  7. removed their assignment
    on May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions