Skip to content

security: move OG image execution behind flag#10175

Merged
mscolnick merged 3 commits into
marimo-team:mainfrom
peter-gy:ptr/security-patch-og
Jul 15, 2026
Merged

security: move OG image execution behind flag#10175
mscolnick merged 3 commits into
marimo-team:mainfrom
peter-gy:ptr/security-patch-og

Conversation

@peter-gy

Copy link
Copy Markdown
Collaborator

Makes the OG image generator function's automatic execution opt-in through --execute-opengraph-generators flag to reduce risk of Remote Code Execution vulnerability.

Copilot AI review requested due to automatic review settings July 14, 2026 09:14
@peter-gy
peter-gy requested a review from akshayka as a code owner July 14, 2026 09:14
@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jul 14, 2026 10:17am

Request Review

@peter-gy peter-gy added the security Security-related finding label Jul 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jul 14, 2026
@peter-gy
peter-gy requested a review from mscolnick July 14, 2026 09:16

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 11 files

Architecture diagram
sequenceDiagram
    participant User as Client Browser
    participant CLI as CLI (marimo run)
    participant Server as Starlette Server
    participant SM as SessionManager
    participant AssetEP as Assets Endpoint (og_thumbnail)
    participant HomeEP as Home Endpoint
    participant IndexEP as Index Endpoint
    participant OGMod as resolve_opengraph_metadata
    participant FS as File System
    participant NB as Notebook App (generator fn)

    Note over User,NB: NEW: OpenGraph generator execution gated by flag

    User->>Server: GET / (index) or /api/home/files or /api/og-thumbnail

    alt Index page request
        Server->>IndexEP: handle index request
        IndexEP->>SM: get execute_opengraph_generators
        SM-->>IndexEP: flag (bool)
        IndexEP->>OGMod: resolve_opengraph_metadata(execute_generator=flag)
        OGMod->>FS: read notebook file for og config
        FS-->>OGMod: config (maybe with generator name)
        alt generator declared AND execute_generator == True
            OGMod->>NB: execute _run_opengraph_generator()
            NB->>NB: run notebook-defined code
            NB-->>OGMod: dynamic metadata (e.g., title, image)
        else generator absent OR execute_generator == False
            Note over OGMod: skip generator execution (safe default)
        end
        OGMod-->>IndexEP: resolved OpenGraphMetadata
        IndexEP-->>User: HTML with og tags
    else Home endpoint (file listing) request
        Server->>HomeEP: get_files_with_metadata()
        HomeEP->>SM: get execute_opengraph_generators
        SM-->>HomeEP: flag
        HomeEP->>OGMod: resolve_opengraph_metadata(execute_generator=flag) per file
        OGMod->>FS: read file
        OGMod-->>HomeEP: metadata
        HomeEP-->>User: FileInfo with og title (static only if flag false)
    else OG thumbnail request
        User->>Server: GET /api/og-thumbnail?file=...
        Server->>AssetEP: og_thumbnail()
        AssetEP->>SM: get execute_opengraph_generators
        SM-->>AssetEP: flag
        AssetEP->>OGMod: resolve_opengraph_metadata(execute_generator=flag)
        OGMod->>FS: read file config
        OGMod-->>AssetEP: metadata
        AssetEP-->>User: image redirect or static OG image
    end

    Note over CLI,SM: Flag originates from CLI or ASGI builder
    CLI->>Server: start(execute_opengraph_generators=True/False)
    Server->>SM: SessionManager(execute_opengraph_generators=flag)
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread marimo/_cli/cli.py
Comment thread marimo/_server/templates/templates.py
Comment thread docs/guides/publishing/opengraph.md Outdated
Comment thread marimo/_server/asgi.py
Comment thread marimo/_metadata/opengraph.py
Comment thread marimo/_cli/cli.py Outdated

@dmadisetti dmadisetti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! I think this is a great compromise

@mscolnick
mscolnick merged commit ce80ac0 into marimo-team:main Jul 15, 2026
45 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.15-dev16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation security Security-related finding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants