Skip to content

fix(security): Prestoui restrict img-src wildcard in CSP#26790

Merged
tdcmeehan merged 1 commit intoprestodb:masterfrom
adkharat:dynamic_scan_fix_presto_ui
Dec 15, 2025
Merged

fix(security): Prestoui restrict img-src wildcard in CSP#26790
tdcmeehan merged 1 commit intoprestodb:masterfrom
adkharat:dynamic_scan_fix_presto_ui

Conversation

@adkharat
Copy link
Copy Markdown
Contributor

@adkharat adkharat commented Dec 12, 2025

Description

Medium Dynamic scan CSV's issues flagged by ZAP.

  1. CSP: Wildcard Directive

Motivation and Context

(1) CSP: Wildcard Directive

Issue: CSP has a very broad img-src:

Removing http: https: eliminates scheme-wide allowances that permitted any external image host, closing the “wildcard/broad img-src” finding. Only images served from the UI origin or inline data URIs will load; everything else is blocked by the browser.
This directly addresses the reported CSP issue because the Content-Security-Policy header sent by the coordinator UI is the enforcement point; tightening the directive stops untrusted external image sources.

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== RELEASE NOTES ==

Security Changes
* Fix CSP by removing `img-src 'http: https:'` in response to `CWE-693 <https://cwe.mitre.org/data/definitions/693.html>`_. :pr:`25910`

@adkharat adkharat requested a review from a team as a code owner December 12, 2025 08:45
@prestodb-ci prestodb-ci added the from:IBM PR from IBM label Dec 12, 2025
@prestodb-ci prestodb-ci requested review from a team, nishithakbhaskaran and pramodsatya and removed request for a team December 12, 2025 08:46
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Dec 12, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Tightens the default Content-Security-Policy (CSP) for the Web UI by removing broad HTTP/HTTPS allowances from the img-src directive so that only self and data URLs are permitted for images.

Sequence diagram for Web UI request with updated CSP img-src policy

sequenceDiagram
    actor User
    participant Browser
    participant PrestoCoordinator

    User->>Browser: Navigate to WebUI URL
    Browser->>PrestoCoordinator: HTTP GET /ui
    PrestoCoordinator-->>Browser: HTML + CSP header
    Browser->>Browser: Parse CSP
    Browser->>PrestoCoordinator: Request images from self
    PrestoCoordinator-->>Browser: Serve images from self
    Browser->>ExternalImageHost: Attempt to load external images (http/https)
    ExternalImageHost-->>Browser: Image response
    Browser->>Browser: Block external images due to CSP img-src 'self' data:
    Browser->>Browser: Allow only self and data images to render
Loading

File-Level Changes

Change Details Files
Harden Web UI Content-Security-Policy img-src directive to remove wildcard-like HTTP/HTTPS allowances.
  • Updated the DEFAULT_WEBUI_CSP string constant to drop http: and https: from the img-src directive, leaving only 'self' and data: sources for images.
  • Preserved all other CSP directives (default-src, style-src, font-src, frame-ancestors, form-action) unchanged to minimize behavioral impact while addressing the security finding.
presto-main/src/main/java/com/facebook/presto/server/CoordinatorModule.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@adkharat adkharat changed the title fixed wildcard directive presto-ui - fixed wildcard directive Dec 12, 2025
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@adkharat adkharat changed the title presto-ui - fixed wildcard directive fix(presto-ui): restrict img-src wildcard in CSP Dec 12, 2025
@adkharat adkharat changed the title fix(presto-ui): restrict img-src wildcard in CSP fix: restrict img-src wildcard in CSP Dec 12, 2025
@adkharat adkharat changed the title fix: restrict img-src wildcard in CSP fix: Prestoui restrict img-src wildcard in CSP Dec 12, 2025
Copy link
Copy Markdown
Contributor

@nishithakbhaskaran nishithakbhaskaran left a comment

Choose a reason for hiding this comment

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

Can you help me understand how do the change fixes the issue

@nishithakbhaskaran
Copy link
Copy Markdown
Contributor

nishithakbhaskaran commented Dec 12, 2025

Also you can change the title something like fix(security): ..........

@adkharat
Copy link
Copy Markdown
Contributor Author

adkharat commented Dec 12, 2025

Can you help me understand how do the change fixes the issue

Removing http: https: eliminates scheme-wide allowances that permitted any external image host, closing the “wildcard/broad img-src” finding. Only images served from the UI origin or inline data URIs will load; everything else is blocked by the browser.
This directly addresses the CSP issue because the Content-Security-Policy header sent by the coordinator UI is the enforcement point; tightening the directive stops untrusted external image sources.

@adkharat adkharat changed the title fix: Prestoui restrict img-src wildcard in CSP fix(security): Prestoui restrict img-src wildcard in CSP Dec 12, 2025
Copy link
Copy Markdown
Contributor

@nishithakbhaskaran nishithakbhaskaran left a comment

Choose a reason for hiding this comment

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

Thanks for the fix @adkharat . LGTM!

@ajaykickdevops
Copy link
Copy Markdown

@yhwang and @tdcmeehan Can you please review the PR.

@prestodb-ci
Copy link
Copy Markdown
Contributor

@unidevel imported this issue as lakehouse/presto #26790

Copy link
Copy Markdown
Contributor

@unidevel unidevel left a comment

Choose a reason for hiding this comment

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

LGTM

@tdcmeehan tdcmeehan merged commit 6cd0529 into prestodb:master Dec 15, 2025
98 of 106 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

from:IBM PR from IBM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants