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:01:17 UTC

(tooling-agents) branch main updated: ASVS audit: 10.2.1.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 7bb82de  ASVS audit: 10.2.1.md (redacted)
7bb82de is described below

commit 7bb82de0ea1d476564dc9303bba798286d2ddb26
Author: ASF Tooling Team <ro...@apache.org>
AuthorDate: Tue May 5 14:01:01 2026 +0200

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

diff --git a/ASVS/reports/steve/v3/d0aa7e9/all/10.2.1.md b/ASVS/reports/steve/v3/d0aa7e9/all/10.2.1.md
new file mode 100644
index 0000000..8509bd2
--- /dev/null
+++ b/ASVS/reports/steve/v3/d0aa7e9/all/10.2.1.md
@@ -0,0 +1,151 @@
+# Security Audit Report: ASVS 10.2.1
+
+## Executive Summary
+
+| Field | Value |
+|-------|-------|
+| **Repository** | apache/steve/v3 |
+| **Audit Date** | May 05, 2026 |
+| **Auditor** | Tooling Agents (bundled-pass mode) |
+| **ASVS Requirement** | ASVS 10.2.1 |
+| **Files Analyzed** | 10 relevant / 49 total |
+| **Files Skipped** | 12 | **Requirement description:** Verify that, if the code flow is used, the OAuth client has protection against browser-based request forgery attacks, commonly known as cross-site request forgery (CSRF), which trigger token requests, either by using proof key for code exchange (PKCE) functionality or checking the 'state' parameter…
+
+### Findings Overview
+
+| Severity | Count |
+|----------|-------|
+| πŸ”΄ Critical | 2 |
+| 🟠 High | 1 |
+| 🟑 Medium | 0 |
+| 🟒 Low | 0 | ---
+
+## ASVS-10.2.1: CSRF Protection for OAuth Code Flow
+
+### Findings for 10.2.1
+
+## need general solution
+@load_election
+async def do_open_endpoint(election):
+    result = await basic_info()
+    ### check authz
+    pdb = steve.persondb.PersonDB.open(DB_FNAME)
+    election.open(pdb)
+    ...
+```
+
+**Description:** State-changing operations (`do-open` and `do-close`) use GET requests. This is a severe CSRF vulnerability because:
+1. GET requests can be triggered by any `<img>`, `<iframe>`, or link
+2. No CSRF token validation occurs
+3. The operations are irreversible ("Opening this election... is permanent")
+
+**Data flow:** Attacker crafts `<img src="/do-open/TARGET_EID">` β†’ Victim browser sends GET with session cookie β†’ Election is permanently opened/closed
+
+**Gap Type:** Type A β€” No CSRF control at all for GET-based state changes.
+
+**Proof of concept:**
+```html
+<!-- Placed on attacker's website -->
+<img src="https://voting.example.org/do-open/abc123def4" style="display:none">
+<img src="https://voting.example.org/do-close/abc123def4" style="display:none">
+```
+Any authenticated committer visiting the attacker's page would trigger these irreversible operations.
+
+**Impact:** An attacker can permanently open or close any election by tricking any authenticated committer into loading a page with the crafted URL. The operations are irreversible.
+
+**Remediation:**
+```python
+@APP.post('/do-open/<eid>')  # Change to POST
+@asfquart.auth.require({R.committer})
+@load_election
+async def do_open_endpoint(election):
+    await validate_csrf(await quart.request.form)  # Validate CSRF
+    # ... rest of implementation
+```
+
+Update templates to use form submissions instead of `window.location.href`:
+```javascript
+confirmOpen.addEventListener('click', () => {
+    openModal.hide();
+    // Use form POST instead of GET redirect
+    const form = document.createElement('form');
+    form.method = 'POST';
+    form.action = '/do-open/[eid]';
+    const csrf = document.createElement('input');
+    csrf.type = 'hidden';
+    csrf.name = 'csrf_token';
+    csrf.value = csrfToken;
+    form.appendChild(csrf);
+    document.body.appendChild(form);
+    form.submit();
+});
+```
+
+## Security Controls Inventory for 10.2.1
+
+| Control | Location | Status |
+|---------|----------|--------|
+| OAuth state/PKCE | `asfquart` library (external) | ⚠️ Not inspectable |
+| Application CSRF token generation | `pages.py:83` | ❌ Placeholder |
+| Application CSRF token validation | None | ❌ Not implemented |
+| GET for state changes | `pages.py:431,451` | ❌ Violates safe methods |
+| SameSite cookie attribute | Not visible | ⚠️ Not inspectable | ### Positive Patterns for 10.2.1
+
+1. **POST method for most mutations**: Most state-changing endpoints correctly use POST (voting, creating elections, adding/editing/deleting issues, setting dates). Only `do-open` and `do-close` incorrectly use GET.
+2. **Template infrastructure**: All forms include CSRF token hidden fields, ready for server-side validation.
+3. **Confirmation modals**: UI requires user interaction before state changes, which adds a thin layer of social-engineering resistance (but is NOT a security control).
+
+---
+
+
+> **Note:** 2 Critical findings have been redacted from this report and forwarded to the project's PMC private mailing list.
+
+
+
+
+## Cross-cutting Architecture Observations
+
+1. **OAuth/OIDC Implementation is External**: The actual OAuth/OIDC client implementation (token handling, authorization code flow, PKCE, state parameter) is entirely within the `asfquart` library, which is not provided for review. This limits the ability to fully assess requirements 10.1.1, 10.1.2, 10.2.1, 10.2.2, 10.2.3, and 10.3.1.
+
+2. **Session-Based Architecture**: The application uses a server-side session pattern where OAuth tokens are exchanged for a session. This is architecturally sound for 10.1.1 (tokens stay server-side) but shifts the security burden to session management.
+
+3. **CSRF Protection is Entirely Missing**: The most critical cross-cutting issue is the complete absence of CSRF protection. The placeholder token creates a false sense of security in the codebase. This affects requirements 10.1.2 and 10.2.1 directly.
+
+4. **State-Changing GET Requests**: The `/do-open/<eid>` and `/do-close/<eid>` endpoints perform irreversible operations via GET requests, violating HTTP semantics and creating trivially exploitable CSRF vulnerabilities.
+
+5. **Authorization Gaps**: Multiple `### check authz` placeholder comments indicate that ownership/permission validation is not implemented. Any authenticated committer can manage any election, regardless of ownership. This is a broader security issue that compounds with the CSRF vulnerabilities.
+
+6. **Acknowledged Issues**: The `TODO.md` file demonstrates awareness of the CSRF and authorization issues, indicating these are known technical debt rather than unknown vulnerabilities.
+
+---
+
+## Cross-cutting Recommendations
+
+### Immediate (P0 β€” Deploy blockers)
+
+1. **Implement real CSRF tokens**: Generate per-session cryptographic tokens using `secrets.token_hex(32)`, store in session, validate on all POST/state-changing endpoints. Estimated effort: 2-4 hours.
+
+2. **Convert GET state-changes to POST**: Change `/do-open/<eid>` and `/do-close/<eid>` from GET to POST, update templates to use form submissions with CSRF tokens. Estimated effort: 1 hour.
+
+3. **Implement ownership authorization**: Add checks that verify the authenticated user owns or has permission to manage an election before allowing open/close/edit/delete operations. Estimated effort: 4-8 hours.
+
+### Short-term (P1 β€” Next sprint)
+
+4. **Audit `asfquart` library**: Review the `asfquart` library's OAuth implementation to verify:
+   - PKCE or state parameter usage in authorization code flow
+   - Token audience validation
+   - Token storage security (HttpOnly, Secure cookies)
+   - Session fixation protection
+
+5. **Add SameSite cookie attributes**: Ensure session cookies use `SameSite=Lax` or `SameSite=Strict` as an additional CSRF defense layer.
+
+6. **Validate `docname` in `serve_doc()`**: While not OAuth-related, the path traversal risk in document serving should be addressed alongside authentication improvements.
+
+### Long-term (P2 β€” Architecture improvements)
+
+7. **Consider token-bound sessions**: If the infrastructure supports it, implement sender-constrained tokens (DPoP or mTLS) to prevent token theft/replay.
+
+8. **Implement rate limiting**: Add rate limiting on authentication-dependent endpoints to prevent brute-force attacks on election IDs.
+
+9. **Add security headers**: Implement `Content-Security-Policy`, `X-Content-Type-Options`, `X-Frame-Options` headers to complement the OAuth security posture.
+        
\ 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