feat(sandbox): L7 credential injection for non-inference providers#541
Draft
htekdev wants to merge 1 commit intoNVIDIA:mainfrom
Draft
feat(sandbox): L7 credential injection for non-inference providers#541htekdev wants to merge 1 commit intoNVIDIA:mainfrom
htekdev wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
Extend the L7 proxy to inject API credentials at the network layer for arbitrary REST endpoints, generalizing the inference.local pattern to any service in network_policies. When an endpoint has a credential_injection configuration, the referenced provider credential is withheld from the sandbox environment and injected by the proxy before forwarding upstream. The agent process never sees the raw API key. Supports three injection styles: - Header (e.g., x-api-key: <value>) - Header with prefix (e.g., Authorization: Bearer <value>) - Query parameter (e.g., ?key=<value>) Changes: - Add CredentialInjection proto message to sandbox.proto - Add CredentialInjectionDef YAML schema with round-trip conversion - Add validation rules (requires rest + tls terminate) - Create credential_injector.rs module with extraction, lookup, and HTTP modification logic - Integrate into sandbox startup to filter provider env vars - Thread CredentialInjector through proxy to L7 relay - Apply injection in relay_http_request_with_resolver() - Make protobuf-src optional to support system protoc - Update policy-schema.md and architecture/sandbox.md Closes NVIDIA#538
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends the L7 proxy to inject API credentials at the network layer for arbitrary REST endpoints -- generalizing the
inference.localcredential injection pattern to any service innetwork_policies.Closes #538
Problem
Provider credentials (Exa AI, Perplexity, YouTube, GitHub, etc.) are injected as environment variables into sandboxes. Even with the
SecretResolverplaceholder mechanism, the agent process can infer credential existence and a prompt injection attack, malicious skill, or compromised dependency can read and exfiltrate placeholder values. Theinference.localproxy already proves credential injection at the network layer works -- this feature generalizes it.Changes
Proto and Policy Schema
CredentialInjectionmessage toproto/sandbox.protowith fields:header,value_prefix,query_param,provider,credentialCredentialInjectionDefserde struct toopenshell-policywith bidirectional YAML-proto conversionprotocol: rest+tls: terminate, exactly one ofheader/query_param,credentialandproviderrequiredCredential Injector Module (
credential_injector.rs)openshell-sandboxCredentialInjector::extract_from_policy()scans policy endpoints forcredential_injectionconfigs, cross-references with provider env, removes matched credentials from child envlookup(host, port)with case-insensitive exact match and glob pattern supportinject_credential()applies header injection (strip existing + append) or query parameter injection (URL append with percent-encoding)Sandbox and Proxy Integration
run_sandbox()to extract credential injections beforeSecretResolver, filtering injected credentials out of the child environmentCredentialInjectorthrough proxy pipeline to L7 relayrelay_http_request_with_resolver()after SecretResolver rewritingBuild System
protobuf-srcoptional (bundled-protocfeature) to support system protoc viaPROTOCenv varDocumentation
docs/reference/policy-schema.mdwith fullcredential_injectionfield reference and examplesarchitecture/sandbox.mdInjection Types
header: x-api-keyx-api-key: <value>header: Authorization,value_prefix: "Bearer "Authorization: Bearer <value>query_param: key?key=<value>Testing
credential_injector.rscovering extraction, lookup, glob matching, header injection, query param injection, body preservationBackward Compatibility
credential_injectionis not set on endpointsChecklist