Skip to content

feat(go): detect non-constant argument to template.HTML(...) — html/template escaping bypass (CWE-79) - #147

Open
ai-anant wants to merge 1 commit into
CodeVigilant:mainfrom
ai-anant:rule/go-html-template-taint
Open

feat(go): detect non-constant argument to template.HTML(...) — html/template escaping bypass (CWE-79)#147
ai-anant wants to merge 1 commit into
CodeVigilant:mainfrom
ai-anant:rule/go-html-template-taint

Conversation

@ai-anant

Copy link
Copy Markdown

Detects template.HTML() where $X is not a compile-time string constant.

The html/template package auto-escapes HTML when rendering plain-string fields, but wrapping a value in the template.HTML type instructs the renderer to emit it verbatim. When a non-literal value (file-derived bytes, config, or user input) is wrapped this way and reaches the rendered page, it is a stored/reflected XSS sink (CWE-79). Literal constants wrapped deliberately (template.HTML("...")) are excluded via pattern-not.

Pattern shape (generic):

x := template.HTML(variableOrFileContent)

Validated: pos repro fires (2), constant-only repro is clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant