← 输入框|github.com|刷新
Skip to content

html-error: HTML-escape template variable values - #635

Open
prownd wants to merge 1 commit into
tinyproxy:masterfrom
prownd:html-error-HTML-escape-template-variable-values-s01
Open

prownd wants to merge 1 commit into
tinyproxy:masterfrom
prownd:html-error-HTML-escape-template-variable-values-s01

Conversation

@prownd

@prownd prownd commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

The values substituted for {variables} in error page and stats page templates were written verbatim. Several of them contain data controlled by the client, e.g. {request} and {url}, so a request such as

CONNECT <img	src=x	onerror=alert(1)>:99 HTTP/1.1

answered with the shipped debug.html template (or any custom ErrorFile using these variables) reflects arbitrary markup into the page, a cross-site scripting vector.

Escape &, <, >, " and ' when substituting variables.

The values substituted for {variables} in error page and stats page
templates were written verbatim.  Several of them contain data
controlled by the client, e.g. {request} and {url}, so a request such
as

    CONNECT <img	src=x	onerror=alert(1)>:99 HTTP/1.1

answered with the shipped debug.html template (or any custom ErrorFile
using these variables) reflects arbitrary markup into the page, a
cross-site scripting vector.

Escape &, <, >, " and ' when substituting variables.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Address the client-triggerable socket-write performance regression.

Review effort: Lite
Findings: None

What changed in this PR

This pull request prevents reflected XSS by HTML-escaping template variable values in error and statistics pages.

Changes:

  • Escapes &, <, >, " and '.
  • Applies escaping to all substituted values.
File Summary Finding
src/​html-error.c Adds and uses HTML escaping for template values. Moderate: per-character send() calls can cause hundreds of thousands of socket writes; accumulate output in bounded chunks.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

2 participants