You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by as...@apache.org on 2026/04/22 06:41:09 UTC

(tooling-agents) branch main updated: ASVS L3 audit: 1.1.2 (input_validation_and_injection)

This is an automated email from the ASF dual-hosted git repository.

asf-tooling pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-agents.git


The following commit(s) were added to refs/heads/main by this push:
     new a95e873  ASVS L3 audit: 1.1.2 (input_validation_and_injection)
a95e873 is described below

commit a95e873568dd59d0b187d28f9977649a746fef3c
Author: ASF Tooling Team <ro...@apache.org>
AuthorDate: Wed Apr 22 08:41:04 2026 +0200

    ASVS L3 audit: 1.1.2 (input_validation_and_injection)
---
 .../input_validation_and_injection/1.1.2.md        | 574 +++++++++++++++++++++
 1 file changed, 574 insertions(+)

diff --git a/repos/apache/ASVS/reports/steve/v3/d0aa7e9/input_validation_and_injection/1.1.2.md b/repos/apache/ASVS/reports/steve/v3/d0aa7e9/input_validation_and_injection/1.1.2.md
new file mode 100644
index 0000000..d0c7f2f
--- /dev/null
+++ b/repos/apache/ASVS/reports/steve/v3/d0aa7e9/input_validation_and_injection/1.1.2.md
@@ -0,0 +1,574 @@
+# ASVS 1.1.2 Security Audit Report
+
+## Executive Summary
+
+- **Repository:** apache/steve
+- **Audit Date:** Apr 22, 2026
+- **Auditor:** Tooling Agents
+- **ASVS Requirement:** 1.1.2 — Verify that the application performs output encoding and escaping either as a final step before being used by the interpreter for which it is intended or by the interpreter itself.
+  - **Level:** 2
+  - **Section:** Encoding and Sanitization Architecture
+  - **Description:** In the sections below, syntax-specific or interpreter-specific requirements for safely processing unsafe content to avoid security vulnerabilities are provided. The requirements in this section cover the order in which this processing should occur and where it should take place. They also aim to ensure that whenever data is stored, it remains in its original state and is not stored in an encoded or escaped form (e.g., HTML encoding), to prevent double encoding issues.
+- **Files analyzed:** 23 relevant out of 23 total, 0 skipped
+
+| Severity | Count |
+|----------|-------|
+| Critical | 0 |
+| High | 3 |
+| Medium | 2 |
+| Low | 0 |
+| **Total** | **5** |
+
+**Summary:** The application fails to consistently perform output encoding/escaping as a final step before data is used by HTML and JavaScript interpreters. While the EZT templating engine provides format directives (`[format "html"]`, `[format "js,html"]`) and these are used in some locations, they are **missing from the majority of output points** rendering user-controlled data. This creates a systemic stored and reflected XSS exposure. Parameterized SQL queries are used consistently,  [...]
+
+---
+
+## Security Controls Inventory
+
+| Control | Defined | Applied Locations | Missing Locations | Coverage |
+|---------|---------|-------------------|-------------------|----------|
+| EZT `[format "html"]` | EZT library | **None found** | All HTML variable outputs | **0%** |
+| EZT `[format "js,html"]` | EZT library | `manage.ezt` onclick handlers, `manage-stv.ezt` onclick handlers | `vote-on.ezt` `<script>` block | ~50% of JS contexts |
+| Client-side `escapeHtml()` | `vote-on.ezt` | STV modal item rendering | N/A (server-side injection occurs first) | N/A |
+| SQL `?` parameter binding | `queries.yaml` | All 30+ queries | None missing | **100%** |
+| LDAP filter hardcoding | `asf-load-ldap.py` | `'uid=*'` filter | N/A | **100%** |
+
+---
+
+## Critical File Review
+
+| File | Security Role | Encoding Status | Risk |
+|------|--------------|-----------------|------|
+| `queries.yaml` | SQL query definitions | ✅ All 30+ queries use `?` parameter binding | LOW |
+| `election.py` | Data layer | ✅ Uses `asfpy.db` parameterized queries; no HTML generation | LOW |
+| `persondb.py` | Data layer | ✅ Uses parameterized queries | LOW |
+| `pages.py` | Request handlers | ❌ `rewrite_description()` generates unescaped HTML; flash messages include raw user data | HIGH |
+| `asf-load-ldap.py` | LDAP loader | ✅ Hardcoded LDAP filter; parameterized DB inserts | LOW |
+| `admin.ezt` | HTML template | ❌ No `[format "html"]` on user-controlled variables | HIGH |
+| `voter.ezt` | HTML template | ❌ No `[format "html"]` on user-controlled variables | HIGH |
+| `manage.ezt` | HTML template | ⚠️ `[format "js,html"]` used in JS onclick; missing in HTML context | HIGH |
+| `manage-stv.ezt` | HTML template | ⚠️ Same as manage.ezt | HIGH |
+| `vote-on.ezt` | HTML template | ❌ No encoding in either HTML or JS `<script>` block | HIGH |
+| `flashes.ezt` | HTML template | ❌ No encoding on `[flashes.message]` | MEDIUM |
+| `e_bad_eid.ezt` | Error template | ❌ No encoding on `[eid]` | MEDIUM |
+| `e_bad_iid.ezt` | Error template | ❌ No encoding on `[iid]` | MEDIUM |
+| `e_bad_pid.ezt` | Error template | ❌ No encoding on `[pid]` | MEDIUM |
+
+---
+
+## Findings
+
+### High Severity
+
+#### ASVS-112-HIGH-001: Stored XSS — Unescaped User Data in HTML Context Across Multiple Templates (Type B Gap)
+
+**Severity:** HIGH
+
+**Location:** 
+- **Files:** `v3/server/templates/manage.ezt`, `v3/server/templates/admin.ezt`, `v3/server/templates/voter.ezt`, `v3/server/templates/vote-on.ezt`
+- **Functions:** Template rendering of user-controlled variables
+- **Lines:** Multiple output points across templates
+
+**Gap Type:** Type B — EZT's `[format "html"]` directive EXISTS but is NOT CALLED for any HTML-context variable output. The same codebase demonstrates awareness of encoding by using `[format "js,html"]` in JavaScript onclick contexts.
+
+**Related Functions Checked:**
+- `do_create_endpoint()` in `v3/server/pages.py`
+- `do_add_issue_endpoint()` in `v3/server/pages.py`
+- `do_edit_issue_endpoint()` in `v3/server/pages.py`
+- `Election.create()` in `v3/steve/election.py`
+- `Election.add_issue()` in `v3/steve/election.py`
+- `Election.edit_issue()` in `v3/steve/election.py`
+
+**Description:**
+
+The application fails to apply HTML output encoding to user-controlled data before rendering in HTML contexts. Multiple templates render election titles, issue descriptions, owner names, and authorization strings without the EZT `[format "html"]` directive, creating systemic stored XSS vulnerabilities.
+
+**Vulnerable Code:**
+
+`v3/server/templates/manage.ezt`:
+```html
+<strong>[issues.title]</strong>
+...
+<div id="description-[issues.iid]" class="description mt-2">[issues.description]</div>
+```
+
+`v3/server/templates/admin.ezt`:
+```html
+<h5 class="card-title">[owned.title]...
+...
+Created by [owned.owner_name] ([owned.owner_pid])
+[if-any owned.authz](authz: [owned.authz])[end]
+```
+
+`v3/server/templates/voter.ezt`:
+```html
+<h5 class="card-title mb-3">[open_elections.title]</h5>
+...
+<span>[open_elections.authz] can vote</span>
+...
+Created By [open_elections.owner_name]
+```
+
+`v3/server/templates/vote-on.ezt`:
+```html
+<h1 class="h4 mb-0 fw-semibold">[election.title]</h1>
+...
+<span>Authority: <strong>[election.owner_name]</strong></span>
+<span>Electorate: <strong>[election.authz]</strong></span>
+```
+
+**Data Flow:**
+1. **Source:** Web form (`form.title`, `form.description`) at `do_create_endpoint()`, `do_add_issue_endpoint()`, `do_edit_issue_endpoint()` in `pages.py`
+2. **Storage:** `Election.create()` / `Election.add_issue()` / `Election.edit_issue()` in `election.py` → parameterized INSERT/UPDATE → database
+3. **Sink:** EZT template variables `[owned.title]`, `[issues.title]`, `[issues.description]`, `[e_title]`, `[election.title]`, etc.
+4. **Missing Control:** `[format "html"]` not applied at output
+
+**Proof of Concept:**
+```http
+POST /do-create-election HTTP/1.1
+Content-Type: application/x-www-form-urlencoded
+Cookie: <authenticated session>
+
+title=<img+src=x+onerror=alert(document.cookie)>&csrf_token=placeholder
+```
+When any authenticated user visits `/admin` or `/voter`, the injected HTML executes.
+
+**Impact:** 
+
+Any authenticated committer who creates an election or adds/edits an issue can inject persistent JavaScript that executes in the browsers of all other authenticated users viewing those elections. This can lead to session hijacking, vote manipulation, or privilege escalation.
+
+**Remediation:**
+
+Apply `[format "html"]` to all user-controlled variables in HTML contexts:
+
+```html
+<!-- Before -->
+<strong>[issues.title]</strong>
+
+<!-- After -->
+<strong>[format "html"][issues.title][end]</strong>
+```
+
+Apply consistently to: `[owned.title]`, `[owned.owner_name]`, `[owned.authz]`, `[e_title]`, `[election.title]`, `[election.owner_name]`, `[election.authz]`, `[issues.title]`, `[issues.description]`, `[open_elections.title]`, `[open_elections.owner_name]`, `[open_elections.authz]`, `[upcoming_elections.title]`, etc.
+
+---
+
+#### ASVS-112-HIGH-002: JavaScript Injection in STV Candidate Data Block (Type B Gap)
+
+**Severity:** HIGH
+
+**Location:**
+- **File:** `v3/server/templates/vote-on.ezt`
+- **Function:** JavaScript `<script>` block rendering STV candidate data
+- **Lines:** ~line 20 of the script section
+
+**Gap Type:** Type B — `[format "js,html"]` is used correctly in `manage.ezt` and `manage-stv.ezt` for onclick attribute values, but is NOT applied when embedding data into a `<script>` block in `vote-on.ezt`.
+
+**Related Functions Checked:**
+- `vote_on_page()` in `v3/server/pages.py`
+- Issue creation/editing functions that populate STV data
+- Template rendering in `manage.ezt` (correct usage example)
+
+**Description:**
+
+User-controlled data (issue titles and STV candidate names/labels) is embedded directly into JavaScript string literals within a `<script>` block without JavaScript encoding. This allows attackers to break out of the string context and inject arbitrary JavaScript code.
+
+**Vulnerable Code:**
+
+`v3/server/templates/vote-on.ezt`:
+```javascript
+const STV_CANDIDATES = {
+[for issues][is issues.vtype "stv"]    "[issues.iid]": {
+      seats: [issues.seats],
+      title: "[issues.title]",
+      candidates: [
+[for issues.candidates]        { label: "[issues.candidates.label]", name: "[issues.candidates.name]" },
+[end]      ]
+    },
+[end][end]  };
+```
+
+**Contrast with correct usage in same codebase (`manage.ezt`):**
+```html
+onclick="openEditIssueModal('[issues.iid]',
+                            '[format "js,html"][issues.title][end]',
+                            '[format "js,html"][issues.description][end]')"
+```
+
+**Data Flow:**
+1. **Source:** Issue title set during creation (CLI or web), candidate names/labels from STV `kv.labelmap`
+2. **Storage:** Database (issue table, kv column as JSON)
+3. **Sink:** JavaScript string literal within `<script>` block in vote-on.ezt
+4. **Missing Control:** `[format "js"]` not applied; client-side `escapeHtml()` exists but runs AFTER the JS parsing stage
+
+**Proof of Concept:**
+
+An STV issue with title:
+```
+Test", evil: (function(){fetch('/do-vote/'+eid,{method:'POST',body:new URLSearchParams({})})})(), "x": "
+```
+
+Or more critically, to break out of the `<script>` tag:
+```
+</script><script>alert(document.cookie)</script><script>var x="
+```
+
+**Impact:** 
+
+JavaScript injection executing in the context of every voter viewing an STV election. Could be used to silently manipulate votes, steal session tokens, or exfiltrate ballot data.
+
+**Remediation:**
+
+Apply `[format "js"]` for JavaScript string contexts within `<script>` blocks:
+
+```javascript
+title: "[format "js"][issues.title][end]",
+candidates: [
+  { label: "[format "js"][issues.candidates.label][end]", name: "[format "js"][issues.candidates.name][end]" },
+]
+```
+
+---
+
+#### ASVS-112-HIGH-003: HTML Injection via `rewrite_description()` — Output Encoding Not Performed Before HTML Generation
+
+**Severity:** HIGH
+
+**Location:**
+- **File:** `v3/server/pages.py`
+- **Function:** `rewrite_description()`
+- **Lines:** 44–53
+
+**Gap Type:** Type A — No encoding control applied at all in this code path.
+
+**Related Functions Checked:**
+- `vote_on_page()` in `v3/server/pages.py` (caller)
+- `do_add_issue_endpoint()` in `v3/server/pages.py`
+- `do_edit_issue_endpoint()` in `v3/server/pages.py`
+- `election.add_issue()` in `v3/steve/election.py`
+
+**Description:**
+
+The `rewrite_description()` function generates HTML by wrapping user-controlled issue descriptions in `<pre>` tags and converting `doc:filename` patterns to anchor tags. However, it performs no HTML encoding on the user-controlled text before constructing the HTML, creating three separate injection points.
+
+**Vulnerable Code:**
+
+```python
+def rewrite_description(issue):
+    """Rewrite issue description: wrap in <pre> and convert doc:filename to links."""
+    import re
+    desc = issue.description
+    def repl(match):
+        filename = match.group(1)
+        return f'<a href="/docs/{issue.iid}/{filename}">{filename}</a>'
+    desc = re.sub(r'doc:([^\s]+)', repl, desc)
+    issue.description = f'<pre>{desc}</pre>'
+```
+
+**Three separate encoding failures:**
+1. Raw `desc` (user-controlled description text) is placed inside `<pre>` without HTML encoding
+2. `filename` extracted from description is placed in `href` attribute without URL encoding
+3. `filename` is placed as link text without HTML encoding
+
+**Data Flow:**
+1. **Source:** `form.description` from `do_add_issue_endpoint()` or `do_edit_issue_endpoint()` → `election.add_issue()` → database
+2. **Processing:** `vote_on_page()` calls `rewrite_description(issue)` for each issue
+3. **Sink:** Modified `issue.description` rendered in template as `[issues.description]`
+4. **Missing Control:** No HTML encoding applied before generating HTML string; `<pre>` tag does NOT prevent HTML rendering
+
+**Proof of Concept:**
+
+Create an issue with description:
+```
+<script>alert('XSS')</script>Review the doc:"><img/src=x/onerror=alert(1)> for details
+```
+
+Results in:
+```html
+<pre><script>alert('XSS')</script>Review the <a href="/docs/IID/"><img/src=x/onerror=alert(1)>">"><img/src=x/onerror=alert(1)></a> for details</pre>
+```
+
+**Impact:** 
+
+Stored XSS affecting all voters viewing the election ballot page. The `rewrite_description()` function is called on the vote-on page which is shown to all eligible voters.
+
+**Remediation:**
+
+```python
+import html
+
+def rewrite_description(issue):
+    """Rewrite issue description: wrap in <pre> and convert doc:filename to links."""
+    import re
+    # HTML-encode the description FIRST
+    desc = html.escape(issue.description)
+    def repl(match):
+        filename = match.group(1)
+        # filename is already HTML-escaped from above; use for display
+        # URL-encode for href
+        from urllib.parse import quote
+        return f'<a href="/docs/{html.escape(issue.iid)}/{quote(filename)}">{filename}</a>'
+    desc = re.sub(r'doc:([^\s]+)', repl, desc)
+    issue.description = f'<pre>{desc}</pre>'
+```
+
+---
+
+### Medium Severity
+
+#### ASVS-112-MED-004: Reflected XSS in Error Pages — URL Parameters Rendered Without HTML Encoding
+
+**Severity:** MEDIUM
+
+**Location:**
+- **Files:** `v3/server/templates/e_bad_eid.ezt`, `v3/server/templates/e_bad_iid.ezt`, `v3/server/templates/e_bad_pid.ezt`
+- **Functions:** Decorator functions in `v3/server/pages.py`
+- **Lines:** 174–225 in `pages.py`
+
+**Related Functions Checked:**
+- `load_election()` decorator in `v3/server/pages.py`
+- `load_issue()` decorator in `v3/server/pages.py`
+- `load_person()` decorator in `v3/server/pages.py`
+- `raise_404()` function in `v3/server/pages.py`
+
+**Description:**
+
+Error page templates render URL path parameters directly without HTML encoding. When an election, issue, or person ID is not found, the user-supplied ID from the URL is reflected in the error message without sanitization.
+
+**Vulnerable Code:**
+
+`e_bad_eid.ezt`:
+```html
+The Election ID ([eid]) does not exist,
+```
+
+`e_bad_iid.ezt`:
+```html
+The Issue ID ([iid]) does not exist,
+```
+
+`e_bad_pid.ezt`:
+```html
+The Person ID ([pid]) does not exist,
+```
+
+**Populating code in `pages.py` (`load_election` decorator):**
+```python
+async def loader(eid):
+    try:
+        e = steve.election.Election(DB_FNAME, eid)
+    except steve.election.ElectionNotFound:
+        result = await basic_info()
+        result.eid = eid  # User-controlled URL path parameter
+        raise_404(T_BAD_EID, result)
+```
+
+**Data Flow:**
+1. **Source:** URL path parameter `<eid>` (e.g., `/vote-on/<eid>`) — URL-decoded by Quart framework
+2. **Sink:** `[eid]` in EZT template rendered as HTML
+3. **Missing Control:** `[format "html"]` not applied
+
+**Proof of Concept:**
+```
+GET /vote-on/%3Cimg%20src%3Dx%20onerror%3Dalert(document.cookie)%3E HTTP/1.1
+```
+
+Quart decodes `%3C` to `<`, etc. The election is not found, and the error page renders:
+```html
+The Election ID (<img src=x onerror=alert(document.cookie)>) does not exist,
+```
+
+**Impact:** 
+
+Reflected XSS. An attacker can craft a URL and trick an authenticated user into visiting it, executing arbitrary JavaScript in their session. Impact is somewhat limited because the error pages require authentication to reach (behind `@asfquart.auth.require`).
+
+**Remediation:**
+
+```html
+<!-- Before -->
+The Election ID ([eid]) does not exist,
+
+<!-- After -->
+The Election ID ([format "html"][eid][end]) does not exist,
+```
+
+Apply the same fix to `[iid]` in `e_bad_iid.ezt` and `[pid]` in `e_bad_pid.ezt`.
+
+---
+
+#### ASVS-112-MED-005: Stored XSS via Flash Messages Containing Unencoded User Input
+
+**Severity:** MEDIUM
+
+**Location:**
+- **File:** `v3/server/templates/flashes.ezt`
+- **Functions:** Multiple endpoints in `v3/server/pages.py`
+- **Lines:** ~447, ~508, ~533, ~413 in `pages.py`
+
+**Related Functions Checked:**
+- `do_create_endpoint()` in `v3/server/pages.py`
+- `do_add_issue_endpoint()` in `v3/server/pages.py`
+- `do_edit_issue_endpoint()` in `v3/server/pages.py`
+- `do_vote_endpoint()` in `v3/server/pages.py`
+- `flash_success()` helper function
+- `flash_danger()` helper function
+
+**Description:**
+
+Flash messages are constructed by concatenating user-controlled input (election titles, issue titles, issue IDs) directly into message strings without HTML encoding. These messages are then rendered in templates without encoding, creating stored XSS vulnerabilities.
+
+**Vulnerable Code:**
+
+`flashes.ezt`:
+```html
+[for flashes]
+    <div class="alert alert-[flashes.category] alert-dismissible fade show" role="alert">
+        [flashes.message]
+        ...
+    </div>
+[end]
+```
+
+`pages.py` — user-controlled data injected into flash messages:
+```python
+# Line ~447 (do_create_endpoint):
+await flash_success(f'Created election: {form.title}')
+
+# Line ~508 (do_add_issue_endpoint):
+await flash_success(f'Issue "{form.title}" has been added.')
+
+# Line ~533 (do_edit_issue_endpoint):
+await flash_success(f'Issue "{form.title}" has been updated.')
+
+# Line ~413 (do_vote_endpoint):
+await flash_danger(f'Invalid issue ID: {iid}')
+```
+
+**Data Flow:**
+1. **Source:** `form.title` from form submission or `iid` extracted from form field names
+2. **Intermediate:** Flash message stored in session
+3. **Sink:** `[flashes.message]` rendered in template without encoding
+4. **Missing Control:** Neither Python-side `html.escape()` before creating the flash, nor `[format "html"]` in the template
+
+**Proof of Concept:**
+
+```http
+POST /do-create-election HTTP/1.1
+Content-Type: application/x-www-form-urlencoded
+
+title=<script>alert('XSS')</script>&csrf_token=placeholder
+```
+
+On redirect, the flash message renders: `Created election: <script>alert('XSS')</script>`
+
+For the `iid` path (do_vote_endpoint), a crafted form submission with field `vote-<img/src=x/onerror=alert(1)>=y` produces flash: `Invalid issue ID: <img/src=x/onerror=alert(1)>`.
+
+**Impact:** 
+
+XSS executes on the page redirect after a state-changing action. Primarily a self-XSS risk for the attacker's own session, but could be exploited if combined with CSRF (CSRF is already acknowledged as incomplete). The `form.title` variant creates a stored XSS that also triggers via ASVS-112-HIGH-001 when the title is displayed on other pages.
+
+**Remediation:**
+
+Either encode at the template level:
+```html
+[flashes.message]
+<!-- change to -->
+[format "html"][flashes.message][end]
+```
+
+Or encode when constructing flash messages:
+```python
+import html
+await flash_success(f'Created election: {html.escape(form.title)}')
+```
+
+---
+
+## Positive Security Patterns
+
+1. **Parameterized SQL Queries:** All 30+ queries in `queries.yaml` use `?` parameter placeholders, and all database operations in `election.py` and `persondb.py` use `asfpy.db` parameter binding. No string concatenation for SQL construction was found.
+
+2. **LDAP Filter Hardcoding:** The LDAP search filter in `asf-load-ldap.py` is a hardcoded constant `'uid=*'`, eliminating LDAP injection risk.
+
+3. **Partial JavaScript Escaping:** The `manage.ezt` and `manage-stv.ezt` templates correctly use `[format "js,html"]` for values passed to JavaScript onclick handlers, demonstrating awareness of the encoding requirement.
+
+4. **Client-side HTML Escaping:** The `vote-on.ezt` template includes a client-side `escapeHtml()` function used when dynamically creating DOM elements, providing defense-in-depth for the client-side rendering path.
+
+5. **Sensitive Field Exclusion:** `get_metadata()` and `get_person()` deliberately exclude `salt` and `opened_key` fields from returned data, preventing accidental leakage.
+
+6. **Vote Type Whitelisting:** The `add_issue()` method validates `vtype in vtypes.TYPES` before storage.
+
+---
+
+## Architecture Observations
+
+1. **EZT Templating is Unsafe-by-Default:** Unlike modern auto-escaping frameworks (Jinja2 with autoescape, React), EZT renders variables as raw text unless explicitly formatted. This architectural choice means every single variable output requires manual `[format]` application, creating a high probability of encoding gaps.
+
+2. **No Centralized Encoding Layer:** There is no middleware, decorator, or helper function that ensures output encoding. Encoding is left entirely to each template, making consistency difficult.
+
+3. **Data Stored in Original Form (Correct per ASVS):** The application correctly stores data in its original (unencoded) form in the database, avoiding double-encoding issues. The problem is that the final-step output encoding before the HTML interpreter is absent.
+
+4. **`rewrite_description()` Violates Encoding Order:** This function generates HTML from raw data mid-pipeline, then the result is passed to the template. The encoding should be the absolute last step before browser interpretation, but here raw HTML is constructed in Python and handed to EZT to output as-is.
+
+---
+
+## Recommendations Summary
+
+### Immediate Actions
+
+1. **Migrate to auto-escaping templating or enable default HTML escaping** — Consider migrating from EZT to Jinja2 with `autoescape=True` (which Quart supports natively). If EZT must be retained, create a linting rule or pre-commit hook that flags any `[variable]` not wrapped in `[format "html"]`.
+
+2. **Add `[format "html"]` to all HTML-context variable outputs** — Audit every `.ezt` template and wrap user-controlled variables. Priority order: `vote-on.ezt` > `manage.ezt`/`manage-stv.ezt` > `admin.ezt`/`voter.ezt` > error templates.
+
+3. **Add `[format "js"]` to the STV_CANDIDATES script block** in `vote-on.ezt` for all values embedded in JavaScript string literals.
+
+### Short-term Actions
+
+4. **Refactor `rewrite_description()`** — HTML-encode the description text before any HTML tag construction. Use `html.escape()` on the raw text first, then apply the `doc:` link transformation.
+
+5. **Encode flash message content** — Either apply `[format "html"]` in `flashes.ezt` or use `html.escape()` when constructing flash messages containing user data in `pages.py`.
+
+### Long-term Actions
+
+6. **Add `[format "html"]` to error templates** — Encode `[eid]`, `[iid]`, and `[pid]` in `e_bad_eid.ezt`, `e_bad_iid.ezt`, and `e_bad_pid.ezt`.
+
+7. **Implement automated template security scanning** — Create tooling to detect unencoded variable outputs in EZT templates as part of CI/CD pipeline.
+
+8. **Establish secure coding guidelines** — Document the requirement for output encoding in all templates and provide training to developers on proper EZT usage.
+
+---
+
+## Appendix: Files Analyzed
+
+<details>
+<summary>Click to expand full file list (23 files)</summary>
+
+- `v3/queries.yaml` (relevance: 10)
+- `v3/server/api.py` (relevance: 10)
+- `v3/server/bin/asf-load-ldap.py` (relevance: 10)
+- `v3/server/bin/create-election.py` (relevance: 10)
+- `v3/server/pages.py` (relevance: 10)
+- `v3/server/templates/about.ezt` (relevance: 10)
+- `v3/server/templates/admin.ezt` (relevance: 10)
+- `v3/server/templates/e_bad_eid.ezt` (relevance: 10)
+- `v3/server/templates/e_bad_iid.ezt` (relevance: 10)
+- `v3/server/templates/e_bad_pid.ezt` (relevance: 10)
+- `v3/server/templates/flashes.ezt` (relevance: 10)
+- `v3/server/templates/footer.ezt` (relevance: 10)
+- `v3/server/templates/header.ezt` (relevance: 10)
+- `v3/server/templates/home.ezt` (relevance: 10)
+- `v3/server/templates/manage-stv.ezt` (relevance: 10)
+- `v3/server/templates/manage.ezt` (relevance: 10)
+- `v3/server/templates/privacy.ezt` (relevance: 10)
+- `v3/server/templates/profile.ezt` (relevance: 10)
+- `v3/server/templates/settings.ezt` (relevance: 10)
+- `v3/server/templates/vote-on.ezt` (relevance: 10)
+- `v3/server/templates/voter.ezt` (relevance: 10)
+- `v3/steve/election.py` (relevance: 10)
+- `v3/steve/persondb.py` (relevance: 10)
+
+</details>
+
+---
+
+**End of Report**
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org