Repository navigation
Fix PHP unserialize() security issues reported by security researcher - #1699
Merged
Merged
Conversation
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
self-requested a review
October 27, 2026 17:02
cpeel
approved these changes
Oct 27, 2026
bpfoley
commented
Oct 27, 2026
bpfoley
left a comment
Collaborator
Author
There was a problem hiding this comment.
LGTM. And thankyou Santosh.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.