Skip to content

revert: drop nginx safe string validation changes#12076

Merged
wanghe-fit2cloud merged 1 commit intodev-v2from
chore/revert-nginx-validate-12072
Mar 5, 2026
Merged

revert: drop nginx safe string validation changes#12076
wanghe-fit2cloud merged 1 commit intodev-v2from
chore/revert-nginx-validate-12072

Conversation

@ssongliu
Copy link
Member

@ssongliu ssongliu commented Mar 5, 2026

Refs #12072

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Mar 5, 2026

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 5, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

Reviewed commit: 22d5e129a2

ℹ️ 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".

Comment on lines +117 to +118
location.UpdateDirective("proxy_pass", []string{req.ProxyPass})
location.UpdateDirective("proxy_set_header", []string{"Host", req.ProxyHost})

Choose a reason for hiding this comment

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

P1 Badge Restore sanitization before writing proxy directives

OperateProxy now writes req.ProxyPass and req.ProxyHost directly into nginx directives, but request.WebsiteProxyConfig only enforces required and DumpDirective serializes parameters verbatim (no escaping), so inputs containing ; or newline can inject extra directives or leave the generated proxy config invalid. This is a regression from the previous validation path and allows a crafted API payload to alter nginx behavior beyond the intended proxy fields.

Useful? React with 👍 / 👎.

return
}
location.UpdateDirective("proxy_pass", []string{safePass})
location.UpdateDirective("proxy_pass", []string{fmt.Sprintf("http://127.0.0.1:%d%s", server.Port, proxyPath)})

Choose a reason for hiding this comment

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

P1 Badge Validate MCP proxy path before composing proxy_pass

The MCP bind flow now interpolates server.StreamableHttpPath/server.SsePath directly into proxy_pass, and those values come from create/update requests without strict format validation; because nginx config dumping does not escape directive separators, a path containing control characters or ; can inject unintended directives or break nginx syntax in generated /proxy/*.conf files. Reintroducing URL/path safety checks here is necessary to prevent config injection and reload failures.

Useful? React with 👍 / 👎.

return err
}
location.UpdateDirective("auth_basic_user_file", []string{safePass})
location.UpdateDirective("auth_basic_user_file", []string{fmt.Sprintf("/www/sites/%s/path_auth/pass/%s", website.Alias, fmt.Sprintf("%s.pass", req.Name))})

Choose a reason for hiding this comment

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

P2 Badge Reject unsafe auth name before auth_basic_user_file

This now embeds req.Name directly in auth_basic_user_file; the current path.Base check only prevents traversal and still allows nginx metacharacters/control characters, which are emitted raw when writing directives. A crafted auth name can therefore terminate or extend the directive in the generated path-auth config, causing unintended directives or persistent syntax errors during auth updates.

Useful? React with 👍 / 👎.

Copy link
Member

@wanghe-fit2cloud wanghe-fit2cloud left a comment

Choose a reason for hiding this comment

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

/lgtm

@wanghe-fit2cloud
Copy link
Member

/approve

@wanghe-fit2cloud wanghe-fit2cloud merged commit 975e7f9 into dev-v2 Mar 5, 2026
4 of 6 checks passed
@wanghe-fit2cloud wanghe-fit2cloud deleted the chore/revert-nginx-validate-12072 branch March 5, 2026 03:55
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Mar 5, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wanghe-fit2cloud

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@f2c-ci-robot f2c-ci-robot bot added the approved label Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants