The issue arises from the plugin's failure to ensure that uploaded SVG files added to a gallery do not contain malicious content. This allows users who can add images to the gallery to upload an SVG file containing JavaScript code. When the image is accessed directly, for example in the /wp-content/uploads/photo-gallery/ folder, the JavaScript code is executed, leading to a Cross-Site Scripting (XSS) issue.