Skip to content

feat(credentials): add provider credential storage drivers - #2437

Open
sjenning wants to merge 17 commits into
NVIDIA:mainfrom
sjenning:1931-credential-drivers-implementation
Open

feat(credentials): add provider credential storage drivers#2437
sjenning wants to merge 17 commits into
NVIDIA:mainfrom
sjenning:1931-credential-drivers-implementation

Conversation

@sjenning

Copy link
Copy Markdown
Collaborator

Superseding #1986 while @TaylorMutch is away

Summary

Adds gateway-owned credential storage for Providers v2. New provider credential
writes now persist opaque handles instead of inline secret values, with default
encrypted database storage when no external credential backend is configured and
opt-in Kubernetes Secrets or Vault backends for deployments that want dedicated
secret storage.

Related Issue

Related to #1931

Changes

  • Adds a credential driver protobuf contract for store, resolve, delete, list,
    and capability calls.
  • Adds gateway credential runtime support for a single active external
    credential driver, in-tree drivers, and UDS-connected external drivers.
  • Adds the default encrypted database credential store as
    openshell-driver-db-credstore.
  • Adds standalone UDS-capable openshell-driver-kubernetes-secrets and
    openshell-driver-vault binaries, plus in-tree gateway loading.
  • Updates Providers v2 create/update/delete paths to store new credential values
    through credential storage and persist internal credential_handles.
  • Preserves upgrade compatibility for existing inline/plaintext provider records:
    legacy inline credentials remain readable, config-only updates leave them
    inline, and only newly submitted/rotated credential values move into credential
    storage.
  • Rejects user-supplied provider.credential_handles on provider create/update.
  • Resolves credential handles at runtime for sandbox provider environments,
    provider refresh, and managed inference routes.
  • Updates Helm defaults so no external driver means default encrypted DB
    credential storage, backed by a retained key-encryption-key Secret injected
    into the gateway.
  • Adds Helm/Skaffold values and targeted e2e coverage for Kubernetes Secrets and
    Vault credential storage backends. The local Vault e2e path deploys OpenBao as
    a Vault-compatible fixture.
  • Updates gateway/provider docs, architecture notes, CI labels, and local test
    tasks for credential driver validation.

Default Behavior

Credential drivers are opt-in for external backends. If
[openshell.gateway].credential_drivers is omitted, the gateway uses the default
encrypted database credential store. The submitted secret is encrypted into a
driver-owned credential object outside the provider record, and the provider
record stores only an opaque handle.

The explicit empty list form, credential_drivers = [], is invalid. Operators
should omit the field for default encrypted DB storage or select exactly one
external backend such as kubernetes-secrets or vault.

Existing provider records that already contain inline plaintext credentials are
still resolved for upgrade compatibility, but new provider creates and credential
updates use credential storage handles.

Testing

  • cargo check -p openshell-driver-vault -p openshell-server
  • mise run pre-commit
  • mise run helm:test
  • mise run e2e:kubernetes:credential-drivers
  • mise run e2e:rust
  • mise run e2e:podman - provider/default credential coverage passed before
    the suite failed in sandbox_create_with_no_keep_cleans_up_after_tty_command;
    isolated rerun of OPENSHELL_E2E_PODMAN_TEST=sandbox_lifecycle mise run e2e:podman reproduced the same Podman cleanup failure.

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated
  • Gateway configuration docs updated

@copy-pr-bot

copy-pr-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@sjenning

Copy link
Copy Markdown
Collaborator Author

Obvious issue left over from the rebase in ‎.github/workflows/branch-e2e.yml. Will fix tomorrow.

@sjenning

sjenning commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator Author

Obvious issue left over from the rebase in ‎.github/workflows/branch-e2e.yml

Fixed

@sjenning

Copy link
Copy Markdown
Collaborator Author

Hold on this. It is all messed up.

@sjenning
sjenning force-pushed the 1931-credential-drivers-implementation branch from 0d42e4e to d1e10d1 Compare July 23, 2026 23:16
@mrunalp

mrunalp commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

/ok to test d1e10d1

@mrunalp

mrunalp commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

/ok to test 052540f

@sjenning
sjenning force-pushed the 1931-credential-drivers-implementation branch from 052540f to 1806c9b Compare July 28, 2026 19:40
@mrunalp

mrunalp commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

/ok to test 1806c9b

@mrunalp mrunalp added the gator:in-review Gator is reviewing or awaiting PR review feedback label Jul 30, 2026

@johntmyers johntmyers left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gator-agent

PR Review Status

Validation: This is project-valid work for roadmap issue #1931 and implements its gateway-owned credential-storage scope.
Head SHA: 1806c9be07e0307137ac7c0b8cced209018e81fb
Base SHA: b1c7ff684e9b16f88d050c29b0093d07389fbbbb
Merge base SHA: b1c7ff684e9b16f88d050c29b0093d07389fbbbb
Patch ID: 8c7fdb202e6f6004ee9069a12d24c5bb02ffb8c7
Gator payload: 2
Review mode: initial
Previous reviewed SHA: none

Blocking findings:

  • GATOR-1806c9be-01 (Critical): backend object identity is not workspace/provider-unique, allowing a cross-workspace Vault credential collision and disclosure.
  • GATOR-1806c9be-02 (Warning): handle-backed credentials bypass persisted provider expiration.
  • GATOR-1806c9be-03 (Warning): refresh overwrites the committed backend object before validation/CAS and can delete the still-referenced handle on failure.
  • GATOR-1806c9be-05 (Warning): the configured UDS startup timeout does not bound capability negotiation or runtime RPCs.

Carried findings:

  • None.

Non-blocking suggestions:

  • Add openshell-driver-db-credstore to the AGENTS.md architecture inventory and document the new credential-driver Skaffold profiles in the Helm development skill.

Docs: Relevant published provider and gateway-configuration docs are updated.

Next state: gator:in-review

Comment thread crates/openshell-driver-vault/src/lib.rs Outdated
Comment thread crates/openshell-server/src/grpc/provider.rs
Comment thread crates/openshell-server/src/provider_refresh.rs Outdated
Comment thread crates/openshell-server/src/credentials.rs Outdated
@johntmyers johntmyers added gator:blocked Gator is blocked by process or repository gates gator:in-review Gator is reviewing or awaiting PR review feedback and removed gator:in-review Gator is reviewing or awaiting PR review feedback gator:blocked Gator is blocked by process or repository gates labels Jul 30, 2026
@sjenning
sjenning force-pushed the 1931-credential-drivers-implementation branch from 1806c9b to 18e3235 Compare July 31, 2026 19:39
@sjenning

sjenning commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator Author

@johntmyers thanks for the review! All review feedback should be addressed by the new commits. I also rebased to resolve a conflict.

varshaprasad96 and others added 11 commits August 4, 2026 16:02
…rallelize operations

Use resourceVersion optimistic concurrency with retry loop for K8s
Secret ownership checks to prevent TOCTOU races. Switch Vault token
cache from RwLock to Mutex with double-check pattern to prevent
thundering herd on cache miss. Parallelize credential store and delete
operations across independent keys using try_join_all.

Signed-off-by: Varsha Prasad <varshaprasad96@gmail.com>
Signed-off-by: Varsha Prasad Narsing <varshaprasad96@gmail.com>
…ate cleanup

Replace try_join_all with join_all in credential store/delete operations
to handle partial failures — successfully-stored handles are cleaned up
when another key fails. Add retry loop with conflict detection to
db-credstore delete_credential, matching the K8s driver pattern.
Consolidate 4 manual cleanup_pre_stored_provider_credentials call sites
into a single error handler using an async block. Remove inconsistent
.trim() from db-credstore validate_handle_owner.

Signed-off-by: Varsha Prasad <varshaprasad96@gmail.com>
Signed-off-by: Varsha Prasad Narsing <varshaprasad96@gmail.com>
Remove attempt-count guard from 409/Aborted match arms in retry loops
so the post-loop Status::aborted error is reachable after exhausting
retries. Previously, last-attempt conflicts fell through to the
catch-all error arm, producing misleading Status::unavailable errors.

Remove duplicate validation calls that ran after
prepare_provider_credential_update but outside the cleanup-protected
async block, which would leak pre-stored handles on failure.

Signed-off-by: Varsha Prasad <varshaprasad96@gmail.com>
Signed-off-by: Varsha Prasad Narsing <varshaprasad96@gmail.com>
…aths

Include workspace and provider ID in credential backend object paths to ensure
cross-workspace uniqueness and prevent credential collision (GATOR-1806c9be-01).

- Updated credential driver proto to include workspace and provider_id fields
- Modified Vault driver to include workspace/provider_id in managed_secret_path
- Modified Kubernetes Secrets driver to include workspace/provider_id in
  credential_owner_id and managed_secret_name
- Updated all credential runtime calls to pass workspace/provider_id
- Updated tests to use the new signatures

This prevents two workspaces sharing the same external credential store from
colliding on provider names, which was a critical security issue (CWE-639).
…d credentials

Compute effective expiration from both provider and driver values using the
earliest non-zero timestamp and skip expired values before insertion
(GATOR-1806c9be-02).

- Modified resolve_provider_handles to check provider credential_expires_at_ms
- Skip expired credentials during resolution instead of returning them
- Use effective expiration (min of provider and driver) in resolution results
- Fix inference.rs to preserve earliest expiration when merging

This ensures handle-backed credentials respect the same expiration semantics
as inline credentials.
…dation

Stage credential replacements under new immutable handles instead of reusing
existing handles to prevent overwriting committed values before validation/CAS
(GATOR-1806c9be-03).

- Stage credentials with empty existing_handles map to force new handle creation
- Validate and CAS before the new values are committed to backend storage
- Delete old handles only after successful CAS
- On CAS failure, delete only the newly staged handles
- This prevents CWE-362/CWE-367 race conditions where failed refreshes could
  still modify or delete the active credential

The fix ensures that a rejected refresh cannot modify the backend object still
referenced by the committed provider record.
Apply configured timeouts to both startup capability negotiation and runtime
RPCs to prevent indefinite hangs (GATOR-1806c9be-05).

- Add DEFAULT_CREDENTIAL_DRIVER_RPC_TIMEOUT_SECS constant (30s)
- Apply timeout to GetCapabilities during startup connection
- Apply timeout to all runtime RPCs (store, delete, resolve)
- Use tokio::time::timeout to bound the entire GetCapabilities operation
  during startup, not just the socket connection
- Return contextual deadline errors on timeout

This prevents a faulty or overloaded driver from hanging gateway operations
indefinitely.
- Add missing workspace and provider_id parameters to test helpers
- Update store_provider_credentials calls to include new parameters
- Update delete_provider_credential_handles calls with new signature
- Fix managed_secret_path call in vault driver test
- Fix run_refresh_worker_tick call to include optional credentials param
- Resolve collapsible_if clippy warning in provider_refresh.rs

Signed-off-by: Seth Jennings <sjenning@redhat.com>
The Kubernetes auth Vault resolve test was constructing a managed path with
test-workspace/test-provider-id but sending default/prov-123 in the request,
causing validation to reject the request (GATOR-18e32351-01).

- Update test to use test-workspace and test-provider-id in the request to
  match the logical_path construction
- This ensures the test exercises the intended code path and validates
  Kubernetes auth resolution properly

The test now passes and correctly validates identity enforcement.
Stage refresh replacements under genuinely distinct immutable handles using
a unique staging ID to prevent overwriting committed values (GATOR-1806c9be-03).

- Generate a unique staging ID using UUID for each refresh operation
- Use this staging ID when storing credentials instead of the real provider ID
- Pass the same staging ID during cleanup on failure to delete only staged objects
- This ensures deterministic paths (Vault) and object names (K8s) don't collide
  with the committed provider's credentials

The fix prevents failed refreshes from silently replacing active credentials
or breaking providers by deleting still-referenced backend objects.
Add local tokio::time::timeout wrappers around credential driver RPCs to
bound non-compliant or stalled UDS peers (GATOR-1806c9be-05).

- Wrap StoreCredential, DeleteCredential, and ResolveCredentials in local timeouts
- Return contextual deadline_exceeded errors when timeouts occur
- Keep existing gRPC timeout metadata for compliant implementations
- GetCapabilities during startup was already wrapped in previous commit

This ensures a faulty local driver cannot hang gateway operations indefinitely,
even if it accepts the connection but never responds to the RPC.
@sjenning
sjenning force-pushed the 1931-credential-drivers-implementation branch from 46de769 to 3e764e8 Compare August 4, 2026 21:04
Signed-off-by: Seth Jennings <sjenning@redhat.com>
Signed-off-by: Seth Jennings <sjenning@redhat.com>
@johntmyers

Copy link
Copy Markdown
Collaborator

gator-agent

Review Convergence Checkpoint

Thanks @sjenning. I checked the current rebased head and the three remediation commits against the durable feedback ledger. The Vault test identity fix remains resolved, and the runtime StoreCredential, DeleteCredential, and ResolveCredentials calls are locally bounded. The independent delta review carried only the two existing invariant families below; it produced no new finding IDs or unchanged-code findings.

Head SHA: 3e764e89b0b5d7fbc92cd73b751636a4f575aa53
Base SHA: 8c7dd148a9e6360c9d5b2830e339a0dc4b3f3032
Merge base SHA: 8c7dd148a9e6360c9d5b2830e339a0dc4b3f3032
Patch ID: d9a6dbdc8c620f7b6952f59503a997cbb38ae1aa
Gator payload: 3

Three finding-bearing review rounds have completed.

Root-cause findings:

  • GATOR-1806c9be-03 remains open: refresh staging uses a UUID-suffixed value as provider_id, but Vault and Kubernetes handles are later resolved against the provider record's real ID. A committed staged handle is therefore rejected. The pre-CAS validation failure path also leaves staged objects behind, and successful cleanup still selects unchanged sibling handles. The governing invariant is to keep immutable provider ownership separate from per-write object identity, clean staged objects on every pre-CAS failure, and delete only replaced old handles after CAS.
  • GATOR-1806c9be-05 remains open in part: the effectful runtime RPCs are now locally bounded, but the supported prestarted UDS path still awaits GetCapabilities with only peer-enforced gRPC timeout metadata. A nonresponding local driver can therefore block gateway startup indefinitely.

Scope growth:

  • Completing refresh staging requires an explicit owner-versus-object-generation identity contract across the default, Vault, and Kubernetes Secrets drivers. That remediation-driven contract decision remains the maintainer checkpoint.

Reviewer-quality signals:

  • No new finding IDs, resolved or waived re-raises, unchanged-code proposals, or missing-reproducer downgrades were produced. Both review proposals preserve carried finding IDs.

Maintainer action: accept the current scope, split follow-up work, waive a finding, or explicitly authorize another autonomous review round.

Next state: gator:blocked

Signed-off-by: Seth Jennings <sjenning@redhat.com>
@johntmyers johntmyers added the test:e2e Requires end-to-end coverage label Aug 4, 2026
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Label test:e2e applied, but pull-request/2437 is at 1806c9b while the PR head is 7937934. A maintainer needs to comment /ok to test 7937934800edb75844cea8e71c229a93d18c3d8f to refresh the mirror. Once the mirror catches up, re-run Branch E2E Checks from the Actions tab.

@johntmyers

Copy link
Copy Markdown
Collaborator

/ok to test 7937934

@johntmyers johntmyers left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gator-agent

PR Review Status

Thanks @sjenning. I checked the three remediation commits on the latest head against the durable feedback ledger. The owner-versus-object-generation identity is now separated across the default, Vault, and Kubernetes Secrets drivers; pre-CAS failures clean staged objects; post-CAS cleanup deletes only replaced old handles; and the prestarted UDS GetCapabilities probe is locally bounded.

Validation: This remains project-valid implementation work for roadmap issue #1931 and its gateway-owned Providers v2 credential-storage scope.
Head SHA: 7937934800edb75844cea8e71c229a93d18c3d8f
Base SHA: 8c7dd148a9e6360c9d5b2830e339a0dc4b3f3032
Merge base SHA: 8c7dd148a9e6360c9d5b2830e339a0dc4b3f3032
Patch ID: 2f56f29deb74a2240ce1a1f4ba56b8716dbe141b
Gator payload: 3
Review mode: follow_up
Previous reviewed SHA: 18e32351d7eed3318fa657b68c35ef2deee47d4d

Blocking findings:

  • No blocking findings remain.

Carried findings:

  • None. GATOR-1806c9be-03 and GATOR-1806c9be-05 are resolved by this delta; GATOR-18e32351-01 remains resolved.

Docs: The PR updates the relevant provider and gateway-configuration docs; this remediation delta adds no separate direct UX contract.

E2E: test:e2e is applied, and /ok to test 7937934800edb75844cea8e71c229a93d18c3d8f was posted for the copy-PR mirror.

Next state: gator:watch-pipeline

@johntmyers johntmyers added gator:watch-pipeline Gator is monitoring PR CI/CD status gator:in-review Gator is reviewing or awaiting PR review feedback gator:blocked Gator is blocked by process or repository gates and removed gator:blocked Gator is blocked by process or repository gates gator:watch-pipeline Gator is monitoring PR CI/CD status gator:in-review Gator is reviewing or awaiting PR review feedback labels Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gator:in-review Gator is reviewing or awaiting PR review feedback test:e2e Requires end-to-end coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants