Skip to content

Fix PHP unserialize() security issues reported by security researcher - #1699

Merged
cpeel merged 8 commits into
DistributedProofreaders:masterfrom
bpfoley:security-1
Oct 27, 2026
Merged

cpeel merged 8 commits into
DistributedProofreaders:masterfrom
bpfoley:security-1

Conversation

@bpfoley

@bpfoley bpfoley commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Edit by @cpeel: This PR addresses a XSS vulnerability in two Project Manager scripts that was responsibly disclosed by @Santoshkumarpuppala. Thank you to them for alerting us to this and allowing us time to fix them.

bpfoley and others added 8 commits October 26, 2026 13:43
YAZ only uses list<list<string>> as its (partly-decoded) data type,
so we can encode this as JSON. It avoids security issues associated
with PHP's serialization format, as well as being human readable.
(this doesn't really matter because this is just test code, but
it serves as a good example in case someone copies and pastes code).
This avoids PHP unserialize() attacks.

And validate the base64 decoding, decompression, and JSON decoding.

Make base64url_decode strict while we're here.
The fq param is derived from a Z39.50 query, represented as a list
of search terms strings such as
[ "@and", "@attr 1=1003 \"Doctorow, Cory\"", "@attr 1=1018 \"Penguin\""]

Encode this using URL-safe base64 encoded JSON and strictly validate
the user input, to avoid PHP unserialize() attacks.

And HTML escape the raw Z39.50 query. It can legitimately contain
HTML special charcater.
...to restrict the scope of any security issues.
….php

rec is used to prepopulate author and title fields in the new project
form, and is user provided, like rec in marc_inspector.php.
Encode it as base64url-ed, compressed, json encoded data and strictly
validate it on reading to avoid PHP unserialize() security issues.
hold_states is a list of state strings, eg ["P1.proj_waiting","P3.proj_avail"]
Encode this as base64url encoded JSON, and strictly parse it when
decoding to avoid PHP unserialize() security issues.
@cpeel
cpeel self-requested a review October 27, 2026 17:02

@bpfoley bpfoley left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

LGTM. And thankyou Santosh.

@cpeel
cpeel merged commit f98ba0e into DistributedProofreaders:master Oct 27, 2026
12 checks passed
@bpfoley
bpfoley deleted the security-1 branch October 27, 2026 17:05
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