Skip to content

Fixes for a second round of XSS security issues found by Psalm's taint analysis. - #1719

Merged
cpeel merged 28 commits into
DistributedProofreaders:masterfrom
bpfoley:xss-2
Nov 22, 2026
Merged

cpeel merged 28 commits into
DistributedProofreaders:masterfrom
bpfoley:xss-2

Conversation

@bpfoley

@bpfoley bpfoley commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

…TP_HOST

(Although in practice, with virtual hosting, the caller may not be
able to set the Host: header in the HTTP request to anything other than
the hostname of the web server.)
While here, quell Psalm warning when printing usernames.
While here, use attr_safe on all the user input, despite it being
validated to quell Psalm warnings.
Ironically this happens with user-provided paths that fail to validate.
It just echos the entire thing unescaped.
…rn= param

And while here sprinkle more defensive escaping (partly to quell Psalm
warnings)
… controllable code_name

(It's escaped elsewhere in the script)
…r names

The script correctly validates the name for eg, path traversal issues,
or using unsafe characters, for all filesystem activities such as
renaming a file or creating a directory, but then drops the ball at the
last step and  shows the unescaped name in the fatal error message :(
… XSS in word= param

It displays an unescaped version of the word= param, both undecoded if
base16 decoding fails, and decoded if base16 decoding succeeds. Oy.
It displays an unescaped version of the word= param, both undecoded if
base16 decoding fails, and decoded if base16 decoding succeeds. Oy.
This is probably harmless, but on the off chance that the
FileUploadException can contain user-controlled characters, we should
probably do this. Also it quells a Psalm taint warning.
We know valid usernames don't contain special HTML characters, but with
the current structure of the code, Psalm can't see this.
by escaping HTML attributes. All of these are validated or are
simple strings with no HTML special characters already, but Psalm
can't see this, as belt-and-braces and to quell the warning, escape them
anyway.
via echo_page_table. Not actually exploitable because page_detail.php
validates selected_pages param in a way Psalm doesn't understand.
…e cookie

While here, HTML escape all the other displayed info just to be safe.
This is an XSS exploit if the HTTP client sends non-percent encoded
params (including ones unused by the page)
This can be set to any string up to 25 characters in length.
And while here, fail early if stage_id isn't a valid stage to prevent
ugly error messages later. (It also incidentally makes the escaping
unnecessary, but belt-and-braces in case this code is ever refactored)
These all happen to be inputs that are restricted to a particular set
(although Psalm can't quite see it), or HTML-safe usernames.
These are server-controlled and practically speaking, will be HTML-safe
strings, but Psalm doesn't know this, so to quell its warnings and be on
the safe side, escape them.
…forms

In practice, these are server-controlled random IDs like
"icon_1234567890123.png" with no HTML special characters in them
(see $avatarID and $iconID), but escape them to quell Psalm's warnings.
Amusingly, the row= and col= params couldn't be used for XSS because
the table_pad function 'accidentally' validated these params as
integers by throwing a TypeError if they weren't numeric-strings

While here, fix a padding error.
All of the inputs were sufficiently validated/constrained that
they're not XSS-able, but Psalm couldn't see that.
@cpeel
cpeel merged commit f4439db into DistributedProofreaders:master Nov 22, 2026
12 checks passed
@bpfoley
bpfoley deleted the xss-2 branch November 22, 2026 19:39
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