Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.

Conversation

@WirelessLife
Copy link
Collaborator

Potential fix for https://github.com/microsoft/AcademicContent/security/code-scanning/16

To fix the reflected XSS vulnerability, we should ensure that any user-provided data is properly sanitized before being stored or returned in API responses. Since the /api/posts endpoint returns all posts, including those created by users, we should escape any potentially dangerous content before sending it in the response. The best way to do this is to encode/escape all string fields in each post before sending the response. We can use a well-known library such as escape-html to escape HTML special characters in string fields. This can be done by mapping over the posts array and escaping all string fields in each post before sending the response in the /api/posts GET handler.

Required changes:

  • Add the escape-html import at the top of the file.
  • In the /api/posts GET handler, map over the posts array and escape all string fields in each post before sending the response.

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

…ripting

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@WirelessLife WirelessLife marked this pull request as ready for review August 20, 2025 19:18
@WirelessLife WirelessLife merged commit 7626f30 into main Aug 20, 2025
7 checks passed
@WirelessLife WirelessLife deleted the alert-autofix-16 branch August 20, 2025 19:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants