Title: [Security] Implement Client-Side Input Sanitization and XSS Prevention for All Forms
Description
The login (login.js), registration (register.js), checkout (checkout.js), and contact forms accept user input without sanitization. Script injection via form fields could lead to XSS attacks stored in localStorage or rendered in DOM.
Motivation
Even in a frontend-only application, XSS through innerHTML assignments or localStorage poisoning can steal session data or redirect users to phishing sites.
Implementation Suggestions
- Create a
sanitize.js utility module with functions: escapeHTML(), sanitizeInput(), validateEmail().
- Import and apply sanitization to all form submissions in
login.js, register.js, checkout.js, and contact.html.
- Replace all
innerHTML assignments with textContent where dynamic user data is rendered.
- Add Content-Security-Policy meta tag to all HTML files to block inline scripts.
Level: Critical
Affected Files: sanitize.js (new), login.js, register.js, checkout.js, all .html files
Title: [Security] Implement Client-Side Input Sanitization and XSS Prevention for All Forms
Description
The login (
login.js), registration (register.js), checkout (checkout.js), and contact forms accept user input without sanitization. Script injection via form fields could lead to XSS attacks stored inlocalStorageor rendered in DOM.Motivation
Even in a frontend-only application, XSS through
innerHTMLassignments orlocalStoragepoisoning can steal session data or redirect users to phishing sites.Implementation Suggestions
sanitize.jsutility module with functions:escapeHTML(),sanitizeInput(),validateEmail().login.js,register.js,checkout.js, andcontact.html.innerHTMLassignments withtextContentwhere dynamic user data is rendered.Level: Critical
Affected Files:
sanitize.js(new),login.js,register.js,checkout.js, all.htmlfiles