Security rules
Checks that detect XSS vectors, mixed-content resource loading, innerHTML usage, and obfuscated vendor code in GTM custom HTML tags.
On this page 5
Security rules audit custom HTML tag code for patterns that introduce vulnerabilities or make a container's behavior unverifiable. GTM's custom HTML environment executes arbitrary JavaScript with full page privileges. There is no sandboxing, no content security policy applied to tag code, and no automatic patching mechanism when vulnerabilities are discovered. Security problems in custom HTML are security problems on the page itself.
What this category covers
The category covers four distinct risks: dynamic code execution via eval(), insecure resource loading over HTTP, DOM manipulation via innerHTML, and obfuscated vendor code that cannot be statically analyzed.
The first three risks are active vulnerabilities. An eval() call that processes user-controlled or externally sourced data is a cross-site scripting vector. An HTTP script loaded in a mixed-content context can be intercepted and replaced with malicious code. An innerHTML assignment that receives user-controlled content can execute embedded scripts.
The obfuscated vendor code finding is different in character. It does not indicate an active exploit — it indicates an unauditable one. Custom HTML tags that use atob() and String.fromCharCode() to construct URLs or code at runtime cannot be analyzed through static inspection. TagManifest cannot determine what the tag actually does, what data it collects, or whether it meets consent obligations. The finding surfaces this gap for human review.
The audience for security rules includes engineering security teams, legal and compliance teams reviewing vendor contracts, and practitioners responsible for third-party risk in the tag implementation.
How findings are tiered
This category uses three tiers: error, optimization, and info.
The two error-tier rules — eval-usage and http-script-loading — flag active security risks that warrant immediate investigation. When either fires, the finding demands engineering attention before the next deployment.
The one optimization-tier rule — innerhtml-usage — flags a risky pattern that is not necessarily exploited. Static innerHTML assignments with hard-coded markup are low risk; dynamic assignments with user-controlled content are high risk. The finding prompts manual triage rather than automatic escalation.
The one info-tier rule — obfuscated-vendor-code — is an audit gap signal. Resolution is strategic, not technical: it requires vendor negotiation or replacement with an official GTM community template.
See Health score for how each tier contributes to deductions.
Rules in this category
Errors
eval-usage— Tags useeval(), which executes arbitrary strings as code. This is an XSS vector and disables JavaScript engine optimizations.http-script-loading— Tags reference HTTP URLs instead of HTTPS. HTTP resources can be intercepted in transit and are blocked by modern browsers as mixed content.
Optimizations
innerhtml-usage— Tags assign toinnerHTML, which can execute embedded scripts if the content includes user-controlled data. UsetextContentor DOM methods instead.
Info
obfuscated-vendor-code— Custom HTML tags use obfuscation techniques (atob+String.fromCharCode,charCodeAt+fromCharCode) to construct URLs or code at runtime. The tag's behavior cannot be verified through static analysis.
Common patterns
The most frequently surfaced finding in this category is obfuscated-vendor-code. It appears in containers where a vendor provided implementation instructions as a code snippet rather than an official GTM template. Vendors sometimes obfuscate tag code to protect proprietary logic, but the practical effect is that no one — not the practitioner, not the compliance team, not a static auditor — can read what the tag sends or where it sends it. The fix is a vendor conversation, not a code change.
innerHTML findings typically appear in containers built by developers who imported patterns from general web development. Assigning to innerHTML is common in front-end JavaScript; the risk in GTM is that tag code runs without the same review gates as application code. The fix is mechanical: replace innerHTML with textContent for text content, or createElement and appendChild for structured markup.
eval-usage and http-script-loading are rare. When they appear, the most common source is legacy tag code that was copied from an old implementation and never updated. Both have direct fixes: refactor eval() to JSON.parse() or restructured logic, and update http:// scheme references to https:// or protocol-relative /.
See also
- Health score — how findings in this category translate to score deductions
- Rules catalog — browse all rules across categories
- Consent rules — adjacent category covering CMP presence, cookie governance, and data layer hygiene