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:16:02 UTC

(tooling-agents) branch main updated: ASVS L3 audit: 3.4.6 (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 05284cb  ASVS L3 audit: 3.4.6 (ch03_general)
05284cb is described below

commit 05284cb61452ac0ce6ce2d9f06e0632ce0620ace
Author: ASF Tooling Team <ro...@apache.org>
AuthorDate: Wed Apr 22 12:15:48 2026 +0200

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

diff --git a/repos/apache/ASVS/reports/steve/v3/d0aa7e9/ch03_general/3.4.6.md b/repos/apache/ASVS/reports/steve/v3/d0aa7e9/ch03_general/3.4.6.md
new file mode 100644
index 0000000..6907c13
--- /dev/null
+++ b/repos/apache/ASVS/reports/steve/v3/d0aa7e9/ch03_general/3.4.6.md
@@ -0,0 +1,290 @@
+# ASVS 3.4.6 Security Audit Report
+
+## Executive Summary
+
+**Audit Metadata**
+- **Repository:** apache/steve
+- **Audit Date:** Apr 22, 2026
+- **Auditor:** Tooling Agents
+- **ASVS Requirement:** 3.4.6 — Verify that the web application uses the frame-ancestors directive of the Content-Security-Policy header field for every HTTP response to ensure that it cannot be embedded by default and that embedding of specific resources is allowed only when necessary. Note that the X-Frame-Options header field, although supported by browsers, is obsolete and may not be relied upon.
+  - **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.
+
+**Analysis Scope**
+- **Files analyzed:** 3 relevant out of 49 total, 12 skipped
+
+**Finding Summary**
+
+| Severity | Count | Status |
+|----------|-------|--------|
+| Critical | 0 | ✓ |
+| High | 1 | ⚠️ |
+| Medium | 0 | ✓ |
+| Low | 0 | ✓ |
+| **Total** | **1** | |
+
+**Key Finding:** The application **completely lacks** the `Content-Security-Policy` header with the `frame-ancestors` directive across all 21 HTTP endpoints. No global middleware, `after_request` hook, or per-route header injection is implemented to protect against clickjacking. This is a **Type A gap** (entry points with NO control whatsoever).
+
+---
+
+## Security Controls Inventory
+
+| Control | Defined? | Where Defined | Applied? | Coverage |
+|---------|----------|---------------|----------|----------|
+| CSP `frame-ancestors` directive | **NO** | Nowhere in codebase | **NO** | 0/21 endpoints (0%) |
+| `X-Frame-Options` header | **NO** | Nowhere in codebase | **NO** | 0/21 endpoints (0%) |
+| Global `after_request` / `after_response` hook | **NO** | Not in `main.py` or `pages.py` | **NO** | N/A |
+| Framework-level CSP config | **NO** | Not in `create_app()` | **NO** | N/A |
+
+---
+
+## Critical File Review
+
+### `v3/server/main.py`
+
+| Line(s) | Code Element | Security Relevance | Finding |
+|---------|-------------|-------------------|---------|
+| 27–42 | `create_app()` | App factory — **only place** to register global middleware | No `after_request` hook for security headers |
+| 38 | `asfquart.construct(...)` | Framework init | No CSP configuration parameter passed |
+| 40–41 | `import pages; import api` | Route registration | Headers must be set globally, not per-route |
+
+### `v3/server/pages.py`
+
+| Line(s) | Code Element | Security Relevance | Finding |
+|---------|-------------|-------------------|---------|
+| All routes | 21 endpoints | Every endpoint returns responses without CSP headers | Type A gap on all |
+| 119–123 | `home_page()` | Public HTML page, no auth required | Embeddable by any origin |
+| 223–277 | `vote_on_page()` | Vote submission form — highest-value target | No frame-ancestors protection |
+| 460–477 | `do_open_endpoint()` | State change via GET — auto-triggerable in iframe | No frame-ancestors protection |
+| 480–495 | `do_close_endpoint()` | State change via GET — auto-triggerable in iframe | No frame-ancestors protection |
+| 682–684 | `raise_404()` | Custom error responses | Also missing CSP headers |
+
+---
+
+## Findings
+
+### HIGH Severity
+
+#### Finding ASVS-346-HIGH-001: Missing Content-Security-Policy frame-ancestors Directive on All Endpoints
+
+| Attribute | Detail |
+|-----------|--------|
+| **Severity** | **HIGH** |
+| **Gap Type** | **Type A** — Entry points with NO control |
+| **ASVS Requirement** | 3.4.6 — frame-ancestors CSP directive on every HTTP response |
+| **File** | `v3/server/main.py` (lines 27–42, `create_app()`) and `v3/server/pages.py` (all routes) |
+| **Function** | `create_app()` — no security header middleware registered; all 21 route handlers |
+
+**Description:**
+
+No `Content-Security-Policy` header with a `frame-ancestors` directive is set on any HTTP response. The `create_app()` function in `main.py` does not register any `after_request`/`after_response` middleware to inject security headers. No individual route handler in `pages.py` adds CSP headers to responses.
+
+**Vulnerable Code — `main.py` `create_app()` (lines 27–42):**
+
+```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 after_request hook, no CSP middleware, no security headers
+```
+
+**Affected Endpoints (all 21):**
+
+| Method | Path | Auth | Renders HTML | Clickjacking Risk |
+|--------|------|------|-------------|-------------------|
+| GET | `/` | None | Yes | Medium |
+| GET | `/voter` | Committer | Yes | High — shows elections |
+| GET | `/vote-on/<eid>` | Committer | Yes | **Critical** — vote submission form |
+| GET | `/admin` | Committer | Yes | High — admin actions |
+| GET | `/manage/<eid>` | Committer | Yes | High — election management |
+| GET | `/manage-stv/<eid>/<iid>` | Committer | Yes | High — STV management |
+| POST | `/do-vote/<eid>` | Committer | Redirect | High — accepts votes |
+| POST | `/do-create-election` | PMC | Redirect | High — creates elections |
+| GET | `/do-open/<eid>` | Committer | Redirect | **Critical** — opens election via GET |
+| GET | `/do-close/<eid>` | Committer | Redirect | **Critical** — closes election via GET |
+| POST | `/do-add-issue/<eid>` | Committer | Redirect | High |
+| POST | `/do-delete-issue/<eid>/<iid>` | Committer | Redirect | High |
+| GET | `/profile` | Auth | Yes | Medium |
+| GET | `/about` | None | Yes | Low |
+
+**Data Flow:**
+
+```
+Attacker's malicious page
+  └── <iframe src="https://voting-app.example.org/vote-on/ELECTION_ID">
+        └── Victim's authenticated session loads the vote form
+              └── Victim clicks "Submit" thinking they're interacting
+                  with the attacker's overlay
+                    └── Vote is cast without victim's informed consent
+```
+
+**Proof of Concept:**
+
+An attacker hosts the following page and lures an authenticated voter:
+
+```html
+<!DOCTYPE html>
+<html>
+<head><title>Important ASF Survey</title></head>
+<body>
+<h1>Click the button below to claim your reward!</h1>
+<div style="position: relative; width: 800px; height: 600px;">
+    <!-- Invisible iframe with voting page -->
+    <iframe src="https://steve.apache.org/vote-on/TARGET_ELECTION_ID"
+            style="position: absolute; top: 0; left: 0; width: 100%;
+                   height: 100%; opacity: 0.01; z-index: 2;">
+    </iframe>
+    <!-- Visible decoy button positioned over the "Submit Vote" button -->
+    <button style="position: absolute; top: 450px; left: 300px;
+                   z-index: 1; font-size: 24px; padding: 15px 30px;">
+        Claim Reward
+    </button>
+</div>
+</body>
+</html>
+```
+
+For the GET-based state-changing endpoints, the attack is even simpler:
+```html
+<!-- Silently opens an election -->
+<iframe src="https://steve.apache.org/do-open/TARGET_EID"
+        style="display:none;"></iframe>
+<!-- Silently closes an election -->
+<iframe src="https://steve.apache.org/do-close/TARGET_EID"
+        style="display:none;"></iframe>
+```
+
+**Impact:**
+
+- **Vote manipulation:** Authenticated voters could be tricked into casting unintended votes in elections, compromising election integrity
+- **Election state manipulation:** The GET-based `/do-open/<eid>` and `/do-close/<eid>` endpoints can be triggered via hidden iframes without any user interaction beyond page load, allowing attackers to open or close elections
+- **Administrative actions:** Election creation, issue addition/deletion can be triggered through clickjacking
+
+**Remediation:**
+
+Add a global `after_response` middleware in `create_app()` to set the CSP `frame-ancestors` directive on every response:
+
+```python
+def create_app():
+    "Create the asfquart app and its endpoints."
+
+    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)
+
+    @app.after_request
+    async def set_security_headers(response):
+        # Prevent framing by any origin (ASVS 3.4.6)
+        response.headers['Content-Security-Policy'] = (
+            "frame-ancestors 'none'"
+        )
+        # Defense-in-depth: older browser fallback
+        response.headers['X-Frame-Options'] = 'DENY'
+        return response
+
+    import pages  # noqa: F401
+    import api  # noqa: F401
+
+    return app
+```
+
+If specific pages need to be embeddable (e.g., by a known ASF domain), use a targeted allowlist:
+
+```python
+response.headers['Content-Security-Policy'] = (
+    "frame-ancestors 'self' https://whimsy.apache.org"
+)
+```
+
+---
+
+## Positive Security Patterns
+
+1. **Authentication on sensitive routes:** All state-changing and voter-facing routes use `@asfquart.auth.require({R.committer})` or stricter, preventing unauthenticated access
+2. **Session-based identity:** `basic_info()` reads session data server-side, preventing client-side identity spoofing
+3. **Security event logging:** All state-changing operations log user identity and action details
+4. **Parameterized queries:** Database access uses prepared statements via the Election class
+
+---
+
+## Architecture Observations
+
+1. **No security header middleware layer exists.** The application has no centralized mechanism for setting HTTP security headers. This is not just a CSP gap — it indicates that other security headers (e.g., `X-Content-Type-Options`, `Strict-Transport-Security`, `Referrer-Policy`) are likely also absent.
+
+2. **GET endpoints for state changes (`/do-open/<eid>`, `/do-close/<eid>`) amplify clickjacking risk.** These can be triggered by simply loading an invisible iframe — no form submission or user click needed. While this is a separate issue (HTTP method misuse), it compounds the clickjacking vulnerability significantly.
+
+3. **The `asfquart` framework does not appear to set CSP headers by default.** The `create_app()` function does not pass any CSP configuration, and the framework's `construct()` call doesn't appear to include security header defaults.
+
+---
+
+## Recommendations Summary
+
+### Immediate Actions (Priority 1)
+
+| Action | Effort | Impact | Finding |
+|--------|--------|--------|---------|
+| Add `after_request` middleware in `create_app()` setting `Content-Security-Policy: frame-ancestors 'none'` on all responses | Low (5 lines) | Closes HIGH finding across all 21 endpoints | ASVS-346-HIGH-001 |
+| Also set `X-Frame-Options: DENY` as defense-in-depth for legacy browsers | Low (1 line) | Additional coverage for older browsers | ASVS-346-HIGH-001 |
+
+### Short-term Actions (Priority 2)
+
+| Action | Effort | Impact |
+|--------|--------|--------|
+| Change `/do-open/<eid>` and `/do-close/<eid>` from GET to POST | Low | Eliminates auto-triggerable iframe attacks even without CSP |
+
+### Long-term Actions (Priority 3)
+
+| Action | Effort | Impact |
+|--------|--------|--------|
+| Audit for other missing security headers (`X-Content-Type-Options`, `Strict-Transport-Security`, `Referrer-Policy`) in the same middleware | Low | Comprehensive browser security posture |
+
+---
+
+## Appendix: Files Analyzed
+
+<details>
+<summary>Click to expand file list (3 files)</summary>
+
+1. **`v3/server/pages.py`** (relevance: 10/10)
+   - All 21 HTTP endpoints
+   - Vote submission forms
+   - Election management interfaces
+   - State-changing operations
+
+2. **`v3/server/main.py`** (relevance: 8/10)
+   - Application factory function
+   - Middleware registration point
+   - Framework initialization
+
+3. **`v3/ARCHITECTURE.md`** (relevance: 2/10)
+   - Architecture documentation
+   - Framework usage patterns
+
+</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