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 20:54:23 UTC

(tooling-agents) branch main updated: ASVS audit: 15.3.7.md (redacted) [source: apache/steve/v3 @ d0aa7e9]

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 f991ea2  ASVS audit: 15.3.7.md (redacted) [source: apache/steve/v3 @ d0aa7e9]
f991ea2 is described below

commit f991ea2121e5684364c358b98fe96d39c8c69d6c
Author: ASF Tooling Team <ro...@apache.org>
AuthorDate: Tue May 5 22:54:03 2026 +0200

    ASVS audit: 15.3.7.md (redacted) [source: apache/steve/v3 @ d0aa7e9]
---
 ASVS/reports/steve/v3/d0aa7e9/all/15.3.7.md | 166 ++++++++++++++++++++++++++++
 1 file changed, 166 insertions(+)

diff --git a/ASVS/reports/steve/v3/d0aa7e9/all/15.3.7.md b/ASVS/reports/steve/v3/d0aa7e9/all/15.3.7.md
new file mode 100644
index 0000000..67aba97
--- /dev/null
+++ b/ASVS/reports/steve/v3/d0aa7e9/all/15.3.7.md
@@ -0,0 +1,166 @@
+# Security Audit Report: ASVS 15.3.7
+
+## Executive Summary
+
+| Field | Value |
+|-------|-------|
+| **Repository** | apache/steve/v3 |
+| **Audit Date** | May 05, 2026 |
+| **Auditor** | Tooling Agents (bundled-pass mode) |
+| **ASVS Requirement** | ASVS 15.3.7 |
+| **Files Analyzed** | 3 relevant / 49 total |
+| **Files Skipped** | 12 |
+
+**Requirement description:** Verify that the application has defenses against HTTP parameter pollution attacks, particularly if the application framework makes no distinction about the source of request parameters (query string, body parameters, cookies, or header fields).
+
+### Findings Overview
+
+| Severity | Count |
+|----------|-------|
+| 🔴 Critical | 0 |
+| 🟠 High | 0 |
+| 🟡 Medium | 1 |
+| 🟢 Low | 1 |
+
+---
+
+## ASVS-15.3.7: HTTP Parameter Pollution Defenses
+
+### Findings for 15.3.7
+
+### [MEDIUM]
+**Finding ID:** ASVS-1537-MED-001
+
+**File:** `v3/server/pages.py`, function `do_vote_endpoint`, lines 383-394
+
+**Vulnerable code:**
+```python
+form = edict(await quart.request.form)
+if not form:
+    await flash_danger('No vote data provided.')
+    return quart.redirect(f'/vote-on/{election.eid}', code=303)
+
+votes = {}
+for key, value in form.items():
+    if key.startswith('vote-'):
+        iid = key.split('-', 1)[1]
+        votes[iid] = value
+```
+
+**Data flow:** HTTP POST form body → `request.form` (MultiDict) → `edict()` → iteration → vote dictionary
+
+**Proof of concept:** Quart's `request.form` is a `MultiDict` that can contain multiple values for the same key. When wrapped with `edict()` (which calls `dict()` on it), if duplicate keys exist (e.g., `vote-abc123` submitted twice), only the last value survives. An attacker could submit:
+```
+POST /do-vote/<eid>
+Content-Type: application/x-www-form-urlencoded
+
+vote-issue1=yes&vote-issue1=no
+```
+The `edict()` constructor would only retain one value (implementation-dependent which one), potentially overriding the voter's intended choice.
+
+**Impact:** Vote manipulation through duplicate parameter submission. The voter's intended vote could be overridden by a parameter injected later in the request body.
+
+**Remediation:**
+```python
+form = await quart.request.form
+# Explicitly handle multi-valued keys
+votes = {}
+for key in form.keys():
+    if key.startswith('vote-'):
+        values = form.getlist(key)
+        if len(values) != 1:
+            await flash_danger(f'Duplicate vote parameter detected for {key}.')
+            return quart.redirect(f'/vote-on/{election.eid}', code=303)
+        iid = key.split('-', 1)[1]
+        votes[iid] = values[0]
+```
+
+---
+
+### [LOW]
+**Finding ID:** ASVS-1537-LOW-001
+
+**File:** `v3/server/pages.py`, function `_set_election_date`, line 91
+
+**Vulnerable code:**
+```python
+data = await quart.request.get_json()
+date_str = data.get('date')
+```
+
+**Data flow:** HTTP request JSON body → `get_json()` → dict → `.get('date')`
+
+**Proof of concept:** If `get_json()` receives a JSON array or a JSON object with multiple `date` keys (last one wins per JSON spec), the behavior could be unexpected. JSON with duplicate keys: `{"date": "2024-01-01", "date": "2099-12-31"}` — Python's JSON parser retains the last value.
+
+**Impact:** Low. JSON duplicate keys are unusual and the last-wins behavior is deterministic. However, if a proxy or WAF inspects the first value while the application uses the last, this could be exploited for bypass.
+
+**Remediation:** Use a JSON parser that rejects duplicate keys or explicitly validate the parsed structure.
+
+---
+
+### Security Controls Inventory for 15.3.7
+
+| Control | Location | Coverage Status |
+|---------|----------|-----------------|
+| Explicit source selection (`request.form`) | `pages.py` - all POST handlers | ✅ Applied consistently |
+| Explicit source selection (`request.get_json()`) | `pages.py` `_set_election_date` | ✅ Applied |
+| URL path parameters via router | All `<eid>`, `<iid>` parameters | ✅ Framework-handled |
+| Multi-value detection/rejection | N/A | ❌ NOT present |
+| `request.values` (combined) usage | N/A | ✅ NOT used (positive) |
+
+### Positive Patterns for 15.3.7
+
+1. **Explicit parameter source**: The code consistently uses `request.form` for POST body data and `request.get_json()` for JSON payloads, never mixing sources via `request.values`.
+2. **URL path parameters**: Election IDs and issue IDs are extracted from URL path segments by the Quart router, completely separate from query/body parameters.
+3. **No cookie-as-parameter usage**: The code reads session data via dedicated session API (`asfquart.session.read()`), never treating cookies as request parameters.
+
+---
+
+
+
+## Cross-cutting Architecture Observations
+
+1. **Python + Async + SQLite Architecture**: The combination of Quart (async framework) with SQLite (file-based database) creates an inherent tension. SQLite's file-level locking doesn't align well with concurrent async request handling. While the single-threaded nature of asyncio mitigates threading issues, the lack of connection pooling and proper busy-timeout handling means production deployments could experience contention.
+
+2. **Assertion-based validation**: The codebase extensively uses `assert` statements for state validation (`assert self.is_editable()`). In production Python (`-O` flag), assertions are stripped entirely, removing all state guards. This is a systemic architectural risk that spans multiple ASVS requirements.
+
+3. **EasyDict usage throughout**: The pervasive use of `EasyDict` means type information is lost at runtime. While convenient, it makes it impossible to enforce schemas on data structures, creating a gap for type safety (15.3.5) and mass assignment concerns.
+
+4. **Separation of concerns**: The `Election` class handles both data access and business logic. The web layer (`pages.py`) directly instantiates `Election` objects rather than going through a service layer, which makes it harder to apply cross-cutting concerns like atomic transactions spanning business operations.
+
+5. **Authorization gap pattern**: The `### check authz` placeholders throughout `pages.py` indicate a systematic Type B gap — the authentication framework exists and is applied, but fine-grained authorization (ownership verification) is consistently missing.
+
+---
+
+## Cross-cutting Recommendations
+
+### Immediate (Critical/High Priority)
+
+1. **Replace assertions with proper validation**: Convert all `assert self.is_editable()` patterns to explicit checks that raise proper exceptions and cannot be disabled with `-O`:
+   ```python
+   if not self.is_editable():
+       raise ElectionBadState(self.eid, self.get_state(), self.S_EDITABLE)
+   ```
+
+2. **Add transaction error handling**: Wrap all `BEGIN TRANSACTION`/`COMMIT` blocks in try/except with explicit `ROLLBACK` on failure to prevent database lock leaks.
+
+3. **Make election state transitions atomic**: Combine state checks and state changes into single transactions using `BEGIN IMMEDIATE` to prevent TOCTOU races on open/close operations.
+
+### Short-term (Medium Priority)
+
+4. **Configure SQLite busy timeout**: Add `PRAGMA busy_timeout = 5000` on every new connection to handle concurrent access gracefully.
+
+5. **Add type validation for JSON inputs**: Verify that `get_json()` returns a dict and that expected fields have correct types before processing.
+
+6. **Implement duplicate parameter detection**: Check for multi-valued form parameters in vote submission and other form-processing endpoints.
+
+7. **Unify transaction patterns**: Adopt a consistent approach (e.g., context manager) for all database write operations.
+
+### Long-term (Architectural)
+
+8. **Consider database migration**: For production use with concurrent access, consider migrating from SQLite to PostgreSQL, which has proper row-level locking and better concurrency support.
+
+9. **Add application-level write serialization**: Implement an asyncio Lock for state-changing operations on the same election to prevent concurrent modification.
+
+10. **Implement a service layer**: Separate business logic from data access to centralize transaction management and make it easier to apply atomic operation patterns consistently.
+        
\ 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