Skip to content

fix(web-surfer): sanitize page metadata in prompts#7708

Open
pragnyanramtha wants to merge 1 commit into
microsoft:mainfrom
pragnyanramtha:codex/sanitize-web-surfer-page-metadata
Open

fix(web-surfer): sanitize page metadata in prompts#7708
pragnyanramtha wants to merge 1 commit into
microsoft:mainfrom
pragnyanramtha:codex/sanitize-web-surfer-page-metadata

Conversation

@pragnyanramtha
Copy link
Copy Markdown

Summary

Fixes #7457.

  • sanitize page titles and URLs before interpolating them into Web Surfer prompts
  • replace markdown-link formatting around page metadata with explicit <page_title> / <page_url> delimiters
  • add focused prompt tests covering control-character flattening, delimiter escaping, truncation, and template formatting

Testing

uv run --project python pytest -q python/packages/autogen-ext/tests/test_websurfer_prompts.py
uv run --project python pytest -q python/packages/autogen-ext/tests/test_websurfer_agent.py::test_run_websurfer_declarative
uv run --project python ruff check python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_prompts.py python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_multimodal_web_surfer.py python/packages/autogen-ext/tests/test_websurfer_prompts.py
uv run --project python ruff format --check python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_prompts.py python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_multimodal_web_surfer.py python/packages/autogen-ext/tests/test_websurfer_prompts.py
uv run --project python pyright python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_prompts.py python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_multimodal_web_surfer.py python/packages/autogen-ext/tests/test_websurfer_prompts.py
git diff --check

Note: uv run --project python pytest -q python/packages/autogen-ext/tests/test_websurfer_agent.py has one local failure in test_run_websurfer: agent._page is None after lazy init. The failure occurs before the changed prompt construction paths and appears local Playwright/browser initialization-related; test_run_websurfer_declarative passes.

@pragnyanramtha pragnyanramtha marked this pull request as ready for review May 16, 2026 22:29
Copilot AI review requested due to automatic review settings May 16, 2026 22:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

[Security] Web Surfer agent vulnerable to indirect prompt injection via page title

2 participants