Skip to content

Conversation

@dobrac
Copy link
Contributor

@dobrac dobrac commented Nov 12, 2025


Note

Adds maskRequestHost to sandbox network config and proxies non-envd traffic with a masked Host (with ${PORT} substitution), including validation, propagation, and tests.

  • API:
    • Add network.maskRequestHost to NewSandbox handling with ASCII validation; accept host or host:port (port optional).
    • Propagate to internal types.SandboxNetworkConfig and pass through to orchestrator creation.
  • Orchestrator/Proxy:
    • Extend proto (SandboxNetworkIngressConfig.mask_request_host) and generated stubs.
    • Proxy masks non-envd requests: sets X-Forwarded-Host and overrides Host; supports ${PORT} placeholder; logs mask_request_host.
    • Add MaskRequestHost to proxy pool Destination and rewrite logic.
  • Spec/Types:
    • Update OpenAPI (spec/openapi.yml) and generated client/server types to include maskRequestHost.
  • Tests:
    • Unit test for proxy host masking behavior.
    • Integration tests for maskRequestHost API param (valid/invalid), traffic access token paths, sandbox-not-found/closed-port; refactor request helpers.
  • Deps/Chores:
    • Add golang.org/x/net to API module; minor go.sum tidy.

Written by Cursor Bugbot for commit bf6cbd0. This will update automatically on new commits. Configure here.

@dobrac dobrac force-pushed the feat/add-mask-request-host-option branch 7 times, most recently from acef439 to 05d4c72 Compare November 12, 2025 17:06
@dobrac dobrac marked this pull request as ready for review November 12, 2025 17:06
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dobrac dobrac force-pushed the feat/add-mask-request-host-option branch from 05d4c72 to b65c9d7 Compare November 12, 2025 17:12
@dobrac dobrac force-pushed the feat/add-mask-request-host-option branch 4 times, most recently from 9803f0c to bb3cae8 Compare November 12, 2025 17:23
if t.MaskRequestHost != nil {
// Mask the request host to bypass source host protections.
r.Out.Header.Set("X-Forwarded-Host", r.In.Host)
r.Out.Host = *t.MaskRequestHost
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we certain that we want to change the ip/port to connect to, or do we just want the Host http request header to change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just the http request header to change

Copy link
Contributor

Choose a reason for hiding this comment

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

Changing the Host field doesn't just set the header, I believe it changes where you send the request as well. I'll see if I can verify that.

Copy link
Contributor Author

@dobrac dobrac Nov 12, 2025

Choose a reason for hiding this comment

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

I think the req.URL (or r.SetURL(url)) is what controls where the request goes, the r.Out.Host is just the header

Copy link
Contributor

Choose a reason for hiding this comment

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

Huh. Turns out that, when writing the http request, it pulls the host from the struct and then writes it out of band. I'll push the test on to your branch, but it just confirms that the code works 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

One suggestion: instead of using X-Forwarded-Host, we might want to consider using more widely accepted headers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

X-Forwarded-Host is actually widely accepted header

@dobrac dobrac force-pushed the feat/add-mask-request-host-option branch from f3d6f71 to 9d9e7ec Compare November 12, 2025 21:41
Base automatically changed from feat/ingress-header-based-auth-eng-3294 to main November 13, 2025 11:29
@dobrac dobrac force-pushed the feat/add-mask-request-host-option branch 2 times, most recently from e2781d7 to 0980901 Compare November 13, 2025 11:36
@dobrac dobrac force-pushed the feat/add-mask-request-host-option branch from 0fb9fe7 to 8d740e0 Compare November 13, 2025 12:35
@dobrac dobrac enabled auto-merge (squash) November 13, 2025 14:45
@dobrac dobrac merged commit eabfe52 into main Nov 13, 2025
27 checks passed
@dobrac dobrac deleted the feat/add-mask-request-host-option branch November 13, 2025 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants