Skip to content

feat(providers): support request-scoped provider credentials for existing sandboxes #1883

Closed as not planned

Description

@rohancmr

Problem Statement

Some platforms create OpenShell sandboxes for interactive AI-agent workflows where credentials are resolved at request time.

The sandbox may be created first, and then a user request arrives with identity or credential material that is specific to that request. The platform may then exchange the user identity or request headers for short-lived service credentials, such as:

  • GitLab tokens
  • Jira or Confluence tokens
  • MaaS service tokens
  • MCP server credentials
  • SSO JWT-derived service credentials
  • workflow-specific headers or secrets

These credentials are scoped to one user, one request, one conversation, or one session. They should not become permanent sandbox credentials, and they should not be shared with other users or later requests.

Today, providers are attached to a sandbox at sandbox creation time. That works when credentials are known before CreateSandbox, but it does not fit request-time credential flows.

OpenShell should support attaching temporary provider credentials to an existing sandbox after it has been created.

Proposed Design

Add support for request-scoped or session-scoped provider credentials on existing sandboxes.

OpenShell should allow a trusted caller to attach temporary provider credentials to a sandbox after CreateSandbox.

Conceptual flow:

1. Platform receives a user request.
2. Platform creates an OpenShell sandbox.
3. Platform resolves user-specific credentials.
4. Platform attaches those credentials to the existing sandbox for a specific request/session.
5. Sandbox supervisor uses those credentials through the existing provider/proxy injection model.
6. Credentials expire or are removed when the request/session ends.

Possible API shape:

sandbox_id: sandbox-abc123
session_id: conversation-456
ttl_seconds: 3600
providers:
  - name: gitlab-user-token
    provider_type: gitlab
    credentials:
      GITLAB_TOKEN:
        source:
          type: inlineSecret
          value: "<redacted>"

Or with a Secret-backed source:

sandbox_id: sandbox-abc123
session_id: conversation-456
ttl_seconds: 3600
providers:
  - name: gitlab-user-token
    provider_type: gitlab
    credentials:
      GITLAB_TOKEN:
        source:
          type: kubernetesSecret
          namespace: openshell-system
          name: user-session-credentials
          key: gitlab-token

The exact API shape can be decided by OpenShell maintainers. The important requirement is that provider credentials can be attached after sandbox creation and scoped to a bounded request/session lifetime.

Required Behavior

OpenShell should support:

  • Attaching provider credentials to an existing sandbox after CreateSandbox.
  • Scoping credentials to a request, conversation, or session identifier.
  • Enforcing a server-side TTL for those credentials.
  • Removing or invalidating credentials when the request/session ends.
  • Preventing credentials from one request/session from being visible to another.
  • Auditing which caller attached which provider credentials to which sandbox/session.
  • Supporting credentials sourced from inline secret material, Kubernetes Secrets, existing provider records, or future brokered credential flows.

Security Requirements

  • Request-scoped credentials must fail closed if they are missing, expired, or unauthorized.
  • Credentials must not appear in logs, events, list responses, or audit output.
  • A caller should only be able to attach credentials that OpenShell policy allows.
  • Credentials from one user/request/session must not be reused by another.
  • TTL must be enforced server-side.
  • On session end, credentials should be deleted or made unusable.
  • The child agent process should continue to receive placeholders where possible, with the supervisor/provider layer performing controlled credential injection.

Why This Is Needed

Many interactive agent systems resolve credentials only after receiving a user request.

For example, a platform may receive a request with a user SSO identity, exchange that identity for short-lived GitLab or Jira credentials, and then run an agent task inside an OpenShell sandbox.

Those credentials are not always known before sandbox creation. They may also be valid only for a short period and only for that user's request.

Without this feature, platforms must choose one of the following workarounds:

  • create all provider credentials before sandbox creation,
  • store short-lived user credentials as normal OpenShell provider records,
  • write raw secrets into a .env file inside the sandbox,
  • pass credentials directly as environment variables,
  • or keep a separate router-side credential injection system outside OpenShell.

Those options are harder to secure and harder to operate than using OpenShell's existing supervisor/provider credential injection model with request-scoped credential lifecycle support.

Example Use Case

A user starts an AI coding session that needs GitLab and Jira access.

The platform receives the request, authenticates the user, and exchanges the user identity for short-lived service tokens.

The platform creates an OpenShell sandbox and then attaches those credentials to the sandbox for the current conversation:

For sandbox sandbox-abc123 and session conversation-456,
make these GitLab and Jira provider credentials available only for this session.
Expire them after 1 hour or when the session is released.

The OpenShell supervisor should then use those credentials through the existing provider/proxy credential injection model.

Alternatives Considered

Attach all providers at sandbox creation time

This works only when credentials are known before CreateSandbox. It does not fit request-time identity exchange or per-request credentials.

Store user credentials as permanent OpenShell provider records

This is not ideal for short-lived, user-specific credentials. It increases credential lifecycle burden and can leave stale credentials behind.

Write a .env file into the sandbox

This works for simple runtimes, but it exposes raw credential values directly to the child process. OpenShell's supervisor/provider injection model is safer and should be used instead.

Pass credentials directly as environment variables

This has similar problems to .env: the child process receives raw credential values directly, and cleanup becomes harder.

Agent Investigation

I reviewed OpenShell's current provider and sandbox flow:

  • Providers are attached to a sandbox through SandboxSpec.providers.
  • Provider credentials are resolved by the gateway and delivered to the sandbox supervisor through the provider environment flow.
  • The sandbox supervisor already supports credential injection through provider placeholders and proxy rewriting.
  • The missing capability is not the injection mechanism. The missing capability is credential lifecycle and scope: credentials need to be attachable after sandbox creation and bounded to a specific request/session.

Checklist

  • I have searched existing issues for related provider and credential lifecycle requests.
  • This is a design proposal, not only a request to build a feature.

Activity

  1. drew commented on Jun 12, 2026

    @drew
    Collaborator

    It's already possible today to attach providers to existing sandboxes, https://docs.nvidia.com/openshell/latest/sandboxes/providers-v2#attach-and-detach-providers. Can you expand on what's currently missing?

  2. rohancmr commented on Jun 15, 2026

    @rohancmr
    Author

    Thanks, that makes sense. The missing piece is not the ability to attach an existing Provider to an existing sandbox.

    The gap is credential lifecycle, source, and scope.

    In the flow I am describing, the Provider credentials may not exist when the sandbox is created, and may not exist as a normal long-lived OpenShell Provider record at all. They are derived at request time from the caller identity or request headers, for example by exchanging an SSO/JWT identity for short-lived GitLab/Jira/MaaS/MCP credentials.

    So the ask is for a first-class way to create or bind temporary provider credential material to an existing sandbox/request/session, with server-side TTL, ownership, audit, cleanup, and authorization.

    If the intended pattern is:

    1. create an ephemeral Provider,
    2. attach it to the existing sandbox,
    3. use it for one request/session,
    4. detach it,
    5. delete or expire it,

    then the missing pieces are the lifecycle guarantees around that pattern: TTL, cleanup, audit, preventing accidental reuse, and making sure the temporary credential material does not behave like a normal durable provider record.

    I can update the issue wording to make it clear that attach/detach exists today, and that this request is specifically about request-scoped credential lifecycle on top of that.

  3. grs commented on Jun 15, 2026

    @grs
    Contributor

    This may also be of interest: 702cbc4. It allows dynamic granting of tokens based on the SPIFFE identity of the sandbox.

  4. krishicks commented on Aug 14, 2026

    @krishicks
    Collaborator

    📋 triage-agent

    Removing state:triage-needed as workflow cleanup. Agent review of the issue's current state found substantive maintainer discussion, indicating that it is no longer awaiting initial triage. This label removal does not imply roadmap acceptance or implementation priority.

  5. github-actions commented on Aug 29, 2026

    @github-actions

    This issue has had no activity for 14 days and is now marked stale. It may be closed in 7 days if there is no further activity. Comment or remove the state:stale label to keep it open.

  6. p5 commented on Sep 17, 2026

    @p5
    Contributor

    I am interested in this feature.

    The use case is an agent SDK where the application resolves user-specific, short-lived credentials after a request arrives. The sandbox is already running, so the SDK needs to attach those credentials without recreating it.

    The credentials must be scoped to the specific sandbox and request or session. They must not be available to other sandboxes, sessions, or users, even when those sandboxes use the same provider type. When the session ends, the credentials should expire and be removed automatically.

    This would avoid permanent provider records, and a separate credential-injection system in the application.

    sandbox = createSandbox(ttl=3600)
    sandbox.addCredentials(github.com, header=X, value=Y) # credentials not assignable to other sandboxes
    sandbox.destroy() # optional, could crash beforehand
    # credentials are destroyed when sandbox removed, graceful or not
    
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions