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/21 22:49:00 UTC
(tooling-agents) branch main updated: ASVS L3 audit: 10.4.8 (authentication_and_session)
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 2d17ce3 ASVS L3 audit: 10.4.8 (authentication_and_session)
2d17ce3 is described below
commit 2d17ce34803fd6d3f69ec4adecf00d8b5ea830d4
Author: ASF Tooling Team <ro...@apache.org>
AuthorDate: Wed Apr 22 00:48:55 2026 +0200
ASVS L3 audit: 10.4.8 (authentication_and_session)
---
.../d0aa7e9/authentication_and_session/10.4.8.md | 337 +++++++++++++++++++++
1 file changed, 337 insertions(+)
diff --git a/repos/apache/ASVS/reports/steve/v3/d0aa7e9/authentication_and_session/10.4.8.md b/repos/apache/ASVS/reports/steve/v3/d0aa7e9/authentication_and_session/10.4.8.md
new file mode 100644
index 0000000..893f442
--- /dev/null
+++ b/repos/apache/ASVS/reports/steve/v3/d0aa7e9/authentication_and_session/10.4.8.md
@@ -0,0 +1,337 @@
+# ASVS 10.4.8 Security Audit Report
+
+## Executive Summary
+
+- **Repository:** apache/steve
+- **Audit Date:** Apr 21, 2026
+- **Auditor:** Tooling Agents
+- **ASVS Requirement:** 10.4.8 — Verify that refresh tokens have an absolute expiration, including if sliding refresh token expiration is applied.
+- **Level:** 2
+- **Section:** OAuth Authorization Server
+- **Section Description:** These requirements detail the responsibilities for OAuth authorization servers, including OpenID Providers. For client authentication, the 'self_signed_tls_client_auth' method is allowed with the prerequisites required by [section 2.2](https://datatracker.ietf.org/doc/html/rfc8705#name-self-signed-certificate-mut) of [RFC 8705](https://datatracker.ietf.org/doc/html/rfc8705).
+- **Files analyzed:** 3 relevant out of 3 total, 0 skipped
+
+### Finding Counts
+
+| Severity | Count |
+|----------|-------|
+| Critical | 0 |
+| High | 0 |
+| Medium | 1 |
+| Low | 0 |
+| **Total** | **1** |
+
+### Key Observations
+
+This application acts as an **OAuth Client (Relying Party)**, delegating authentication to an external Authorization Server (`oauth.apache.org`). The application does not implement an OAuth Authorization Server and therefore does not issue refresh tokens directly. However, the audit reveals that the client-side code has no visible mechanism to enforce token/session absolute expiration boundaries that would complement the AS's token lifecycle, creating a gap in end-to-end expiration enforcement.
+
+---
+
+## Security Controls Inventory
+
+### Token/Session Lifecycle Controls
+
+| Control | Location | Purpose | Coverage Status |
+|---------|----------|---------|-----------------|
+| OAuth URL configuration | `main.py:40-43` | Configure external OAuth AS endpoints | ✅ Present — uses HTTPS |
+| Session reading | `pages.py:77` (`asfquart.session.read()`) | Read authenticated user session | ✅ Present |
+| Session absolute expiration config | Not found in provided code | Enforce maximum session lifetime | ⚠️ Not visible |
+| Token expiration verification | Not found in provided code | Validate token freshness | ⚠️ Not visible |
+| Refresh token storage/rotation | Not found in provided code | Manage refresh token lifecycle | ⚠️ Not visible |
+| Session lifetime configuration | Not found in provided code | Configure `PERMANENT_SESSION_LIFETIME` | ⚠️ Not visible |
+
+### Entry Point Coverage Analysis
+
+| Entry Point (Session-Dependent) | Session Read | Expiration Check | Freshness Validation |
+|--------------------------------|--------------|------------------|---------------------|
+| `GET /voter` | ✅ via `basic_info()` | ❌ Not visible | ❌ Not visible |
+| `POST /do-vote/<eid>` | ✅ via `basic_info()` | ❌ Not visible | ❌ Not visible |
+| `POST /do-create-election` | ✅ via `basic_info()` | ❌ Not visible | ❌ Not visible |
+| `GET /do-open/<eid>` | ✅ via `basic_info()` | ❌ Not visible | ❌ Not visible |
+| `GET /do-close/<eid>` | ✅ via `basic_info()` | ❌ Not visible | ❌ Not visible |
+| All other authenticated routes | ✅ via `basic_info()` | ❌ Not visible | ❌ Not visible |
+
+---
+
+## Critical File Review
+
+### `main.py` — OAuth Configuration
+
+| Line(s) | Element | Security Function | Risk Assessment |
+|----------|---------|------------------|-----------------|
+| 40-41 | `OAUTH_URL_INIT` | OAuth flow initiation | ⚠️ No visible state parameter entropy validation |
+| 42 | `OAUTH_URL_CALLBACK` | Token exchange endpoint | ✅ Uses HTTPS |
+| 45 | `asfquart.construct()` | Application initialization | ⚠️ No session lifetime configuration visible |
+
+### `pages.py` — Session Handling
+
+| Line(s) | Element | Security Function | Risk Assessment |
+|----------|---------|------------------|-----------------|
+| 77 | `asfquart.session.read()` | Session retrieval | ⚠️ No expiration/freshness validation |
+| 60-90 | `basic_info()` | User session extraction | ⚠️ No timestamp-based validation |
+| 89 | `csrf_token = 'placeholder'` | CSRF protection | ⚠️ Not implemented (acknowledged) |
+| Multiple | `@asfquart.auth.require` | Authentication enforcement | ✅ Consistently applied |
+
+### `asf-load-ldap.py` — LDAP Integration
+
+| Line(s) | Element | Security Function | Risk Assessment |
+|----------|---------|------------------|-----------------|
+| 33 | LDAP connection | Directory service access | ✅ Uses `ldaps://` (TLS-encrypted) |
+
+---
+
+## Findings
+
+### Medium Severity
+
+#### ASVS-1048-SEV-001: No Visible Session/Token Absolute Expiration Enforcement in OAuth Client
+
+**Severity:** MEDIUM
+
+**Location:**
+- **File:** `v3/server/main.py`
+- **Lines:** 36-48
+- **Function:** `create_app()`
+
+**Additional Locations:**
+- **File:** `v3/server/pages.py`
+- **Lines:** 60-90
+- **Function:** `basic_info()`
+
+**Related Functions Checked:**
+- `asfquart.construct()` (main.py:45)
+- `asfquart.session.read()` (pages.py:77)
+- All authenticated route handlers in `pages.py`
+
+**Description:**
+
+The application lacks visible enforcement of absolute session or token expiration at the client level. While the application delegates authentication to an external OAuth Authorization Server (`oauth.apache.org`), there is no application-level mechanism to ensure sessions derived from OAuth tokens respect absolute expiration boundaries.
+
+**Vulnerable Code:**
+
+`main.py:36-48`:
+```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)
+ # No session lifetime, token expiration, or cookie configuration visible
+```
+
+`pages.py:60-90`:
+```python
+async def basic_info():
+ """Return base-level EZT template data."""
+ basic = edict()
+ # ...
+ s = await asfquart.session.read()
+ if s:
+ basic.update(
+ uid=s['uid'],
+ name=s['fullname'],
+ email=s['email'],
+ )
+ else:
+ basic.update(uid=None, name=None, email=None)
+ # No check for session age, token expiration, or creation timestamp
+ # ...
+ return basic
+```
+
+**Data Flow:**
+
+1. User authenticates via `oauth.apache.org` (external AS)
+2. Authorization code exchanged for token via `OAUTH_URL_CALLBACK`
+3. `asfquart` creates a session (mechanism not visible in provided code)
+4. All subsequent requests read session via `asfquart.session.read()` — **no expiration or freshness check at the application level**
+5. Session persists until explicitly invalidated or framework default (unknown)
+
+**Gap Classification:**
+
+Type A — No visible control for session/token absolute expiration at the application level. The `asfquart.construct()` call includes no session lifetime configuration, and `basic_info()` performs no timestamp-based session validation.
+
+**Proof of Concept:**
+
+```
+1. User authenticates via OAuth → session established
+2. Time passes beyond the AS's intended refresh token expiration
+3. User continues accessing authenticated routes (e.g., GET /voter, POST /do-vote/<eid>)
+4. Application reads session via basic_info() — no timestamp check
+5. If asfquart doesn't enforce absolute timeout, access continues indefinitely
+```
+
+**Impact:**
+
+- If `asfquart` does not internally enforce absolute session expiration, sessions derived from OAuth tokens could persist indefinitely
+- Even if the AS properly expires refresh tokens (per ASVS 10.4.8), the client session may outlive the intended token lifetime
+- Long-lived sessions increase the window for session hijacking, particularly for a voting application where temporal bounds on voting windows are security-critical
+- For an election system, a session that persists beyond an election's close could theoretically allow late vote submission (dependent on other controls)
+
+**Remediation:**
+
+**Step 1:** Configure explicit session absolute expiration in the application:
+
+```python
+def create_app():
+ import datetime
+
+ app = asfquart.construct('steve', app_dir=THIS_DIR, static_folder=None)
+
+ # Enforce absolute session expiration
+ app.config['PERMANENT_SESSION_LIFETIME'] = datetime.timedelta(hours=8)
+ app.config['SESSION_COOKIE_SECURE'] = True
+ app.config['SESSION_COOKIE_HTTPONLY'] = True
+ app.config['SESSION_COOKIE_SAMESITE'] = 'Lax'
+
+ return app
+```
+
+**Step 2:** Store the authentication timestamp in the session and validate it:
+
+```python
+import time
+
+async def basic_info():
+ basic = edict()
+ s = await asfquart.session.read()
+ if s:
+ # Check absolute session age
+ created_at = s.get('created_at')
+ if created_at:
+ age = time.time() - created_at
+ MAX_SESSION_AGE = 8 * 3600 # 8 hours absolute maximum
+ if age > MAX_SESSION_AGE:
+ await asfquart.session.invalidate()
+ quart.abort(401, 'Session expired')
+ basic.update(uid=s['uid'], name=s['fullname'], email=s['email'])
+ else:
+ basic.update(uid=None, name=None, email=None)
+ return basic
+```
+
+**Step 3:** Ensure the OAuth callback handler stores the creation timestamp:
+
+```python
+# In the OAuth callback handler (not visible in provided code)
+async def oauth_callback():
+ # ... token exchange logic ...
+ session_data = {
+ 'uid': user_id,
+ 'fullname': full_name,
+ 'email': email,
+ 'created_at': time.time() # Add creation timestamp
+ }
+ await asfquart.session.write(session_data)
+```
+
+---
+
+## Positive Security Patterns
+
+| Pattern | Location | Assessment |
+|---------|----------|------------|
+| HTTPS for OAuth endpoints | `main.py:40-43` | ✅ Both OAuth URLs use `https://` protocol, preventing token interception |
+| Authentication decorators on all state-changing routes | `pages.py` (multiple) | ✅ Consistent use of `@asfquart.auth.require` ensures authentication enforcement |
+| External OAuth AS delegation | `main.py:40-43` | ✅ Authentication delegated to dedicated AS (`oauth.apache.org`) rather than custom implementation |
+| Session-based user identity | `pages.py:77-87` | ✅ User identity derived from server-side session, not client-side tokens |
+| LDAPS for LDAP connection | `asf-load-ldap.py:33` | ✅ Uses `ldaps://` (TLS-encrypted LDAP) for directory service access |
+| Audit logging of sensitive operations | `pages.py` (multiple) | ✅ User actions logged with UIDs and election IDs for accountability |
+
+---
+
+## Architecture Observations
+
+| Aspect | Observation |
+|--------|-------------|
+| **OAuth Role** | OAuth Client / Relying Party — NOT an Authorization Server |
+| **External AS** | `oauth.apache.org` (configured in lines 40-43 of `main.py`) |
+| **Session Framework** | `asfquart.session` — source code not provided in audit scope |
+| **Token Handling** | Entirely delegated to `asfquart` framework internals |
+| **Refresh Token Management** | No refresh token handling visible in application code |
+| **Token Exchange** | `OAUTH_URL_CALLBACK = 'https://oauth.apache.org/token?code=%s'` — authorization code → token exchange |
+| **Application Type** | Web-based voting system requiring temporal session boundaries |
+
+**Key Architectural Finding:**
+
+The ASVS 10.4.8 requirement primarily targets the Authorization Server. Since `oauth.apache.org` is external and its code is not provided, the core requirement **cannot be directly verified** from this codebase. The findings above address the client-side complement to this requirement — ensuring that even if the AS properly implements refresh token absolute expiration, the client application enforces corresponding session boundaries.
+
+---
+
+## Recommendations Summary
+
+### Immediate Actions (0-30 days)
+
+| Priority | Recommendation | Rationale | Effort |
+|----------|---------------|-----------|--------|
+| 1 | **Configure explicit session absolute expiration** in `asfquart.construct()` or app configuration | Ensures sessions cannot persist indefinitely regardless of framework defaults | Low |
+| 2 | **Add creation timestamp to sessions** and validate absolute age in `basic_info()` | Application-level defense-in-depth for absolute expiration | Low |
+
+### Short-term Actions (1-3 months)
+
+| Priority | Recommendation | Rationale | Effort |
+|----------|---------------|-----------|--------|
+| 3 | **Verify `asfquart` framework's token handling** — confirm whether the framework stores refresh tokens, rotates them, and respects AS-defined expiration | Cannot be determined from provided code; critical for overall OAuth security posture | Medium |
+| 4 | **Document the OAuth token lifecycle** end-to-end: AS token issuance → client storage → session creation → session expiration → re-authentication | Provides assurance that ASVS 10.4.8 is satisfied across the entire flow | Low |
+
+### Long-term Actions (3-6 months)
+
+| Priority | Recommendation | Rationale | Effort |
+|----------|---------------|-----------|--------|
+| 5 | **Audit the external AS (`oauth.apache.org`)** against ASVS 10.4.8 requirements | Core requirement verification requires AS code review | High |
+| 6 | **Implement session activity monitoring** to detect anomalous long-lived sessions | Additional detection layer for session abuse | Medium |
+| 7 | **Add sliding window expiration** with absolute maximum to balance usability and security | Reduces friction for active users while maintaining hard limits | Medium |
+
+---
+
+## Conclusion
+
+The application does not implement an OAuth Authorization Server; it is an OAuth client delegating to `oauth.apache.org`. Therefore, the core ASVS 10.4.8 requirement (refresh token absolute expiration at the AS) **cannot be verified from this codebase**. The external AS (`oauth.apache.org`) must be audited separately against this requirement.
+
+On the client side, one MEDIUM finding was identified: the absence of visible session/token absolute expiration enforcement, which is the client-side complement needed to fully realize the security intent of ASVS 10.4.8. The `asfquart` framework may enforce this internally, but this cannot be confirmed from the provided source code.
+
+**Risk Assessment:** The identified gap creates a potential window for session persistence beyond intended token lifetimes. For a voting application where temporal boundaries are security-critical (e.g., preventing votes after election close), this represents a moderate risk that should be addressed through the recommended session lifetime controls.
+
+---
+
+## Appendix: Files Analyzed
+
+<details>
+<summary><strong>Click to expand full file list (3 files)</strong></summary>
+
+### Files In Scope
+
+1. **`v3/server/bin/asf-load-ldap.py`** (relevance: 10/10)
+ - LDAP integration for user directory
+ - Uses secure `ldaps://` protocol
+ - Not directly related to OAuth token lifecycle
+
+2. **`v3/server/main.py`** (relevance: 10/10)
+ - Application entry point and OAuth configuration
+ - Configures external AS endpoints
+ - **Key finding location:** Missing session lifetime configuration
+
+3. **`v3/server/pages.py`** (relevance: 10/10)
+ - Request handlers and session management
+ - Contains `basic_info()` function used across all authenticated routes
+ - **Key finding location:** No session expiration validation
+
+### Files Not Provided (Referenced but not in scope)
+
+- `asfquart` framework source code (session management internals)
+- `oauth.apache.org` Authorization Server implementation
+- OAuth callback handler implementation (token exchange logic)
+
+</details>
+
+---
+
+**Report Generated:** Apr 21, 2026
+**Audit Framework:** ASVS 4.0 (OAuth and OIDC Chapter)
+**Methodology:** Static code analysis with OAuth RFC alignment review
\ 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