Skip to content

fix: log denied requests for unmatched L7 endpoint paths #2898

Description

@wtrep

User Story

As an OpenShell operator using multiple protocol: rest endpoint objects that share one host and port but use distinct path HTTP path globs, I want requests outside those endpoint paths to produce a corresponding HTTP denial log event, so that I can audit blocked sandbox egress and diagnose policy mismatches.

Problem Statement

When a network policy entry has multiple protocol: rest endpoint objects that share a host and port, an HTTP request whose path matches none of those endpoint objects' path HTTP path globs is correctly blocked with HTTP 403. However, openshell logs has no corresponding HTTP:* DENIED OCSF/shorthand event.

The log appears when REST rules deny a request. It is missing only when the request matches no endpoint path.

Impact / Why This Matters

Operators see an allowed network connection followed by an application-level 403 but cannot see the L7 policy decision that explains why it was blocked. This creates an incomplete audit trail and makes policy troubleshooting depend on manually comparing configured endpoint path HTTP path globs and REST allow rules against the application's request path.

Acceptance Criteria

  • A request whose path matches no configured L7 endpoint object's path HTTP path glob remains blocked with HTTP 403 and is not forwarded upstream.
  • openshell logs emits a redacted HTTP:<method> … DENIED OCSF/shorthand event for the endpoint-path-selection miss, consistent with existing L7 policy denials.

Reproduction Steps

  1. Save this complete policy as unmatched-path-repro.yaml:
version: 1

filesystem_policy:
  include_workdir: true
  read_only: [/usr, /lib, /proc, /dev/urandom, /app, /etc, /var/log]
  read_write: [/tmp, /dev/null]
landlock:
  compatibility: best_effort

network_policies:
  github_path_scopes:
    name: github-path-scopes
    endpoints:
      - host: api.github.com
        port: 443
        path: /repos/NVIDIA/OpenShell/pulls/**
        protocol: rest
        enforcement: enforce
        rules:
          - allow:
              method: GET
              path: /repos/NVIDIA/OpenShell/pulls/**
      - host: api.github.com
        port: 443
        path: /repos/NVIDIA/OpenShell/commits/**
        protocol: rest
        enforcement: enforce
        rules:
          - allow:
              method: GET
              path: /repos/NVIDIA/OpenShell/commits/**
    binaries:
      - { path: /usr/bin/curl }
  1. Create a disposable sandbox with that policy:
openshell sandbox create --name l7-path-log-repro --policy unmatched-path-repro.yaml --no-auto-providers --no-tty -- sleep infinity
  1. Request the issues endpoint, whose path matches neither endpoint object's path HTTP path glob:
openshell sandbox exec --name l7-path-log-repro -- curl -i --max-time 20 https://api.github.com/repos/NVIDIA/OpenShell/issues
  1. Observe an explicit local HTTP/1.1 403 Forbidden response with detail: no L7 endpoint path matched request.
  2. Inspect sandbox logs:
openshell logs <sandbox-name>
  1. Observe an allowed connection-level event for curl but no corresponding HTTP denial event for the issues request.

Environment

  • OpenShell: 0.0.111 (openshell --version)
  • Host OS: macOS 26.6.2 (build 25G83, Apple Silicon)
  • Runtime: Docker Engine 29.7.2 (client and server), Docker-backed local sandbox
  • Deployment or integration: local gateway; ghcr.io/nvidia/openshell-community/sandboxes/base:latest; custom network policy entry with two protocol: rest endpoint objects sharing api.github.com:443; /usr/bin/curl requesting GET /repos/NVIDIA/OpenShell/issues

Logs

# Application result
HTTP/1.1 403 Forbidden
X-OpenShell-Policy: github_path_scopes

{
  "detail": "no L7 endpoint path matched request",
  "error": "policy_denied",
  "host": "api.github.com",
  "layer": "l7",
  "method": "GET",
  "path": "/repos/NVIDIA/OpenShell/issues",
  "port": 443,
  "protocol": "rest"
}

# Present connection-level event
NET:OPEN [INFO] ALLOWED /usr/bin/curl(...) -> api.github.com:443 \
  [policy:github_path_scopes engine:opa]

# Expected after the fix; currently absent
# HTTP:GET [MED] DENIED GET http://api.github.com:443/repos/NVIDIA/OpenShell/issues \
#   [policy:github_path_scopes engine:l7] \
#   [reason:L7_REQUEST deny GET api.github.com:443/repos/NVIDIA/OpenShell/issues reason=no L7 endpoint path matched request]

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:sandboxSandbox runtime and isolation workarea:supervisorProxy and routing-path workstate:validatedtopic:l7Application-layer policy and inspection worktopic:observabilityLogging, metrics, and observability work

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions