Skip to content

Introduce WebServer Gateway Integration - #373

Open
straw-hat-sunny wants to merge 2 commits into
Infisical:mainfrom
straw-hat-sunny:sswarn/gateway-webserver
Open

Introduce WebServer Gateway Integration#373
straw-hat-sunny wants to merge 2 commits into
Infisical:mainfrom
straw-hat-sunny:sswarn/gateway-webserver

Conversation

@straw-hat-sunny

Copy link
Copy Markdown

Description 📣

Adds Web Server as a PAM resource handled directly by the Infisical Gateway, enabling HTTP request and response session recording for frontend browser access.

Changes

  • Adds the web-server gateway resource type and capability advertisement.

  • Routes frontend Web Server browser sessions through the PAM ALPN protocol instead of the generic TCP proxy.

  • Issues PAM certificates containing the session ID and Web Server resource type.

  • Adds a fixed-target HTTP/1.1 reverse-proxy handler that:

    • Injects configured Basic Auth credentials.
    • Prevents clients from selecting a different upstream host.
    • Records complete request and response bodies as paired HTTP events.
    • Redacts authorization, cookies, and API-key headers.
    • Handles redirects, keep-alive, encoded paths, queries, HEAD, and 304 responses.
    • Rejects CONNECT, WebSocket, and protocol-upgrade requests.
  • Adds CLI routing and loopback access for Web Server accounts.

  • Adds a local Basic Auth Go server for manual POC validation.

Notes

  • This is POC scope; no automated tests were added.
  • Request and response bodies are recorded without a size limit.
  • Existing browser sessions must be recreated because older sessions use generic TCP certificates rather than PAM certificates.

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

Tests 🛠️

# Here's some code block to paste some code snippets

@infisical-cla-app

Copy link
Copy Markdown

📝 Contributor License Agreement required

Before this PR can merge, every contributor must sign the Infisical CLA.
Signing is quick: sign in with GitHub, review the CLA, and accept.

👉 Sign the CLA

Still needs to sign:

Once everyone has signed, the check updates automatically — no need to close and reopen the PR.

@straw-hat-sunny
straw-hat-sunny marked this pull request as ready for review August 22, 2026 00:03
@greptile-apps

greptile-apps Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces Web Server PAM sessions routed through a Gateway-side HTTP/1.1 reverse proxy, including Basic Auth injection and paired request/response recording.

  • Adds Web Server account routing, Gateway capability advertisement, and handler dispatch.
  • Adds fixed-target HTTP forwarding, sensitive-header redaction, unsupported-upgrade rejection, and HTTP event recording.
  • Adds Web Server recording upload selection and a local Basic Auth test server.

Confidence Score: 3/5

The Gateway memory-exhaustion path should be fixed before merging; unrestricted target addresses also warrant SSRF hardening.

An authenticated PAM client can make the new handler buffer arbitrarily large request or response bodies, including additional recording allocations, which can take down the Gateway; target validation also permits internal and metadata-service destinations.

Files Needing Attention: packages/pam/handlers/webserver/proxy.go, packages/pam/pam-proxy.go

Security Review

The new handler permits one authenticated session to force unbounded request or response buffering in the shared Gateway process. Its target validation also permits SSRF-sensitive HTTP(S) destinations without address restrictions.

Important Files Changed

Filename Overview
packages/pam/handlers/webserver/proxy.go Adds the HTTP reverse proxy, but unbounded body buffering creates a Gateway denial-of-service path and target validation leaves SSRF-sensitive destinations unrestricted.
packages/pam/pam-proxy.go Advertises and dispatches Web Server resources, passing API-provided target credentials into the new handler.
packages/pam/local/access.go Adds loopback routing and user-facing connection details for interactive Web Server PAM sessions.
packages/pam/session/uploader.go Recognizes Web Server recording filenames and uploads their records using the existing HTTP-event format.
cmd/test/main.go Adds a loopback-only Basic Auth server for manual proxy validation.

Reviews (1): Last reviewed commit: "add test web server" | Re-trigger Greptile

Comment on lines +183 to +186
}
if err := req.Body.Close(); err != nil {
return fmt.Errorf("failed to close web server request body: %w", err)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 security Unbounded body buffering exhausts memory

When an authenticated PAM client sends a very large request body or selects an endpoint returning a very large response, the proxy buffers the complete body and recording data in memory without a size limit, causing the shared Gateway to become unavailable or be terminated for out-of-memory. How this was verified: The raw client stream reaches both unbounded io.ReadAll calls, and each resulting body is also passed to the session recorder.

Knowledge Base Used:

Comment on lines +42 to +47
if targetURL.Host == "" || (targetURL.Scheme != "http" && targetURL.Scheme != "https") {
return nil, fmt.Errorf("web server URL must include http or https scheme and host")
}
if targetURL.User != nil {
return nil, fmt.Errorf("web server URL must not include user info")
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 security Target validation permits internal destinations

If a Web Server resource is configured with a loopback, private, link-local, metadata-service, or rebinding hostname, this validation accepts it and the Gateway resolves and connects to that address from its own network, enabling access to internal-only services. How this was verified: The API-provided target is checked only for an HTTP(S) scheme, host, and absent userinfo before being resolved by the Gateway's dialer.

Context Used: Flag SSRF risks (source)

Knowledge Base Used:

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.

1 participant