[{"data":1,"prerenderedAt":432},["ShallowReactive",2],{"rule-innerhtml-usage":3},{"id":4,"title":5,"body":6,"breadcrumb":395,"coderail":402,"dateModified":421,"datePublished":421,"description":422,"extension":423,"meta":424,"navigation":425,"next":421,"path":426,"prev":421,"schemaType":427,"seo":428,"stem":429,"wide":430,"__hash__":431},"docs\u002Frules\u002Finnerhtml-usage.md","innerHTML assignment detected",{"type":7,"value":8,"toc":387},"minimark",[9,16,58,63,78,82,104,108,250,254,293,297,355,359,383],[10,11,12],"p",{},[13,14,15],"strong",{},"Summary",[17,18,19,30,40,46,52],"ul",{},[20,21,22,25,26],"li",{},[13,23,24],{},"rule_id"," — ",[27,28,29],"code",{},"innerhtml-usage",[20,31,32,35,36,39],{},[13,33,34],{},"purpose"," — Detect Custom HTML tags that assign to ",[27,37,38],{},".innerHTML",", a pattern that can introduce XSS when content includes user-controlled data",[20,41,42,45],{},[13,43,44],{},"effect"," — Flags all matching tags for human review; rule cannot distinguish static from dynamic assignments",[20,47,48,51],{},[13,49,50],{},"layer"," — container",[20,53,54,57],{},[13,55,56],{},"reversibility"," — non-destructive",[59,60,62],"h2",{"id":61},"what-fires-this","What fires this",[10,64,65,66,69,70,73,74,77],{},"The rule calls ",[27,67,68],{},"getHtmlTags()"," and filters for tags where ",[27,71,72],{},"codeAnalysis.hasInnerHTML"," is true. The parser sets that flag when it finds a ",[27,75,76],{},".innerHTML ="," assignment in the tag code. Every matching active tag is flagged — the rule does not distinguish static string assignments from user-controlled interpolation. Manual triage is required when this rule fires. Paused tags are excluded.",[59,79,81],{"id":80},"why-it-matters","Why it matters",[10,83,84,87,88,91,92,95,96,99,100,103],{},[27,85,86],{},"innerHTML"," assignment triggers a full HTML parse of the assigned string and executes any ",[27,89,90],{},"\u003Cscript>"," tags or event-handler attributes it contains. When the assigned content includes user-controlled data — URL parameters, cookie values, or dataLayer fields sourced from user input — the assignment becomes a cross-site scripting (XSS) vector. Static assignments are lower risk but create a pattern that future developers may extend with dynamic content without recognizing the implication. ",[27,93,94],{},"textContent"," is the correct replacement for text; ",[27,97,98],{},"createElement"," and ",[27,101,102],{},"appendChild"," are correct for structured HTML.",[59,105,107],{"id":106},"example","Before \u002F after",[109,110,111,197],"compare",{},[112,113,115],"compare-col",{"label":114},"Before — flagged",[116,117,122],"pre",{"className":118,"code":119,"language":120,"meta":121,"style":121},"language-js shiki shiki-themes github-light github-dark","\u002F\u002F Tag injects a banner message from a URL param\nconst msg = new URLSearchParams(location.search).get('msg')\ndocument.querySelector('#banner').innerHTML = msg  \u002F\u002F XSS vector\n","js","",[27,123,124,133,171],{"__ignoreMap":121},[125,126,129],"span",{"class":127,"line":128},"line",1,[125,130,132],{"class":131},"sJ8bj","\u002F\u002F Tag injects a banner message from a URL param\n",[125,134,136,140,144,147,150,154,158,161,164,168],{"class":127,"line":135},2,[125,137,139],{"class":138},"szBVR","const",[125,141,143],{"class":142},"sj4cs"," msg",[125,145,146],{"class":138}," =",[125,148,149],{"class":138}," new",[125,151,153],{"class":152},"sScJk"," URLSearchParams",[125,155,157],{"class":156},"sVt8B","(location.search).",[125,159,160],{"class":152},"get",[125,162,163],{"class":156},"(",[125,165,167],{"class":166},"sZZnC","'msg'",[125,169,170],{"class":156},")\n",[125,172,174,177,180,182,185,188,191,194],{"class":127,"line":173},3,[125,175,176],{"class":156},"document.",[125,178,179],{"class":152},"querySelector",[125,181,163],{"class":156},[125,183,184],{"class":166},"'#banner'",[125,186,187],{"class":156},").innerHTML ",[125,189,190],{"class":138},"=",[125,192,193],{"class":156}," msg  ",[125,195,196],{"class":131},"\u002F\u002F XSS vector\n",[112,198,200],{"label":199},"After — fixed",[116,201,203],{"className":118,"code":202,"language":120,"meta":121,"style":121},"\u002F\u002F Safe: textContent for text, no script execution possible\nconst msg = new URLSearchParams(location.search).get('msg')\ndocument.querySelector('#banner').textContent = msg\n",[27,204,205,210,232],{"__ignoreMap":121},[125,206,207],{"class":127,"line":128},[125,208,209],{"class":131},"\u002F\u002F Safe: textContent for text, no script execution possible\n",[125,211,212,214,216,218,220,222,224,226,228,230],{"class":127,"line":135},[125,213,139],{"class":138},[125,215,143],{"class":142},[125,217,146],{"class":138},[125,219,149],{"class":138},[125,221,153],{"class":152},[125,223,157],{"class":156},[125,225,160],{"class":152},[125,227,163],{"class":156},[125,229,167],{"class":166},[125,231,170],{"class":156},[125,233,234,236,238,240,242,245,247],{"class":127,"line":173},[125,235,176],{"class":156},[125,237,179],{"class":152},[125,239,163],{"class":156},[125,241,184],{"class":166},[125,243,244],{"class":156},").textContent ",[125,246,190],{"class":138},[125,248,249],{"class":156}," msg\n",[59,251,253],{"id":252},"remediation","Remediation",[255,256,257,263,266,272,275,282,290],"ol",{},[20,258,259,260,262],{},"Open each flagged tag and locate the ",[27,261,76],{}," assignment.",[20,264,265],{},"Identify what value is being assigned — a static string, a variable, or an expression.",[20,267,268,269,271],{},"If the value is a static string with no runtime components, replace with ",[27,270,94],{}," or a DOM-construction approach.",[20,273,274],{},"If the value includes any variable that could originate from URL parameters, cookies, or user input, treat this as an active XSS risk and prioritize replacement.",[20,276,277,278,281],{},"For text content, use ",[27,279,280],{},"el.textContent = value",".",[20,283,284,285,99,287,289],{},"For HTML structure, use ",[27,286,98],{},[27,288,102],{}," rather than a string template.",[20,291,292],{},"If the assignment comes from a vendor snippet you cannot modify, document the risk and confirm the snippet source is always static.",[59,294,296],{"id":295},"metadata","Metadata",[298,299,302,303,308,302,312,316,302,319,323,302,326,329,302,332,336,302,339,343,302,349,352],"dl",{"className":300},[301],"spec-list","\n  ",[304,305,307],"dt",{"id":306},"severity","Severity",[309,310,311],"dd",{},"low",[304,313,315],{"id":314},"tier","Tier",[309,317,318],{},"optimization",[304,320,322],{"id":321},"category","Category",[309,324,325],{},"security",[304,327,328],{"id":50},"Layer",[309,330,331],{},"container",[304,333,335],{"id":334},"version","Version",[309,337,338],{},"1",[304,340,342],{"id":341},"effort","Effort",[309,344,345,348],{},[27,346,347],{},"2hr"," (about 2 hours)",[304,350,351],{"id":56},"Reversibility",[309,353,354],{},"non-destructive",[59,356,358],{"id":357},"see-also","See also",[17,360,361,369,376],{},[20,362,363,368],{},[364,365,367],"a",{"href":366},"\u002Fcategories\u002Fsecurity\u002F","Security rules"," — other rules in this category",[20,370,371,375],{},[364,372,374],{"href":373},"\u002Fhealth-score\u002F","Health score"," — how this rule contributes to the score",[20,377,378,382],{},[364,379,381],{"href":380},"\u002Frules\u002F","Rules catalog"," — browse all rules",[384,385,386],"style",{},"html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":121,"searchDepth":135,"depth":135,"links":388},[389,390,391,392,393,394],{"id":61,"depth":135,"text":62},{"id":80,"depth":135,"text":81},{"id":106,"depth":135,"text":107},{"id":252,"depth":135,"text":253},{"id":295,"depth":135,"text":296},{"id":357,"depth":135,"text":358},[396,399,401],{"label":397,"href":398},"API Reference","\u002F",{"label":400,"href":380},"Rules",{"label":29},{"cards":403,"onpage":415},[404],{"title":405,"tabs":406},"Evaluate",[407,411],{"label":408,"language":409,"code":410},"cURL","bash","curl https:\u002F\u002Fdeveloper.tagmanifest.com\u002Fv1\u002Fevaluate-rule \\\n  -H \"Authorization: Bearer $TM_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"rule_id\":\"innerhtml-usage\",\"url\":\"https:\u002F\u002Fexample.com\"}'\n",{"label":412,"language":413,"code":414},"MCP","text","User: Run innerhtml-usage on https:\u002F\u002Fexample.com\n\n# Tool call\n{\n  \"tool\": \"evaluate_rule\",\n  \"arguments\": {\n    \"rule_id\": \"innerhtml-usage\",\n    \"url\": \"https:\u002F\u002Fexample.com\"\n  }\n}\n",[416,417,418,419,420],{"id":61,"label":62},{"id":80,"label":81},{"id":106,"label":107},{"id":252,"label":253},{"id":295,"label":296},null,"Tags assign to innerHTML, which can execute embedded scripts if the content includes user-controlled data. Use textContent or DOM methods instead.","md",{},true,"\u002Frules\u002Finnerhtml-usage","TechArticle",{"title":5,"description":422},"rules\u002Finnerhtml-usage",false,"6hYmKBSdb8yVT8YPe0E_AikYsIaUVZ4sCSBMVZmUrEA",1796069484468]