Fixed XSS vulnerability report via Gallery shortcode - #8
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a reported stored XSS vector by ensuring gallery/shortcode IDs are sanitized (digits-only) and safely escaped before being used in lightbox-related HTML attributes and selectors, and when saved/consumed via the [easy_image_gallery] shortcode.
Changes:
- Added
easy_image_gallery_sanitize_gallery_id()and applied it across shortcode parsing and gallery ID comparisons. - Escaped lightbox grouping attributes (prettyPhoto/fancybox/luminous) and tightened URL escaping in gallery output.
- Bumped plugin version/readme stable tag and added a 1.5.5 security changelog entry.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| readme.txt | Updates stable tag and adds 1.5.5 security changelog notes. |
| includes/template-functions.php | Adds gallery ID sanitization + uses it for lightbox attributes/selectors and shortcode handling. |
| includes/metabox.php | Sanitizes gallery SHORTCODE values in the metabox UI and on save. |
| easy-image-gallery.php | Bumps plugin header version to 1.5.5. |
Comments suppressed due to low confidence (1)
includes/metabox.php:425
- When sanitizing
SHORTCODEon save, the fallback towp_rand( 100, 999 )risks collisions because the range is small. A collision could make two galleries share an ID, breaking shortcode targeting and lightbox grouping. Consider generating a larger/unique numeric ID and ensuring it does not duplicate any existingSHORTCODEvalues in$galleriesfor this post before saving.
if ( isset( $gallery['SHORTCODE'] ) ) {
$gallery['SHORTCODE'] = easy_image_gallery_sanitize_gallery_id( $gallery['SHORTCODE'] );
if ( '' === $gallery['SHORTCODE'] ) {
$gallery['SHORTCODE'] = (string) wp_rand( 100, 999 );
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+443
to
+450
| if ( $gallery_id == 'old_db' ) { | ||
| $gallery_id = easy_image_gallery_sanitize_gallery_id( $gallery['SHORTCODE'] ); | ||
| } else { | ||
| $gallery_id = easy_image_gallery_sanitize_gallery_id( $gallery_id ); | ||
| } | ||
|
|
||
| if ( '' === $gallery_id ) { | ||
| continue; |
metodiew
requested changes
May 20, 2026
metodiew
left a comment
Contributor
There was a problem hiding this comment.
@PGeorgiev Copilot suggestions make sense, let's update them and we'll run one more review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/DevriX/Easy-Image-Gallery/sessions/b985ebd2-5ad3-4217-82d8-5116911b3197 Co-authored-by: PGeorgiev <2990395+PGeorgiev@users.noreply.github.com>
metodiew
approved these changes
May 28, 2026
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.
Asana task [Easy Image Gallery: Closure Notice - Security: Easy Image Gallery]