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 10:12:42 UTC

(tooling-agents) branch main updated: ASVS L3 audit: 3.4.5 (ch03_general)

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 69e74cf  ASVS L3 audit: 3.4.5 (ch03_general)
69e74cf is described below

commit 69e74cfd9d4ba6e560f196dc1a0608702cbdf2ce
Author: ASF Tooling Team <ro...@apache.org>
AuthorDate: Wed Apr 22 12:12:37 2026 +0200

    ASVS L3 audit: 3.4.5 (ch03_general)
---
 .../reports/steve/v3/d0aa7e9/ch03_general/3.4.5.md | 241 +++++++++++++++++++++
 1 file changed, 241 insertions(+)

diff --git a/repos/apache/ASVS/reports/steve/v3/d0aa7e9/ch03_general/3.4.5.md b/repos/apache/ASVS/reports/steve/v3/d0aa7e9/ch03_general/3.4.5.md
new file mode 100644
index 0000000..30566d0
--- /dev/null
+++ b/repos/apache/ASVS/reports/steve/v3/d0aa7e9/ch03_general/3.4.5.md
@@ -0,0 +1,241 @@
+# ASVS 3.4.5 Security Audit Report
+
+## Executive Summary
+
+- **Repository:** apache/steve
+- **Audit Date:** Apr 22, 2026
+- **Auditor:** Tooling Agents
+- **ASVS Requirement:** 3.4.5 — Verify that the application sets a referrer policy to prevent leakage of technically sensitive data to third-party services via the 'Referer' HTTP request header field. This can be done using the Referrer-Policy HTTP response header field or via HTML element attributes. Sensitive data could include path and query data in the URL, and for internal non-public applications also the hostname.
+  - **Level:** 2
+  - **Section:** Browser Security Mechanism Headers
+  - **Section Description:** This section describes which security headers should be set on HTTP responses to enable browser security features and restrictions when handling responses from the application.
+  - **Chapter:** Web Frontend Security
+  - **Control Objective:** This category focuses on requirements designed to protect against attacks executed via a web frontend. These requirements do not apply to machine-to-machine solutions.
+- **Files Analyzed:** 2 relevant out of 49 total, 12 skipped
+
+### Finding Counts
+
+| Severity | Count |
+|----------|-------|
+| Critical | 0 |
+| High | 0 |
+| Medium | 1 |
+| Low | 0 |
+| **Total** | **1** |
+
+---
+
+## Security Controls Inventory
+
+| Control | Defined? | Location | Applied to All Routes? | Coverage |
+|---------|----------|----------|----------------------|----------|
+| `Referrer-Policy` HTTP response header | **NO** | N/A | N/A | **0%** |
+| `<meta name="referrer">` HTML element | **Unknown** (templates not provided) | N/A | N/A | **Unverifiable** |
+| Response header middleware / `after_request` hook | **NO** | N/A | N/A | **0%** |
+| Framework-level security header configuration | **NO** | `main.py:create_app()` | N/A | **0%** |
+
+---
+
+## Critical File Review
+
+### `v3/server/main.py` — Application Factory
+
+| Line Range | Function | Security Header Config? | Notes |
+|-----------|----------|------------------------|-------|
+| 31–47 | `create_app()` | **NO** | Creates app via `asfquart.construct()`, no security headers configured |
+| 50–84 | `run_standalone()` | **NO** | Only logging and TLS config |
+| 90–109 | `run_asgi()` | **NO** | Only logging config |
+
+### `v3/server/pages.py` — All Route Handlers
+
+| Line Range | Route | Sensitive Path Data | Referrer-Policy Set? |
+|-----------|-------|-------------------|---------------------|
+| 125–131 | `GET /` | None | **NO** |
+| 133–163 | `GET /voter` | None | **NO** |
+| 223–284 | `GET /vote-on/<eid>` | Election ID | **NO** |
+| 286–322 | `GET /admin` | None | **NO** |
+| 324–344 | `GET /manage/<eid>` | Election ID | **NO** |
+| 346–372 | `GET /manage-stv/<eid>/<iid>` | Election ID + Issue ID | **NO** |
+| 386–428 | `POST /do-vote/<eid>` | Election ID | **NO** |
+| 454–473 | `GET /do-open/<eid>` | Election ID | **NO** |
+| 475–493 | `GET /do-close/<eid>` | Election ID | **NO** |
+| 586–602 | `GET /docs/<iid>/<docname>` | Issue ID + Document name | **NO** |
+
+---
+
+## Findings
+
+### Medium Severity
+
+#### ASVS-345-MED-001: Missing Referrer-Policy Header on All Application Responses
+
+**Severity:** MEDIUM
+
+**Gap Type:** Type A — Entry points with NO control
+
+**Location:**
+- **File:** `v3/server/main.py`
+- **Function:** `create_app()`
+- **Lines:** 31–47
+- **Additional File:** `v3/server/pages.py` — all route handlers (no `after_request` hook defined)
+
+**Related Functions Checked:**
+- `create_app()` (main.py:31–47)
+- `run_standalone()` (main.py:50–84)
+- `run_asgi()` (main.py:90–109)
+- All route handlers in `pages.py` (lines 125–602)
+
+**Description:**
+
+The application does not set a `Referrer-Policy` HTTP response header on any responses, nor is there evidence of HTML meta tag configuration in the provided code. This violates ASVS requirement 3.4.5 and exposes sensitive election identifiers, issue IDs, and document names in URL paths to third-party services via the browser's `Referer` header.
+
+**Vulnerable Code (main.py:31–47):**
+
+```python
+def create_app():
+    "Create the asfquart app and its endpoints."
+
+    ### is this really needed right now?
+    # Avoid OIDC
+    import asfquart.generics
+
+    asfquart.generics.OAUTH_URL_INIT = (
+        'https://oauth.apache.org/auth?state=%s&redirect_uri=%s'
+    )
+    asfquart.generics.OAUTH_URL_CALLBACK = 'https://oauth.apache.org/token?code=%s'
+
+    app = asfquart.construct('steve', app_dir=THIS_DIR, static_folder=None)
+
+    # Now that we have an APP, import modules that will add page
+    # and API endpoints into the APP.
+    import pages  # noqa: F401
+    import api  # noqa: F401
+
+    return app  # also available as asfquart.APP now
+```
+
+No `Referrer-Policy` header is configured at the application level, and no `after_request` handler sets it on any response.
+
+**Data Flow:**
+
+1. User navigates to a sensitive page (e.g., `/vote-on/abc123` or `/manage-stv/abc123/issue456`)
+2. The HTML response is rendered and served **without** a `Referrer-Policy` header
+3. If any page contains links to third-party resources (e.g., CDN-hosted CSS/JS, external documentation links) or the user clicks an external link, the browser sends the **full URL** including the path (election ID, issue ID, document name) in the `Referer` header to the third party
+4. Third-party services learn internal election identifiers and navigation patterns
+
+**Sensitive URL Paths Exposed:**
+
+- `/vote-on/<eid>` — reveals which election a user is voting on
+- `/manage/<eid>` — reveals election management activity
+- `/manage-stv/<eid>/<iid>` — reveals both election and issue identifiers
+- `/docs/<iid>/<docname>` — reveals issue IDs and supporting document names
+- `/do-open/<eid>`, `/do-close/<eid>` — reveals election state-change operations (these are GET requests that leak via Referer on the subsequent redirect target's page load)
+
+**Proof of Concept:**
+
+```
+1. User visits: https://steve.example.org/vote-on/election-2024-board
+2. That page loads a third-party resource or user clicks an external link
+3. Browser sends request to third party with header:
+   Referer: https://steve.example.org/vote-on/election-2024-board
+4. Third party now knows the election identifier and that voting is occurring
+```
+
+**Impact:**
+
+- Election identifiers, issue identifiers, and document names leak to any third-party service referenced in the HTML pages
+- For this election/voting system, leaking which elections exist and are active has organizational sensitivity
+- Combined with timing information from the Referer, an observer could correlate voting activity patterns
+
+**Remediation:**
+
+Add a global `after_request` handler that sets `Referrer-Policy` on all responses. For an election system, `strict-origin-when-cross-origin` (minimum) or `no-referrer` (strictest) is recommended:
+
+```python
+# In main.py create_app(), after app construction:
+def create_app():
+    app = asfquart.construct('steve', app_dir=THIS_DIR, static_folder=None)
+
+    @app.after_request
+    async def set_security_headers(response):
+        # Prevent leakage of election/issue IDs in URL paths
+        response.headers['Referrer-Policy'] = 'strict-origin-when-cross-origin'
+        # Consider also adding other security headers here:
+        # response.headers['X-Content-Type-Options'] = 'nosniff'
+        # response.headers['X-Frame-Options'] = 'DENY'
+        return response
+
+    import pages
+    import api
+
+    return app
+```
+
+For maximum protection (recommended for a voting system):
+
+```python
+response.headers['Referrer-Policy'] = 'no-referrer'
+```
+
+Alternatively, if templates are controlled, a fallback HTML meta tag can be added in the base template:
+
+```html
+<meta name="referrer" content="strict-origin-when-cross-origin">
+```
+
+---
+
+## Positive Security Patterns
+
+| Pattern | Location | Notes |
+|---------|----------|-------|
+| Authentication on all sensitive routes | `pages.py` throughout | Consistent use of `@asfquart.auth.require` decorators |
+| POST for state-changing vote operations | `pages.py:386` | `/do-vote/<eid>` uses POST method |
+| Redirect after POST (PRG pattern) | `pages.py:427` | `return quart.redirect('/voter', code=303)` prevents resubmission |
+| Per-document authorization | `pages.py:593` | `serve_doc()` checks `q_get_mayvote` before serving |
+| TLS support | `main.py:76-78` | Certificate and key file configuration available |
+
+---
+
+## Architecture Observations
+
+1. **No security header middleware exists anywhere.** The application factory (`create_app`) configures OAuth URLs and imports route modules but does not set any HTTP security headers. This is a systemic gap — not just for Referrer-Policy, but likely for other security headers (CSP, X-Frame-Options, etc.) as well.
+
+2. **State-changing GET endpoints are particularly vulnerable.** The routes `GET /do-open/<eid>` and `GET /do-close/<eid>` perform state changes via GET requests. After the redirect (303), the next page load will send the previous URL (containing the election ID and operation type) as the Referer to any third-party resources loaded on the redirect target page.
+
+3. **The `asfquart` framework** is used as the application foundation, but there is no evidence from the provided code that it sets `Referrer-Policy` by default. The application must explicitly configure this.
+
+---
+
+## Recommendations Summary
+
+### Immediate Actions
+
+| Priority | Action | Effort |
+|----------|--------|--------|
+| **1** | Add `Referrer-Policy: strict-origin-when-cross-origin` (or `no-referrer`) via `after_request` hook in `create_app()` | Low — ~5 lines of code |
+| **2** | Add a backup `<meta name="referrer">` tag in the base EZT template | Low — 1 line in template |
+
+### Short-term Actions
+
+| Priority | Action | Effort |
+|----------|--------|--------|
+| **3** | Audit all templates for third-party resource loading (CDN links, external scripts) that would be immediate leakage vectors | Medium |
+
+### Long-term Actions
+
+| Priority | Action | Effort |
+|----------|--------|--------|
+| **4** | Consider adding a comprehensive security headers middleware covering CSP, X-Frame-Options, X-Content-Type-Options alongside Referrer-Policy | Medium |
+
+---
+
+## Appendix: Files Analyzed
+
+<details>
+<summary>Click to expand file list (2 files)</summary>
+
+1. `v3/server/pages.py` (relevance: 8)
+2. `v3/server/main.py` (relevance: 7)
+
+</details>
\ 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