From a report to security@
# Stored XSS through PageForms `#autoedit` redirect links
## Summary
PageForms accepts the `redirect` parameter of the `#autoedit` parser
function and places it directly into the `href` attribute of a
generated anchor. A user who can edit an ordinary page can therefore
publish a `javascript:` URL. A visitor who clicks the generated
auto-edit link executes attacker-controlled JavaScript in the wiki
origin.
## Affected code
`extensions/PageForms/includes/parserfunctions/PFAutoEdit.php` assigns
the parser-function `redirect` value to `$linkToPage` and passes it to
`Html::rawElement( 'a', ... )` without URL-scheme validation. The same
value is used for the generated link branch at approximately lines
143–168 in the audited checkout.
## Security impact
Stored same-origin XSS. The attacker needs ordinary page-edit
permission. The victim only needs to view the page and click the
rendered auto-edit link. JavaScript executes with the wiki origin and
can act as the victim, subject to the site’s existing browser
controls.
## Reproduction
1. As an ordinary editor, save a page containing the PoC in `poc.md`.
2. View the page while logged in to the local MediaWiki instance.
3. Click `Trigger`.
4. The page body receives the `data-pf-autoedit` attribute, proving
JavaScript execution from the generated link.
## Expected behavior
`redirect` should be restricted to a safe internal destination or
emitted through a URL sanitizer that rejects executable schemes. If an
external destination is intended, it should be validated and handled
as an explicit external URL rather than copied into a raw anchor.
===== PROOF OF CONCEPT =====
# PageForms `#autoedit` redirect XSS PoC
Save this wikitext in an ordinary editable page:
```text
{{#autoedit:link text=Trigger|link type=link|target=Main
Page|redirect=javascript:document.body.setAttribute('data-pf-autoedit','PF_AUTOEDIT_REDIRECT_TEST')}}When a visitor clicks Trigger, the generated anchor navigates to the
JavaScript URL and sets:
text data-pf-autoedit=PF_AUTOEDIT_REDIRECT_TEST
The local validation used the same payload through a real NormalUser
edit and a Chromium mouse click.