Skip to content

feat(sandbox): L7 credential injection — query param rewriting and Basic auth encoding#631

Draft
htekdev wants to merge 1 commit intoNVIDIA:mainfrom
htekdev:feat/credential-injection-query-param-basic-auth
Draft

feat(sandbox): L7 credential injection — query param rewriting and Basic auth encoding#631
htekdev wants to merge 1 commit intoNVIDIA:mainfrom
htekdev:feat/credential-injection-query-param-basic-auth

Conversation

@htekdev
Copy link
Copy Markdown
Contributor

@htekdev htekdev commented Mar 26, 2026

Summary

Adds two credential injection capabilities to the L7 proxy's SecretResolver, closing the remaining gaps identified in #630 (supersedes #538 and #541).

Query parameter rewriting

Resolves placeholder tokens in URL query parameter values before forwarding upstream. When the sandbox child process constructs a request like:

GET /youtube/v3/search?part=snippet&key=openshell:resolve:env:YOUTUBE_API_KEY HTTP/1.1

The proxy rewrites the request line to inject the real credential:

GET /youtube/v3/search?part=snippet&key=AIzaSy-real-key HTTP/1.1
  • Handles URLs with single or multiple query parameters
  • Properly percent-encodes resolved secrets per RFC 3986
  • Percent-decodes parameter values before placeholder matching
  • No rewriting when no placeholders are present (zero overhead)

Basic Authorization header encoding

Supports credentials stored as raw username:password that need base64 encoding for HTTP Basic auth. When the child process constructs:

Authorization: Basic <base64("admin:openshell:resolve:env:DB_PASSWORD")>

The proxy decodes the base64 token, resolves placeholders in the decoded string, and re-encodes:

Authorization: Basic <base64("admin:hunter2")>
  • Decodes existing Basic auth tokens to resolve embedded placeholders
  • Re-encodes after substitution
  • Passes through non-placeholder Basic auth tokens unmodified

What's NOT changed

  • No modifications to the network policy file spec
  • No proto schema changes
  • No changes to the L7 relay logic — both features operate within the existing rewrite_http_header_block flow

Testing

11 new unit tests covering:

  • Query param rewriting (single param, multiple params, special characters, no-op cases)
  • Basic auth encoding round-trips (placeholder in password, no-op for normal auth, full header block)
  • Percent encoding/decoding correctness

Closes #630

…sic auth encoding

Add two credential injection capabilities to the L7 proxy's SecretResolver:

1. Query parameter rewriting: resolve placeholder tokens in URL query
   parameter values (e.g. ?api_key=openshell:resolve:env:KEY) with proper
   percent-encoding of the resolved secret.

2. Basic Authorization header encoding: decode base64 Basic auth tokens,
   resolve placeholder tokens in the decoded username:password string,
   and re-encode before forwarding upstream.

Both features operate within the existing rewrite_http_header_block flow
and require no changes to the network policy file spec or proto schema.

Closes NVIDIA#630
@htekdev htekdev requested a review from a team as a code owner March 26, 2026 17:47
@johntmyers
Copy link
Copy Markdown
Collaborator

Is there a UX change here? How would a user use these?

@htekdev
Copy link
Copy Markdown
Contributor Author

htekdev commented Mar 27, 2026

No ux changed. I am testing this now. Essentially it's extending the reach of credentials injection into query parameters and basic authorization which won't work for credentials injection given query parameters are not headers and basic authentication is encoded base 64.

It's required for github copilot integration seeing thst some calls use user:pat token

Once I confirm it is working in a live env I will ping again

@johntmyers johntmyers marked this pull request as draft March 27, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(sandbox): L7 credential injection — query parameter rewriting and Basic auth encoding

2 participants