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 12:19:01 UTC

(tooling-agents) branch main updated: ASVS audit: 3.3.3.md (redacted)

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 ba82635  ASVS audit: 3.3.3.md (redacted)
ba82635 is described below

commit ba82635200a5026c6498f1472591076710f1676c
Author: ASF Tooling Team <ro...@apache.org>
AuthorDate: Tue May 5 14:06:30 2026 +0200

    ASVS audit: 3.3.3.md (redacted)
---
 ASVS/reports/steve/v3/d0aa7e9/all/3.3.3.md | 144 +++++++++++++++++++++++++++++
 1 file changed, 144 insertions(+)

diff --git a/ASVS/reports/steve/v3/d0aa7e9/all/3.3.3.md b/ASVS/reports/steve/v3/d0aa7e9/all/3.3.3.md
new file mode 100644
index 0000000..fe7f195
--- /dev/null
+++ b/ASVS/reports/steve/v3/d0aa7e9/all/3.3.3.md
@@ -0,0 +1,144 @@
+# Security Audit Report: ASVS 3.3.3
+
+## Executive Summary
+
+| Field | Value |
+|-------|-------|
+| **Repository** | apache/steve/v3 |
+| **Audit Date** | May 05, 2026 |
+| **Auditor** | Tooling Agents (bundled-pass mode) |
+| **ASVS Requirement** | ASVS 3.3.3 |
+| **Files Analyzed** | 11 relevant / 49 total |
+| **Files Skipped** | 12 |
+
+**Requirement description:** Verify that cookies have the '__Host-' prefix for the cookie name unless they are explicitly designed to be shared with other hosts.
+
+### Findings Overview
+
+| Severity | Count |
+|----------|-------|
+| 🔴 Critical | 0 |
+| 🟠 High | 0 |
+| 🟡 Medium | 1 |
+| 🟢 Low | 0 |
+
+---
+
+## ASVS-3.3.3: Cookie __Host- Prefix
+
+### Findings for 3.3.3
+
+#### [MEDIUM]
+**Finding ID**: ASVS-333-MED-001
+
+**Title**: Session cookie does not use `__Host-` prefix
+
+**File**: `v3/server/main.py` (lines 42-45)
+
+**Vulnerable code quote**:
+```python
+# No SESSION_COOKIE_NAME configuration with __Host- prefix
+app = asfquart.construct('steve', app_dir=THIS_DIR, static_folder=None)
+```
+
+**Data flow**: Framework creates session cookie with default name (likely `session`) → no `__Host-` prefix → cookie could potentially be set by a subdomain or over insecure connection.
+
+**Impact**: Without the `__Host-` prefix, the cookie:
+- Could be overwritten by a sibling subdomain (e.g., `evil.apache.org` setting cookies for `steve.apache.org`)
+- Does not enforce the `Secure` and `Path=/` requirements that `__Host-` mandates
+- Reduces assurance that the cookie originated from the application itself
+
+**Proof of concept**: An attacker controlling `any-subdomain.apache.org` could set a cookie with the same name as the session cookie, overwriting the legitimate session and potentially performing session fixation.
+
+**Remediation**:
+```python
+# In app configuration
+app.config['SESSION_COOKIE_NAME'] = '__Host-steve_session'
+app.config['SESSION_COOKIE_SECURE'] = True  # Required by __Host- prefix
+app.config['SESSION_COOKIE_PATH'] = '/'     # Required by __Host- prefix
+```
+
+### Security Controls Inventory for 3.3.3
+
+| Control | Location | Status |
+|---------|----------|--------|
+| `__Host-` cookie name prefix | Not found | **MISSING** |
+| Cookie `Secure` attribute | Not explicitly configured | **UNKNOWN** (framework default) |
+| Cookie `Path=/` | Not explicitly configured | **UNKNOWN** (framework default) |
+
+### Positive Patterns for 3.3.3
+
+- The application supports TLS via certfile/keyfile configuration (`main.py` lines 75-78), which is a prerequisite for `__Host-` prefix
+- The application is designed as a single-host service (not explicitly designed to share cookies with other hosts), making `__Host-` the correct choice
+
+---
+
+
+
+## Cross-cutting Architecture Observations
+
+1. **Session Management Framework Opacity**: The `asfquart` framework handles session cookies, but its configuration is not visible in the audited code. Critical security attributes (SameSite, HttpOnly, Secure, cookie name) are delegated to the framework with no explicit override. This creates an audit gap — the security posture depends on undocumented framework defaults.
+
+2. **No Security Header Middleware**: The application lacks any `after_request` handler or middleware for setting security headers. This means HSTS, CSP, X-Content-Type-Options, X-Frame-Options, and other security headers are all absent from responses.
+
+3. **CSRF Defense Completely Absent**: The combination of:
+   - Placeholder CSRF token (`'placeholder'`)
+   - No SameSite cookie attribute (verified)
+   - State-changing GET endpoints (`/do-open`, `/do-close`)
+   
+   Creates a complete absence of CSRF protection for the voting system. This is the most critical cross-cutting concern.
+
+4. **Defense-in-Depth Gap**: The application relies solely on authentication (`@asfquart.auth.require`) for security. There are no layered defenses (CSRF, origin checking, SameSite cookies, authorization checks). If any single layer is bypassed, there is no fallback.
+
+5. **Acknowledged Technical Debt**: The `TODO.md` and inline `### check authz` comments indicate the development team is aware of security gaps but has not yet addressed them. The code appears to be in active development with security controls planned but not implemented.
+
+---
+
+## Cross-cutting Recommendations
+
+### Immediate (Before Any Production Deployment)
+
+1. **Add Security Headers Middleware** (addresses ASVS 3.4.1):
+```python
+@APP.after_request
+async def security_headers(response):
+    response.headers['Strict-Transport-Security'] = 'max-age=31536000; includeSubDomains'
+    response.headers['X-Content-Type-Options'] = 'nosniff'
+    response.headers['X-Frame-Options'] = 'DENY'
+    return response
+```
+
+2. **Configure Session Cookie Securely** (addresses ASVS 3.3.2, 3.3.3, 3.3.4):
+```python
+app.config.update(
+    SESSION_COOKIE_NAME='__Host-steve_session',
+    SESSION_COOKIE_HTTPONLY=True,
+    SESSION_COOKIE_SECURE=True,
+    SESSION_COOKIE_SAMESITE='Strict',
+    SESSION_COOKIE_PATH='/',
+)
+```
+
+3. **Convert State-Changing GET Endpoints to POST** (addresses ASVS 3.3.2):
+   - `/do-open/<eid>` → POST with CSRF token
+   - `/do-close/<eid>` → POST with CSRF token
+
+### Short-term (Within Next Sprint)
+
+4. **Implement Real CSRF Protection** (supports ASVS 3.3.2):
+   - Generate cryptographically random tokens per session
+   - Validate tokens on all state-changing endpoints
+   - Combine with `SameSite=Strict` for defense-in-depth
+
+5. **Add Cookie Size Monitoring** (addresses ASVS 3.3.5):
+   - Log warnings if session cookie approaches 4096 bytes
+   - Consider server-side session storage if flash messages grow
+
+### Long-term (Architecture)
+
+6. **Audit asfquart Framework**: Review the `asfquart` framework source code to verify default cookie attributes, as the application delegates all cookie security to this dependency.
+
+7. **Implement Authorization Layer**: Address the `### check authz` placeholders throughout the codebase to ensure election owners/authorized groups are properly validated, complementing the cookie security controls.
+
+8. **Security Testing**: Add integration tests that verify response headers include HSTS, cookie attributes include SameSite/HttpOnly/Secure, and no CORS headers leak on sensitive endpoints.
+        
\ 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