Skip to content

Conversation

@arnayv-47
Copy link

Potential fix for https://github.com/GSA/eoc/security/code-scanning/25

To fix this vulnerability, we need to ensure that the value retrieved from the data-lazy attribute (imageSource) is safe before using it as the src attribute of an image. The best way is to validate that imageSource is a URL with an allowed protocol (e.g., http:, https:, or maybe data:), and does not start with dangerous schemes like javascript: or vbscript:.

The change should be applied in the loadImages function, specifically before setting imageToLoad.src and/or image.attr('src', imageSource). If the value is invalid, we should skip loading the image and mark it as an error.

To implement this, we need a helper function to validate image URLs. We can define a simple validator within the same file, above the loadImages function.


Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…as HTML

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@arnayv-47 arnayv-47 marked this pull request as ready for review July 21, 2025 20:08
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