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:18:58 UTC

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

commit ebed268ee207c0865c95499fe82d78394e7918e3
Author: ASF Tooling Team <ro...@apache.org>
AuthorDate: Tue May 5 14:10:00 2026 +0200

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

diff --git a/ASVS/reports/steve/v3/d0aa7e9/all/8.1.2.md b/ASVS/reports/steve/v3/d0aa7e9/all/8.1.2.md
new file mode 100644
index 0000000..13d4fee
--- /dev/null
+++ b/ASVS/reports/steve/v3/d0aa7e9/all/8.1.2.md
@@ -0,0 +1,174 @@
+# Security Audit Report: ASVS 8.1.2
+
+## Executive Summary
+
+| Field | Value |
+|-------|-------|
+| **Repository** | apache/steve/v3 |
+| **Audit Date** | May 05, 2026 |
+| **Auditor** | Tooling Agents (bundled-pass mode) |
+| **ASVS Requirement** | ASVS 8.1.2 |
+| **Files Analyzed** | 11 relevant / 49 total |
+| **Files Skipped** | 12 |
+
+**Requirement description:** Verify that authorization documentation defines rules for field-level access restrictions (both read and write) based on consumer permissions and resource attributes. Note that these rules might depend on other attribute values of the relevant data object, such as state or status.
+
+### Findings Overview
+
+| Severity | Count |
+|----------|-------|
+| 🔴 Critical | 0 |
+| 🟠 High | 0 |
+| 🟡 Medium | 1 |
+| 🟢 Low | 0 |
+
+---
+
+## ASVS-8.1.2: Field-Level Authorization Documentation
+
+### Findings for 8.1.2
+
+#### [MEDIUM]
+
+**Finding ID:** ASVS-812-MED-001
+
+**Files:** `v3/steve/election.py`, `v3/docs/schema.md`
+
+**Evidence of undocumented field-level restrictions:**
+
+From `election.py`, `get_metadata()`, lines 144-158:
+```python
+def get_metadata(self):
+    "Return basic metadata about this Election."
+    md = self._all_metadata()
+    # NOTE: do not return the SALT or OPENED_KEY
+    return edict(
+        eid=md.eid,
+        title=md.title,
+        owner_pid=md.owner_pid,
+        authz=md.authz,
+        closed=md.closed,
+        open_at=md.open_at,
+        close_at=md.close_at,
+        state=self._compute_state(md),
+    )
+```
+
+From `election.py`, `get_issue()`, lines 157-163:
+```python
+def get_issue(self, iid):
+    "Return TITLE, DESCRIPTION, TYPE, and KV for issue IID."
+    issue = self.q_get_issue.first_row(iid)
+    if not issue:
+        raise IssueNotFound(iid)
+    # NEVER return issue.salt
+    return (issue.title, issue.description, issue.type, self.json2kv(issue.kv))
+```
+
+From `queries.yaml`, lines 76-85 (q_owned):
+```yaml
+q_owned: |
+    SELECT eid, title, authz, closed, open_at, close_at,
+           owner_pid, (opened_key IS NOT NULL) AS is_opened
+    FROM election WHERE owner_pid = ?
+```
+
+**Issue:** While the code implements field-level restrictions (e.g., never returning `salt` or `opened_key` to callers), these restrictions are documented only as inline code comments rather than in a formal authorization document. There is no documentation specifying:
+
+1. Which fields are sensitive and must not be exposed (salt, opened_key, vote ciphertext)
+2. Which fields are read-only after certain state transitions (title after opening, dates after closing)
+3. Which fields are writable only by specific roles (e.g., only election owner can modify title)
+4. How field access varies based on election state (editable → open → closed)
+
+The schema trigger `prevent_open_close_update` enforces that `open_at`/`close_at` cannot be modified once closed, but this constraint is not part of any authorization document.
+
+**Impact:** Without documented field-level rules, inconsistencies can emerge. For example, `_all_metadata()` returns all fields including sensitive ones internally, and any new endpoint could accidentally expose them.
+
+**Remediation:** Add field-level access documentation:
+```markdown
+# Field-Level Access Control
+
+## Election Table
+| Field | Read Access | Write Access | State Constraint |
+|-------|------------|--------------|------------------|
+| eid | All authenticated | Never (immutable) | — |
+| title | All authenticated | election_owner | Only in editable state |
+| salt | System internal ONLY | System (on open) | Set once, never modified |
+| opened_key | System internal ONLY | System (on open) | Set once, never modified |
+| open_at | All authenticated | election_owner | Not after closed |
+| close_at | All authenticated | election_owner | Not after closed |
+
+## Mayvote Table
+| Field | Read Access | Write Access |
+|-------|------------|--------------|
+| salt | System internal ONLY | System (on open) |
+| pid + iid | election_owner, system | election_owner (editable state) |
+```
+
+### Security Controls Inventory for 8.1.2
+
+| Control | Location | Status |
+|---------|----------|--------|
+| `get_metadata()` field filtering | `election.py` line 144 | Applied (excludes salt/opened_key) |
+| `get_issue()` salt exclusion | `election.py` line 157 | Applied (inline comment) |
+| `q_owned` query field selection | `queries.yaml` line 76 | Applied (excludes sensitive columns) |
+| `q_open_to_me` field selection | `queries.yaml` line 68 | Applied (excludes sensitive columns) |
+| State-based write restriction | `election.py` assertions | Applied via `assert self.is_editable()` |
+| `prevent_open_close_update` trigger | `schema.sql` | Applied (database-level enforcement) |
+| Field-level authorization documentation | N/A | DOES NOT EXIST |
+
+### Positive Patterns for 8.1.2
+
+- Code consistently excludes sensitive fields (`salt`, `opened_key`) from public-facing methods
+- SQL queries for user-facing data explicitly list columns rather than using `SELECT *`
+- Database trigger prevents modification of date fields after election closure
+- State assertions prevent modification of issues after election is opened
+
+---
+
+
+
+## Cross-cutting Architecture Observations
+
+1. **Systematic Authorization Gap (Type B):** The most critical finding across all requirements is the pattern of authorization placeholders (`### check authz`) that are never implemented. This creates a dangerous false sense of security — developers clearly intended to add authorization but it was never done. Eight separate endpoints share this identical gap.
+
+2. **Authentication ≠ Authorization Confusion:** The application conflates authentication (proving identity) with authorization (proving permission). Being an ASF committer is sufficient to perform ANY operation on ANY election. The `authz` and `owner_pid` fields exist in the schema but are completely unused in the application layer.
+
+3. **Defense-in-Depth at Data Layer:** Despite the application-level authorization failures, the `election.py` module provides some defense via state assertions (`assert self.is_editable()`) and the cryptographic design (can't decrypt votes without the proper keys). However, these protect election integrity, not confidentiality or availability.
+
+4. **Missing Documentation Pattern:** Across all 8.1.x requirements, there is no formal authorization documentation. The code comments and `TODO.md` acknowledge this debt explicitly. The `schema.md` provides data-level documentation but not security-decision documentation.
+
+5. **HTTP Method Misuse:** State-mutating operations (`do_open`, `do_close`) use GET, making them vulnerable to CSRF even before considering the placeholder CSRF token. This compounds the authorization gap.
+
+6. **Incomplete Enforcement Pattern:** Where authorization IS implemented (e.g., `vote_on_page` checks mayvote), the corresponding action endpoint (`do_vote_endpoint`) does NOT repeat the check. This creates a bypass where viewing is protected but acting is not.
+
+---
+
+## Cross-cutting Recommendations
+
+### Immediate (Critical - must fix before deployment)
+
+1. **Implement ownership checks in `load_election` decorator** — Compare `election.owner_pid` against `result.uid`. This single fix addresses ASVS-821-CRIT-001, CRIT-003, HIGH-002, and MED-001 across 8+ endpoints.
+
+2. **Add voter eligibility check in `do_vote_endpoint`** — Mirror the check from `vote_on_page()` to prevent ineligible users from submitting votes (ASVS-821-CRIT-002).
+
+3. **Change `do_open` and `do_close` from GET to POST** — Prevents trivial CSRF via link/image tags (ASVS-821-HIGH-001).
+
+### Short-term (High priority - within next sprint)
+
+4. **Implement the `authz` field enforcement** — Define and implement group-based authorization for elections that specify an authz group.
+
+5. **Create authorization documentation** (ASVS-811-HIGH-001) — Document the role hierarchy, function-level access matrix, and field-level restrictions that are already partially implemented in code.
+
+6. **Implement CSRF token generation and validation** — Replace the placeholder with real tokens, validated on all POST endpoints.
+
+7. **Document field-level access rules** — Formalize the implicit rules about salt/key exclusion from public APIs.
+
+### Long-term (Strategic improvements)
+
+8. **Consider contextual security factors** — For a voting system, logging IP addresses and implementing rate limiting would improve auditability and prevent abuse.
+
+9. **Implement session consent mechanism** — For federated authentication, add a consent step or session confirmation to meet ASVS 7.6.2.
+
+10. **Centralize authorization logic** — Instead of scattered checks, implement a policy-based authorization system (e.g., ABAC) that the decorators call 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