[PR #4294] [MERGED] Restrict private image results to the provider origin #6322

Closed
opened 2026-10-23 04:09:20 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4294
Author: @SpicyMarinara
Created: 7/30/2026
Status: ✅ Merged
Merged: 7/30/2026
Merged by: @SpicyMarinara

Base: staging ← Head: security/restrict-image-result-urls


📝 Commits (1)

  • ba89762 security: restrict private image result URLs

📊 Changes

7 files changed (+216 additions, -21 deletions)

View changed files

📝 CHANGELOG.md (+2 -4)
📝 docs/CONFIGURATION.md (+1 -1)
📝 docs/media/image-providers.md (+2 -0)
📝 package.json (+2 -1)
📝 packages/server/src/services/image/image-generation.ts (+87 -15)
📝 packages/server/src/utils/security.ts (+15 -0)
➕ scripts/regressions/image-result-url-security.regression.ts (+107 -0)

📄 Description

Linked issue

Closes #4288

Why this change

An image provider controls the result URL that Marinara Engine fetches. Private-provider support should authorize only that configured service, not arbitrary private hosts or ports selected by a response or redirect.

What changed

  • Extend outbound-request policy with an exact-origin allowlist enforced on every redirect hop.
  • Keep normal SSRF protections for public image result URLs.
  • Permit private result URLs only when their scheme, hostname, and port exactly match the configured provider origin.
  • Normalize loopback provider origins consistently and reject metadata, other-port, other-scheme, and cross-origin targets.
  • Add local two-server regressions for exact-origin success, same-origin redirects, and boundary violations.
  • Update image-provider/configuration documentation and the changelog.
  • Track translated documentation separately in #4289.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Automated proof completed before publication:

  • pnpm regression:image-result-security
  • pnpm check
  • pnpm version:check
  • git diff --check staging...security/restrict-image-result-urls

Manual verification notes

  • Manually generate with a public hosted provider and verify public/CDN result redirects.
  • Manually generate with a private loopback or LAN provider and verify exact-origin results.
  • Manually verify a cross-origin private redirect is rejected with a useful provider error.
  • No live external image-provider generation was performed in this agent run.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

English documentation and CHANGELOG.md are updated. Translation follow-up: #4289.

UI evidence (if applicable)

Not applicable; this changes server-side outbound fetching and provider configuration behavior.

Summary by CodeRabbit

  • Security

    • Private generated-image result URLs are now restricted to the configured provider’s exact scheme, hostname, and port.
    • Redirects from trusted local image providers can no longer reach other private services.
    • Public CDN-hosted image results remain supported.
  • Documentation

    • Clarified local image provider requirements and URL safety behavior.
    • Added guidance for local proxies serving generated images.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/4294 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 7/30/2026 **Status:** ✅ Merged **Merged:** 7/30/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `security/restrict-image-result-urls` --- ### 📝 Commits (1) - [`ba89762`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ba897625c13034ff7b5f7236fccb0b5ff59f0960) security: restrict private image result URLs ### 📊 Changes **7 files changed** (+216 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -4) 📝 `docs/CONFIGURATION.md` (+1 -1) 📝 `docs/media/image-providers.md` (+2 -0) 📝 `package.json` (+2 -1) 📝 `packages/server/src/services/image/image-generation.ts` (+87 -15) 📝 `packages/server/src/utils/security.ts` (+15 -0) ➕ `scripts/regressions/image-result-url-security.regression.ts` (+107 -0) </details> ### 📄 Description ## Linked issue Closes #4288 ## Why this change An image provider controls the result URL that Marinara Engine fetches. Private-provider support should authorize only that configured service, not arbitrary private hosts or ports selected by a response or redirect. ## What changed - Extend outbound-request policy with an exact-origin allowlist enforced on every redirect hop. - Keep normal SSRF protections for public image result URLs. - Permit private result URLs only when their scheme, hostname, and port exactly match the configured provider origin. - Normalize loopback provider origins consistently and reject metadata, other-port, other-scheme, and cross-origin targets. - Add local two-server regressions for exact-origin success, same-origin redirects, and boundary violations. - Update image-provider/configuration documentation and the changelog. - Track translated documentation separately in #4289. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Automated proof completed before publication: - `pnpm regression:image-result-security` - `pnpm check` - `pnpm version:check` - `git diff --check staging...security/restrict-image-result-urls` ### Manual verification notes - Manually generate with a public hosted provider and verify public/CDN result redirects. - Manually generate with a private loopback or LAN provider and verify exact-origin results. - Manually verify a cross-origin private redirect is rejected with a useful provider error. - No live external image-provider generation was performed in this agent run. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) English documentation and `CHANGELOG.md` are updated. Translation follow-up: #4289. ## UI evidence (if applicable) Not applicable; this changes server-side outbound fetching and provider configuration behavior. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Security** * Private generated-image result URLs are now restricted to the configured provider’s exact scheme, hostname, and port. * Redirects from trusted local image providers can no longer reach other private services. * Public CDN-hosted image results remain supported. * **Documentation** * Clarified local image provider requirements and URL safety behavior. * Added guidance for local proxies serving generated images. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:09:20 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#6322
No description provided.