

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
12345# JavaScript Injection Security Rule67<rule>8name: javascript_injection9description: Identifies and helps prevent injection vulnerabilities in JavaScript applications, as defined in OWASP Top 10:2021-A03.1011actions:12 - type: enforce13 conditions:14 - pattern: "eval\\(([^)]*(req|request|query|param|user|input)[^)]*)\\)"15 severity: "critical"16 message: |17 🔴 CRITICAL: Potential code injection vulnerability detected.1819 Impact: Attackers can execute arbitrary code in your application context.20 CWE Reference: CWE-95 (Improper Neutralization of Directives in Dynamically Evaluated Code)2122 ❌ Insecure:23 eval(req.body.data)2425 ✅ Secure Alternative:26 // Use safer alternatives like JSON.parse for JSON data27 try {28 const data = JSON.parse(req.body.data);29 // Process data safely30 } catch (error) {31 // Handle parsing errors32 }33 learn_more_url: "https://owasp.org/www-community/attacks/Direct_Dynamic_Code_Evaluation_Eval_Injection"3435 - pattern: "\\$\\(\\s*(['\"])<[^>]+>\\1\\s*\\)"36 severity: "high"37 message: |38 🟠 HIGH: jQuery HTML injection vulnerability detected.3940 Impact: This can lead to Cross-Site Scripting (XSS) attacks.41 CWE Reference: CWE-79 (Improper Neutralization of Input During Web Page Generation)4243 ❌ Insecure:44 $("<div>" + userProvidedData + "</div>")4546 ✅ Secure Alternative:47 // Create element safely, then set text content48 const div = $("<div></div>");49 div.text(userProvidedData);50 learn_more_url: "https://cheatsheetseries.owasp.org/cheatsheets/jQuery_Security_Cheat_Sheet.html"5152 - pattern: "document\\.write\\(|document\\.writeln\\("53 severity: "high"54 message: |55 🟠 HIGH: Potential DOM-based XSS vulnerability.5657 Impact: Attackers can inject malicious HTML/JavaScript into your page.58 CWE Reference: CWE-79 (Improper Neutralization of Input During Web Page Generation)5960 ❌ Insecure:61 document.write("<h1>" + userGeneratedContent + "</h1>");6263 ✅ Secure Alternative:64 // Use safer DOM manipulation methods65 const h1 = document.createElement("h1");66 h1.textContent = userGeneratedContent;67 document.body.appendChild(h1);68 learn_more_url: "https://cheatsheetseries.owasp.org/cheatsheets/DOM_based_XSS_Prevention_Cheat_Sheet.html"6970 - pattern: "innerHTML\\s*=|outerHTML\\s*="71 pattern_negate: "sanitize|DOMPurify|escapeHTML"72 severity: "high"73 message: |74 🟠 HIGH: Potential DOM-based XSS through innerHTML/outerHTML.7576 Impact: Setting HTML content directly can allow script injection.77 CWE Reference: CWE-79 (Improper Neutralization of Input During Web Page Generation)7879 ❌ Insecure:80 element.innerHTML = userProvidedData;8182 ✅ Secure Alternative:83 // Option 1: Use textContent instead for text84 element.textContent = userProvidedData;8586 // Option 2: Sanitize if HTML is required87 import DOMPurify from 'dompurify';88 element.innerHTML = DOMPurify.sanitize(userProvidedData);89 learn_more_url: "https://cheatsheetseries.owasp.org/cheatsheets/DOM_based_XSS_Prevention_Cheat_Sheet.html"9091 - pattern: "\\$\\(.*\\)\\.html\\("92 pattern_negate: "sanitize|DOMPurify|escapeHTML"93 severity: "high"94 message: |95 🟠 HIGH: jQuery HTML injection risk detected.9697 Impact: Setting HTML content can lead to XSS vulnerabilities.98 CWE Reference: CWE-79 (Improper Neutralization of Input During Web Page Generation)99100 ❌ Insecure:101 $("#element").html(userProvidedData);102103 ✅ Secure Alternative:104 // Option 1: Use text() instead for text105 $("#element").text(userProvidedData);106107 // Option 2: Sanitize if HTML is required108 import DOMPurify from 'dompurify';109 $("#element").html(DOMPurify.sanitize(userProvidedData));110 learn_more_url: "https://cheatsheetseries.owasp.org/cheatsheets/jQuery_Security_Cheat_Sheet.html"111112 - pattern: "require\\(([^)]*(req|request|query|param|user|input)[^)]*)\\)"113 severity: "critical"114 message: |115 🔴 CRITICAL: Dynamic require() can lead to remote code execution.116117 Impact: Attackers can load arbitrary modules or access sensitive files.118 CWE Reference: CWE-95 (Improper Neutralization of Directives in Dynamically Evaluated Code)119120 ❌ Insecure:121 const module = require(req.query.module);122123 ✅ Secure Alternative:124 // Use a whitelisproach125 const allowedModules = {126 'user': './modules/user',127 'product': './modules/product'128 };129130 const moduleName = req.query.module;131 if (allowedModules[moduleName]) {132 const module = require(allowedModules[moduleName]);133 // Use module safely134 } else {135 // Handle invalid module request136 }137 learn_more_url: "https://owasp.org/www-project-top-ten/2017/A1_2017-Injection"138139 - pattern: "exec\\(([^)]*(req|request|query|param|user|input)[^)]*)\\)"140 severity: "critical"141 message: |142 🔴 CRITICAL: Command injection vulnerability detected.143144 Impact: Attackers can execute arbitrary system commands.145 CWE Reference: CWE-78 (Improper Neutralization of Special Elements used in an OS Command)146147 ❌ Insecure:148 exec('ls ' + userInput, (error, stdout, stderr) => {149 // Process output150 });151152 ✅ Secure Alternative:153 // Use child_process.execFile with separate arguments154 import { execFile } from 'child_process';155156 execFile('ls', [safeDirectory], (error, stdout, stderr) => {157 // Process output safely158 });159160 // Or use a validation library to sanitize inputs161 import validator from 'validator';162 if (validator.isAlphanumeric(userInput)) {163 exec('ls ' + userInput, (error, stdout, stderr) => {164 // Process output165 });166 }167 learn_more_url: "https://cheatsheetseries.owasp.org/cheatsheets/OS_Command_Injection_Defense_Cheat_Sheet.html"168169 - type: suggest170 message: |171 **JavaScript Injection Prevention Best Practices:**172173 1. **Input Validation:**174 - Validate all user inputs both client-side and server-side175 - Use allowlists instead of blocklists176 - Apply strict type checking and schema validation177178 2. **Output Encoding:**179 - Always encode/escape output in the correct context (HTML, JavaScript, CSS, URL)180 - Use libraries like DOMPurify for HTML sanitization181 - Avoid building HTML, JavaScript, SQL dynamically from user inputs182183 3. **Content Security Policy (CSP):**184 - Implement a strict CSP to prevent execution of malicious scripts185 - Use nonce-based or hash-based CSP to allow only specific scripts186187 4. **Structured Data Formats:**188 - Use structured data formats like JSON, XML with proper parsers189 - Avoid manually parsing or constructing these formats190191 5. **Parameterized APIs:**192 - Use parameterized APIs for database queries, OS commands193 - Separate code from data to prevent injection194195 6. **DOM Manipulation:**196 - Prefer .textContent over .innerHTML when displaying user content197 - Use document.createElement() and node methods instead of directly setting HTML198199 7. **Frameworks and Libraries:**200 - Keep frameworks and libraries updated to latest secure versions201 - Many modern frameworks offer built-in protections against common injection attacks202203metadata:204 priority: critical205 version: 1.1206 tags:207 - language:javascript208 - category:security209 - standard:owasp-top10210 - risk:a03-injection211 references:212 - "https://owasp.org/Top10/A03_2021-Injection/"213 - "https://cheatsheetseries.owasp.org/cheatsheets/Injection_Prevention_Cheat_Sheet.html"214 - "https://nodegoat.herokuapp.com/tutorial/a1"215 - "https://github.com/OWASP/NodeGoat"216</rule>217
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| ivangrynenko/cursorrules.cursor/rules/cursor-rules.mdc · 86 | Cursor rules | teststylearchgit+2 | 77/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/behat-steps.mdc · 86 | Cursor rules | lint-formatstyleperformanceagent-behaviour | 42/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/php-drupal-development-standards.mdc · 86 | Cursor rules | no sections | 34/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/python-insecure-design.mdc · 86 | Cursor rules | no sections | 40/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/python-cryptographic-failures.mdc · 86 | Cursor rules | security | 40/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/python-injection.mdc · 86 | Cursor rules | styledo-not | 51/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/node-dependencies.mdc · 86 | Cursor rules | no sections | 16/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/behat-ai-guide.mdc · 86 | Cursor rules | testtesting-strategydo-not | 45/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/new-pull-request.mdc · 86 | Cursor rules | archtesting-strategygitsecurity+3 | 58/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/accessibility-standards.mdc · 86 | Cursor rules | ui | 44/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/api-standards.mdc · 86 | Cursor rules | api | 44/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/build-optimization.mdc · 86 | Cursor rules | build | 48/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/code-generation-standards.mdc · 86 | Cursor rules | lint-formatstyletypesdocs | 52/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/confluence-editing-standards.mdc · 86 | Cursor rules | stylearchsecuritydeployment | 60/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/debugging-standards.mdc · 86 | Cursor rules | no sections | 30/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/docker-compose-standards.mdc · 86 | Cursor rules | style | 62/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-authentication-failures.mdc · 86 | Cursor rules | security | 48/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-broken-access-control.mdc · 86 | Cursor rules | stylesecurity | 52/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-cryptographic-failures.mdc · 86 | Cursor rules | security | 48/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-database-standards.mdc · 86 | Cursor rules | database | 30/100 | 14 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 14 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 14 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 14 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 14 days ago | |
| skillrecordings/egghead-next.cursor/rules/gh-task-plan.mdc · 1.4k | Cursor rules | teststylearchtypes+2 | 96/100 | 14 days ago | |
| skillrecordings/egghead-next.cursor/rules/project-update-rules.mdc · 1.4k | Cursor rules | buildtestlint-formatstyle+7 | 96/100 | 14 days ago | |
| skillrecordings/egghead-next.cursor/rules/project-update-user-rules.mdc · 1.4k | Cursor rules | buildtestlint-formatstyle+7 | 96/100 | 14 days ago | |
| hiromaily/go-crypto-wallet.cursor/rules/proto.mdc · 126 | Cursor rules | buildlint-formatstylearch+3 | 96/100 | 14 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/ivangrynenko-cursorrules-cursor-rules-javascript-injection)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.
Directory