Skip to content

fix: preserve RAG upload limits and block unsafe iframes - #23

Draft
cursor[bot] wants to merge 8 commits into
mainfrom
cursor/critical-bug-investigation-bd68
Draft

cursor[bot] wants to merge 8 commits into
mainfrom
cursor/critical-bug-investigation-bd68

Conversation

@cursor

@cursor cursor Bot commented Aug 17, 2026

Copy link
Copy Markdown

Pull Request Checklist

Before submitting, make sure you've checked the following:

  • Target branch: Automation branch is based on main per run configuration.
  • Description: Fixes two high-severity regressions found in recent behavioral changes.
  • Changelog: Not added; targeted critical bugfix automation PR.
  • Documentation: Not applicable for these internal correctness/security fixes.
  • Dependencies: No new dependencies.
  • Testing: Focused regression tests and validation commands run successfully.
  • Code review: Self-reviewed changed code and caller paths.
  • Prefix: PR title uses fix:.

Changelog Entry

Description

  • Preserve existing RAG file upload and image compression limits when admins submit partial RAG config updates, such as saving only Web Search settings.
  • Restrict generic markdown iframe rendering to external HTTP(S) origins so chat content cannot trigger same-origin authenticated requests via iframe src values.

Added

  • Dependency-light regression test for partial RAG config update preservation.
  • getSafeIframeSrc utility and Vitest coverage for external, same-origin, backend-origin, and script/data/file iframe sources.

Changed

  • /api/v1/retrieval/config/update now treats omitted nullable upload/compression fields consistently with the surrounding optional config fields.
  • Generic markdown iframe rendering now validates src before creating an iframe.

Deprecated

  • None.

Removed

  • None.

Fixed

  • Admin saving Web Search settings no longer silently clears FILE_MAX_SIZE, FILE_MAX_COUNT, FILE_IMAGE_COMPRESSION_WIDTH, or FILE_IMAGE_COMPRESSION_HEIGHT.
  • Raw markdown iframe content can no longer embed relative/same-origin/WebUI-backend URLs such as /api/v1/auths/signout, or script/data/file schemes.

Security

  • Blocks same-origin iframe request abuse from model-generated or shared chat markdown.

Breaking Changes

  • None.

Additional Information

Bug and impact:

  • Partial RAG update data loss: saving a partial RAG config payload ({ web: ... }) overwrote upload limits and image compression settings with None, disabling admin-enforced upload controls.
  • Unsafe iframe rendering: raw markdown iframes bypassed sanitized HTML and rendered arbitrary src values, allowing authenticated same-origin GET side effects from viewed chat content.

Root cause:

  • Four optional upload/compression fields were assigned directly from form_data instead of preserving existing values when omitted.
  • HTMLToken.svelte extracted iframe URLs from unsanitized token.text and rendered them without origin/scheme validation.

Fix and validation performed:

  • Added non-None preservation for the four RAG upload/compression fields.
  • Added external-origin iframe URL validation and wired it into generic iframe rendering.
  • Ran python3 -m py_compile backend/open_webui/routers/retrieval.py tests/test_rag_config_update.py.
  • Manually executed test_partial_rag_updates_preserve_file_upload_settings() because pytest is unavailable in the base image.
  • Ran npm ci to install pinned frontend dependencies.
  • Ran npx vitest run src/lib/utils/iframe.test.ts (4 tests passed).
  • Ran npx prettier --check src/lib/components/chat/Messages/Markdown/HTMLToken.svelte src/lib/utils/iframe.ts src/lib/utils/iframe.test.ts.
  • Ran git diff --check origin/main..HEAD.

Screenshots or Videos

  • Not applicable.

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree with the Contributor License Agreement (CLA), and I am providing my contributions under its terms.

Open in Web View Automation 

cursoragent and others added 8 commits August 17, 2026 11:03
Co-authored-by: mkatwi <mkatwi@users.noreply.github.com>
Co-authored-by: mkatwi <mkatwi@users.noreply.github.com>
Co-authored-by: mkatwi <mkatwi@users.noreply.github.com>
Co-authored-by: mkatwi <mkatwi@users.noreply.github.com>
Co-authored-by: mkatwi <mkatwi@users.noreply.github.com>
Co-authored-by: mkatwi <mkatwi@users.noreply.github.com>
Co-authored-by: mkatwi <mkatwi@users.noreply.github.com>
Co-authored-by: mkatwi <mkatwi@users.noreply.github.com>
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.

1 participant