Skip to content

Render Laravel dd() output in a sandboxed iframe to fix XSS in Try It Out - #1094

Open
zhhngln wants to merge 1 commit into
knuckleswtf:v5from
zhhngln:fix-1092-try-it-out-sfdump-xss
Open

zhhngln wants to merge 1 commit into
knuckleswtf:v5from
zhhngln:fix-1092-try-it-out-sfdump-xss

Conversation

@zhhngln

@zhhngln zhhngln commented Nov 23, 2026

Copy link
Copy Markdown

Fixes #1092

handleResponse() inserted the whole response with innerHTML whenever it contained the substring Sfdump, before checking for JSON. A string field in normal API data such as Sfdump<img src=x onerror=...> therefore executed on the docs page, where it could read the auth token or make same-origin requests.

Changes:

  • Parse JSON first and show every ordinary response with textContent.
  • Only a non-JSON response that contains a real Symfony dump (<pre class=sf-dump) is shown, inside an <iframe sandbox="allow-scripts" srcdoc> with an opaque origin. The dump's toggle script still works but is isolated from the docs origin and window.lastAuthValue.
  • Clear the previous result and any previous iframe when a new request starts.

Tests: the repo has no JS test setup, so I checked the behaviour in headless Chrome. The payload stays literal in JSON and in raw text, and genuine dd() output renders and expands in the iframe. composer test passes (335). composer lint shows 2 existing PHPStan errors, unchanged by this change.

Try It Out inserted responses containing Sfdump as HTML before parsing JSON. This let API data create executable markup in the documentation page.

Parse JSON first and write ordinary responses as text. Render Symfony dump markup in a script-enabled iframe with an opaque origin so its controls still work. Clear the previous result when sending another request.

Fixes knuckleswtf#1092
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.

Try It Out renders any response containing "Sfdump" as HTML (XSS)

1 participant