### Vulnerability Overview - **Vulnerability Name**: Cross-Site Scripting (XSS) Vulnerability in Pharmacy Sales and Inventory System V1.0 - **Vulnerability Type**: Cross-Site Scripting (XSS) - **Vulnerability Location**: The `id` parameter in the `/index.php?page=categories` file - **Vulnerability Cause**: The system fails to properly encode or filter user input, directly outputting it to the web page. This allows attackers to inject malicious script code. ### Impact Scope - **Affected Product**: Pharmacy Sales and Inventory System V1.0 - **Impact Description**: Attackers can exploit this vulnerability to steal user cookies, session tokens, or other sensitive information, perform unauthorized operations, and even gain full control over the victim's browser. ### Remediation Solutions 1. **Output Encoding**: Encode user input when outputting it to the web page. Different contexts (such as HTML, JavaScript, CSS, and URLs) require different encoding methods to ensure that input is treated as plain text rather than code. 2. **Input Validation and Filtering**: Strictly validate and filter user input data. Only allow data that conforms to the expected format, and reject or escape any potentially malicious content, such as script tags and event handlers. 3. **Implement Content Security Policy (CSP)**: Enforce a strict CSP to restrict the sources of scripts that can be executed on the web page, preventing the execution of unauthorized inline scripts and external scripts. 4. **Set Secure Cookie Flags**: For sensitive cookies (such as session cookies), set the `HttpOnly` flag to prevent access via JavaScript, and set the `Secure` flag to ensure they are transmitted only over HTTPS, thereby reducing the risk of cookie theft. 5. **Regular Security Audits**: Conduct regular code and system security audits to promptly identify and remediate potential XSS vulnerabilities and other security issues. ### POC Code ```html prompt(xss) ```