Skip to content

Support path prefixes in Agent.to_web() - #7614

Closed
dsfaccini wants to merge 4 commits into
mainfrom
codex/issue-7611-chat-config
Closed

Support path prefixes in Agent.to_web()#7614
dsfaccini wants to merge 4 commits into
mainfrom
codex/issue-7611-chat-config

Conversation

@dsfaccini

@dsfaccini dsfaccini commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

This pull request was posted by Codex Desktop using gpt-5.6-sol on behalf of David.

Derive the chat UI's public navigation and API directories from each request's ASGI root_path, with independent base_path and api_path overrides for proxy topologies that cannot be represented by root_path.

The raw HTML remains cached unchanged. Each response receives a script-safe window.PYDANTIC_AI_CHAT_CONFIG bootstrap before the UI module executes. The path validation keeps generated requests same-origin and avoids browser URL-normalization escapes.

Release dependency

This draft depends on pydantic/ai-chat-ui#47 being merged and released. CHAT_UI_VERSION is intentionally unchanged because no released UI version consumes the runtime configuration yet. Before this PR can leave draft, it must be updated to the compatible released UI artifact and verified against both the default CDN and offline HTML.

Verification

  • Web UI tests pass.
  • Changed documentation examples pass.
  • Formatting, lint, type checking, and cassette checks pass.

Checklist

  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • No breaking changes in accordance with the version policy.
  • PR title is fit for the release changelog.

Review in cubic

@dsfaccini dsfaccini added feature New feature request, or PR implementing a feature (enhancement) web-ui labels Aug 19, 2026
@github-actions github-actions Bot added the size: M Medium PR (101-500 weighted lines) label Aug 19, 2026
@dsfaccini
dsfaccini temporarily deployed to ui-security-review August 19, 2026 19:00 — with GitHub Actions Inactive
@dsfaccini

Copy link
Copy Markdown
Contributor Author

This comment was posted by Codex Desktop using gpt-5.6-sol on behalf of David.

Closing as an accidentally created duplicate of #7612. Its distinct validation and HTML-injection findings are being reviewed by the canonical task before that PR proceeds.

@dsfaccini dsfaccini closed this Aug 19, 2026

@github-actions github-actions Bot left a comment

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.

SECURITY: PASS

The PR does not touch the UI message-history trust boundary (dump_messages / load_messages / sanitize_messages / FileUrl / SSRF surface). The new surface is purely the chat web UI HTML bootstrap, and the introdued code is well-defended:

  • _normalize_public_path (default-deny) rejects protocol-relative URLs (//), ../. segments (after URL-decoding, so %2e%2e is caught), control chars (\t\n\r), backslashes, and query/fragment. The PR keeps the documented "no cross-origin" policy (PR #7611 explicitly scopes cross-origin out).
  • base_path/api_path are server-side configuration only (creation time), with secure defaults (None → derive from root_path).
  • The root_path from request.scope is quote(safe='/')d before validation, normalizing any server-set value before the boundary check.
  • HTML injection of the PYDANTIC_AI_CHAT_CONFIG bootstrap is escaped at the JSON level (ensure_ascii=True) and additionally at the script-token boundary (&/</>\u0026/\u003c/\u003e), preventing </script> breakouts. The test_chat_app_bootstrap_serialization_is_script_safe regression covers this.
  • The existing HostValidationMiddleware still wraps the app unchanged.

No HIGH or CRITICAL findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature request, or PR implementing a feature (enhancement) size: M Medium PR (101-500 weighted lines) web-ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support mounting Agent.to_web() below a URL path prefix

1 participant