# Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (CWE-79) The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. **Stack:** Python - Prevalence: उच्च बार-बार शोषित - Impact: क्रिटिकल 1 क्रिटिकल गंभीरता वाले नियम - Prevention: प्रलेखित 4 फिक्स उदाहरण **OWASP:** Injection (A03:2021-Injection) - #3 ## Description Cross-site scripting (XSS) vulnerabilities occur when untrusted data enters a web application and is sent to a web browser without proper validation or encoding. XSS allows attackers to execute scripts in the victim's browser which can hijack user sessions, deface web sites, or redirect the user to malicious sites. ## Prevention 1 Shoulder डिटेक्शन नियमों पर आधारित Cross-Site Scripting (XSS) के लिए रोकथाम रणनीतियाँ। ### Python Use template rendering with auto-escaping or html.escape() for manual escaping ## Warning Signs - [HIGH] untrusted user input being rendered in HTML responses without proper escaping ## Consequences - अनधिकृत कोड निष्पादित करना - सुरक्षा तंत्र को बायपास करना - एप्लिकेशन डेटा पढ़ना - एप्लिकेशन डेटा संशोधित करना ## Mitigations - एक सत्यापित लाइब्रेरी या फ़्रेमवर्क का उपयोग करें जो इस कमज़ोरी की अनुमति न दे - उस संदर्भ को समझें जिसमें आपका डेटा उपयोग होगा और अपेक्षित एनकोडिंग को जानें - प्रभाव कम करने के लिए Content Security Policy (CSP) का उपयोग करें ## Detection - Total rules: 4 - Critical: 1 - Languages: javascript, typescript, python ## Rules by Language ### Python (1 rules) - **Cross-Site Scripting (XSS) in Templates** [HIGH]: Detects untrusted user input being rendered in HTML responses without proper escaping. - Remediation: Use template rendering with auto-escaping, or escape manually with html.escape(). ```python import html safe_text = html.escape(user_input) ``` Learn more: https://shoulder.dev/learn/python/cwe-79/xss