Practical Exercise: Article Application

Complete this hands-on exercise to test your knowledge of the security fundamentals.

Task

Develop a straightforward “Commenting” application. The emphasis is on ensuring that the application is robust and does not have vulnerabilities that could lead to a Cross-Site Scripting (XSS) attack.

Instructions

  1. Modify the existing code to replace dangerouslySetInnerHTML with a safe alternative that still allows for text formatting and image embedding. Maybe look online for third-party libraries.

  2. Ensure that all user inputs are sanitized to prevent any malicious scripts from executing.

  3. Write tests to confirm that your changes have effectively eliminated the risk of XSS.

By completing this exercise, you’ll not only make the commenting system safer but also gain hands-on experience in writing secure code.

Coding playground

Get hands-on with 1400+ tech skills courses.