Skip to content

fix: gate public presentation serialization on display_on_site for media uploads - #577

Open
JpMaxMan wants to merge 1 commit into
mainfrom
fix/presentation-media-upload-public-leak
Open

fix: gate public presentation serialization on display_on_site for media uploads#577
JpMaxMan wants to merge 1 commit into
mainfrom
fix/presentation-media-upload-public-leak

Conversation

@JpMaxMan

@JpMaxMan JpMaxMan commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Public/anonymous callers to the events/published endpoints could pull full PresentationMediaUpload data — including live public S3 URLs — for draft (display_on_site=false) uploads via ?expand=media_uploads, because PresentationSerializer read the unfiltered media uploads collection with no visibility check.

Reported externally: a third party's calendar/speaker-scraping AI agent recovered pre-event draft slide decks this way, with no malicious intent — it just added expand=media_uploads to a normal public schedule call.

ClickUp: https://app.clickup.com/t/86bb7zx8t

Root cause

  • GET /summits/{id}/events/published and GET /summits/{id}/events/{event_id}/published are fully public/unauthenticated and forward a caller-supplied expand with no allowlist.
  • PresentationSerializer::serialize() handled expand=media_uploads (and the relations id-list path) by calling Presentation::getMediaUploads() — unfiltered — and serializing every attached upload's public_url regardless of draft state.
  • display_on_site exists on PresentationMaterial/PresentationMediaUpload for exactly this distinction (defaults false), and SummitMediaUploadType::getMediaUploadsToDisplayOnSite() was even built to filter on it — but had zero callers in the API/serializer stack.

Fix

PresentationSerializer now resolves media uploads through a new getVisibleMediaUploads() helper: when the resolved serializer type is Public (the same admin/editor privilege check getMediaUploadsSerializerType() already performs), it filters to only display_on_site=true uploads before serializing. Applied at all three call sites in this file that read getMediaUploads() (cached-expand branch, plain relations id-list branch, main expand branch). AdminPresentationCSVSerializer (admin-only CSV export) is intentionally untouched.

Out of scope / follow-up (tracked in the ClickUp ticket)

  • This stops the URL from being served going forward — it does not revoke the public-read ACL already on previously-uploaded draft files. Rotating/regenerating already-exposed files (use_temporary_links_on_public_storage + the existing presentations-regenerate-media-uploads-temporal-public-urls command, or a longer-term private-storage migration) is a separate ops decision for @smarcet.

Test plan

  • Confirm ?expand=media_uploads on GET /summits/{id}/events/{id}/published (unauthenticated) no longer returns uploads with display_on_site=false
  • Confirm an admin/editor-authenticated request to the same endpoint still sees all uploads (draft + published) unchanged
  • Confirm AdminPresentationCSVSerializer export still includes all uploads regardless of display_on_site

Summary by CodeRabbit

  • Bug Fixes
    • Public presentation pages now display only media uploads marked for website visibility.
    • Private and administrative views continue to include all associated media uploads.
    • Media upload data remains consistently filtered across expanded and related presentation details.

…dia uploads

Public/anonymous callers to the events/published endpoints could pull full
PresentationMediaUpload data -- including live public S3 URLs -- for
draft (display_on_site=false) uploads via ?expand=media_uploads, since
PresentationSerializer read the unfiltered media uploads collection.
Reported externally: a third party's calendar-scraping agent recovered
pre-event draft slide decks this way.

getVisibleMediaUploads() now reuses the existing admin/editor privilege
check to filter to display_on_site=true uploads for Public callers, at
all three call sites in this file. AdminPresentationCSVSerializer
(admin-only) is untouched.
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

PresentationSerializer now hides media uploads from public serialization unless display_on_site=true. Private, admin, and editor serialization continues to include all media uploads across cached, relation-ID, and expanded serialization paths.

Changes

Presentation media visibility

Layer / File(s) Summary
Media-upload visibility filtering and serialization
app/ModelSerializers/Summit/Presentation/PresentationSerializer.php
Adds getVisibleMediaUploads() and applies it to cached media_uploads expansion, relation IDs, and expanded media-upload serialization. Private serializers retain all uploads.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: smarcet

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the change that gates public presentation serialization on media upload visibility.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/presentation-media-upload-public-leak

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/summit-api/openapi/pr-577/

This page is automatically updated on each push to this PR.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/ModelSerializers/Summit/Presentation/PresentationSerializer.php`:
- Line 153: Update PresentationSerializer cache-key generation to distinguish
public output from private/admin output resolved through
AdminPresentationSerializer, using a private serializer-specific key for private
data. Ensure cached relation IDs still pass through the appropriate visibility
rules before being returned, including the logic around getVisibleMediaUploads
and the related cache handling at the referenced later section.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6d0d53ee-95bd-4518-867f-495fd7dd1e9b

📥 Commits

Reviewing files that changed from the base of the PR and between 70ba47e and 90904aa.

📒 Files selected for processing (1)
  • app/ModelSerializers/Summit/Presentation/PresentationSerializer.php

$media_uploads = [];

foreach ($presentation->getMediaUploads() as $mediaUpload) {
foreach ($this->getVisibleMediaUploads() as $mediaUpload) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

# Expect private/editor callers to bypass this cache, or cache keys to include serializer type.
rg -n -C 12 'PresentationSerializer|public_presentation_|use_cache' .

Repository: OpenStackweb/summit-api

Length of output: 50380


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

# Inspect the relevant PresentationSerializer paths and all passing of use_cache.
printf '--- PresentationSerializer relevant lines ---\n'
sed -n '1,240p;400,430p' app/ModelSerializers/Summit/Presentation/PresentationSerializer.php | cat -n

printf '\n--- use_cache usages (concise) ---\n'
rg -n --glob '!adr/**' 'use_cache|SerializerRegistry::getInstance\(\)->getSerializer\(|serialize\(' app tests tests-api || true

Repository: OpenStackweb/summit-api

Length of output: 252


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

# Inspect the relevant PresentationSerializer paths and all passing of use_cache.
printf '%s\n' '--- PresentationSerializer relevant lines ---'
sed -n '1,240p;400,430p' app/ModelSerializers/Summit/Presentation/PresentationSerializer.php | cat -n

printf '%s\n' ''
printf '%s\n' '--- use_cache usages (concise) ---'
rg -n --glob '!adr/**' 'use_cache|SerializerRegistry::getInstance\(\)->getSerializer\(|serialize\(' app tests tests-api || true

Repository: OpenStackweb/summit-api

Length of output: 50380


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- exact use_cache references outside tests ---'
rg -n --glob '!adr/**' --glob '!tests/**' 'use_cache' app

printf '%s\n' ''
printf '%s\n' '--- exact use_cache references in tests ---'
rg -n 'use_cache' tests || true

printf '%s\n' ''
printf '%s\n' '--- parent cache key helpers/usages ---'
rg -n --glob '!adr/**' 'build.*[Cc]ache[Kk]ey|get.*Cache.*Key|Cache::put|Cache::has' app/ModelSerializers | head -n 120

Repository: OpenStackweb/summit-api

Length of output: 1247


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- OAuth2SummitEventsApiController cache calls context ---'
sed -n '520,700p' app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitEventsApiController.php | cat -n

printf '%s\n' ''
printf '%s\n' '--- route/controller declarations around protected events ---'
rg -n --glob '!adr/**' --glob '!tests/**' 'OAuth2SummitEventsApiController|Protected/Summit|summit/events|/presentations' app/routes app/Http/Controllers/Apis app/Http/Controllers -g '*.php' | head -n 200

Repository: OpenStackweb/summit-api

Length of output: 40762


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- SerializerRegistry resolved serializer and toArray ---'
sed -n '750,835p' app/ModelSerializers/SerializerRegistry.php | cat -n

printf '%s\n' ''
printf '%s\n' '--- OAuth2SummitEventsApiController serializer type logic ---'
sed -n '86,150p' app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitEventsApiController.php | cat -n

Repository: OpenStackweb/summit-api

Length of output: 7021


Keep private presentation cache keys isolated.

Private/admin endpoints pass use_cache => true and are resolved to AdminPresentationSerializer, while cached PresentationSerializer output key is only "public_presentation_...". Store private data under a private-serializer cache key and apply visibility rules to cached relation IDs.

Also applies to: 215-219

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/ModelSerializers/Summit/Presentation/PresentationSerializer.php` at line
153, Update PresentationSerializer cache-key generation to distinguish public
output from private/admin output resolved through AdminPresentationSerializer,
using a private serializer-specific key for private data. Ensure cached relation
IDs still pass through the appropriate visibility rules before being returned,
including the logic around getVisibleMediaUploads and the related cache handling
at the referenced later section.

* public events/published endpoints.
* @return \Doctrine\Common\Collections\Collection|PresentationMediaUpload[]
*/
protected function getVisibleMediaUploads()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@JpMaxMan This filter is an off switch rather than a draft gate, because display_on_site is false on essentially every existing row.

Nothing in the submission flow ever sets it true. PresentationMaterial::__construct (PresentationMaterial.php:190) defaults it false, PresentationMediaUploadFactory::populate (:39-40) only calls setDisplayOnSite when the key is present in the payload, and call-for-presentations - the app speakers actually upload through - has zero occurrences of display_on_site in src/. The only writer is summit-admin's material form checkbox, which itself starts unchecked (event-material-reducer.js:30).

Concrete failure: pub-api's snapshot job requests expand=media_uploads with a client_credentials token, which resolves Public here, so every media_uploads array in events.json and presentations.json comes back empty. pub-api does not validate response shape - it only raises on transport errors - so the snapshot publishes normally and SnapshotCompleted fires. dropbox-materializer then iterates sess["media_uploads"] with no filter of its own and stages nothing, for every session, silently.

Suggested: get a production count first -

SELECT DisplayOnSite, COUNT(*) FROM PresentationMaterial
WHERE ClassName = 'PresentationMediaUpload' GROUP BY DisplayOnSite;

and gate this behind a backfill plus a defined write path for the flag. Also worth a test pinning both branches - the PR's own test plan is still unchecked, and this is exactly the case where behaviour depends entirely on data.

{
$presentation = $this->object;
$mediaUploads = $presentation->getMediaUploads();
if ($this->getMediaUploadsSerializerType() === SerializerRegistry::SerializerType_Private) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@JpMaxMan Delegating to getMediaUploadsSerializerType() inherits a privilege gap this PR does not close: that method checks only isAdmin() || memberCanEdit(), so summit admins and service accounts both land on Public.

Compare OAuth2SummitEventsApiController::getSerializerType() (:127), which already resolves Private for isSummitAdmin() and for ApplicationType_Service. The presentation is served Private to those callers while its media uploads are served Public - the two decisions disagree.

Concrete failure, and it is circular: an operator in summit-front-end-administrators loads the summit-admin event grid, which requests media_uploads.display_on_site among its fields (event-actions.js:288) against GET /api/v1/summits/{id}/events. With this filter in place those rows disappear, so the operator cannot see the upload in order to tick the very checkbox that would make it visible again. The same gap is why pub-api's snapshot client gets Public output despite that controller granting service accounts Private.

Suggested: align getMediaUploadsSerializerType() with the check the controller already performs - Private for isSummitAdmin() as well as isAdmin(), and for service accounts. The application-type pattern has serializer-layer precedent at PresentationSpeakerBaseSerializer.php:104-109. For the service-account half I would require a dedicated snapshot scope rather than ApplicationType_Service alone, so this does not hand drafts to every service client.

{
$media_uploads = [];
foreach ($presentation->getMediaUploads() as $mediaUpload) {
foreach ($this->getVisibleMediaUploads() as $mediaUpload) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@JpMaxMan This call site never executes when caching is on, so the relations id-list path stays unfiltered.

The cached branch above returns at line 170, and on a cache hit it only recomputes media_uploads for the expand path. A request passing relations=media_uploads without expand=media_uploads gets the cached id array verbatim - built by whichever caller populated the key, filtered or not.

use_cache => true is set on the voteable-presentations endpoints (OAuth2SummitEventsApiController.php:554, :616, :685), which is where pub-api's presentations.json feed goes, so this is a live path rather than a theoretical one.

Suggested: handle the relations case inside the cache-hit branch the same way expand is handled, or drop media_uploads from the cached payload entirely and always recompute it after the cache lookup.

$media_uploads = [];

foreach ($presentation->getMediaUploads() as $mediaUpload) {
foreach ($this->getVisibleMediaUploads() as $mediaUpload) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@JpMaxMan Pre-existing rather than introduced here, but it undercuts this PR's premise, so flagging it on the branch you are touching: the cache key is not privilege-scoped.

It is built from presentation id, last_edited, expand, fields and relations with no serializer-type or user component, while getAllVoteablePresentations passes $this->getSerializerType(), which resolves Private or Public per caller. For one combination of params, a payload built by a Private caller can be served to a Public one, and vice versa.

Recomputing media_uploads here covers this PR's field, but every other field the Admin serializer contributes still comes straight off the shared key. So "Public callers only ever see approved uploads" is not guaranteed by construction while this stands.

Suggested: add the resolved serializer type to the key. Worth its own ticket rather than expanding this PR's scope.

@smarcet smarcet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@JpMaxMan please 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.

2 participants