Support path prefixes in Agent.to_web() - #7614
Closed
dsfaccini wants to merge 4 commits into
Closed
Conversation
dsfaccini
temporarily deployed
to
ui-security-review
August 19, 2026 19:00 — with
GitHub Actions
Inactive
Contributor
Author
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. |
Contributor
There was a problem hiding this comment.
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%2eis 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_pathare server-side configuration only (creation time), with secure defaults (None→ derive fromroot_path).- The
root_pathfromrequest.scopeisquote(safe='/')d before validation, normalizing any server-set value before the boundary check. - HTML injection of the
PYDANTIC_AI_CHAT_CONFIGbootstrap is escaped at the JSON level (ensure_ascii=True) and additionally at the script-token boundary (&/</>→\u0026/\u003c/\u003e), preventing</script>breakouts. Thetest_chat_app_bootstrap_serialization_is_script_saferegression covers this. - The existing
HostValidationMiddlewarestill wraps the app unchanged.
No HIGH or CRITICAL findings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Agent.to_web()below a URL path prefix #7611Derive the chat UI's public navigation and API directories from each request's ASGI
root_path, with independentbase_pathandapi_pathoverrides for proxy topologies that cannot be represented byroot_path.The raw HTML remains cached unchanged. Each response receives a script-safe
window.PYDANTIC_AI_CHAT_CONFIGbootstrap 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_VERSIONis 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
Checklist