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/22 04:14:34 UTC
(tooling-agents) branch main updated: ASVS L3 audit: 14.2.6 (sensitive_data_handling)
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 4eb1619 ASVS L3 audit: 14.2.6 (sensitive_data_handling)
4eb1619 is described below
commit 4eb1619ce810ac1d4be243f1154323ac24324c37
Author: ASF Tooling Team <ro...@apache.org>
AuthorDate: Wed Apr 22 06:14:30 2026 +0200
ASVS L3 audit: 14.2.6 (sensitive_data_handling)
---
.../v3/d0aa7e9/sensitive_data_handling/14.2.6.md | 400 +++++++++++++++++++++
1 file changed, 400 insertions(+)
diff --git a/repos/apache/ASVS/reports/steve/v3/d0aa7e9/sensitive_data_handling/14.2.6.md b/repos/apache/ASVS/reports/steve/v3/d0aa7e9/sensitive_data_handling/14.2.6.md
new file mode 100644
index 0000000..f116265
--- /dev/null
+++ b/repos/apache/ASVS/reports/steve/v3/d0aa7e9/sensitive_data_handling/14.2.6.md
@@ -0,0 +1,400 @@
+# Security Audit Report: ASVS 14.2.6 — Minimum Sensitive Data Return
+
+## Executive Summary
+
+- **Repository:** apache/steve
+- **Audit Date:** Apr 22, 2026
+- **Auditor:** Tooling Agents
+- **ASVS Requirement:** 14.2.6 — Verify that the application only returns the minimum required sensitive data for the application's functionality. For example, only returning some of the digits of a credit card number and not the full number. If the complete data is required, it should be masked in the user interface unless the user specifically views it.
+- **ASVS Level:** 3
+- **Section:** General Data Protection
+- **Files Analyzed:** 20 relevant out of 20 total, 0 skipped
+
+### Finding Counts
+
+| Severity | Count |
+|----------|-------|
+| Critical | 0 |
+| High | 1 |
+| Medium | 2 |
+| Low | 0 |
+| **Total** | **3** |
+
+The application demonstrates several positive patterns for sensitive data minimization, including explicit field filtering in `get_metadata()` to exclude cryptographic keys, and `get_person()` to exclude salts. However, three findings of MEDIUM+ severity were identified where the application returns more sensitive data than the minimum required for its functionality.
+
+---
+
+## Security Controls Inventory
+
+| Control | Defined Location | Description | Coverage |
+|---------|-----------------|-------------|----------|
+| **Metadata field filtering** | `election.py:get_metadata()` (L147–159) | Constructs return dict excluding `salt` and `opened_key` | Applied to single-election lookups; NOT applied to list queries |
+| **PersonDB salt exclusion** | `persondb.py:get_person()` (L34–39) | Returns only `name, email`; excludes `person.salt` | Applied to all PersonDB lookups ✓ |
+| **Issue salt exclusion** | `election.py:get_issue()` (L162–170) | Returns title/desc/type/kv; comment says "NEVER return issue.salt" | Applied to single-issue lookups ✓ |
+| **Voter eligibility check** | `pages.py:vote_on_page()` (L244–250) | Checks `q_find_issues` before showing voting page | Exists but only checks for ANY authorization, not per-issue |
+| **Mayvote authorization for docs** | `pages.py:serve_doc()` (L543–556) | Checks `q_get_mayvote` before serving documents | Applied correctly ✓ |
+| **Election ownership authz** | `pages.py` — multiple endpoints | `### check authz` comment appears 10+ times | **NOT IMPLEMENTED** — Type B gap |
+
+---
+
+## Critical File Review
+
+### `v3/steve/election.py` — Data Return Analysis
+
+| Method | Returns Sensitive Fields? | Filtering Applied? | Risk |
+|--------|--------------------------|-------------------|------|
+| `get_metadata()` | No — explicit edict | ✅ salt/opened_key excluded | Low |
+| `get_issue()` | No — explicit tuple | ✅ "NEVER return issue.salt" | Low |
+| `list_issues()` | No — explicit edict | ✅ Extracts only needed fields | Low |
+| `open_to_pid()` | Unknown — raw rows | ❌ No code-level filtering | Medium |
+| `upcoming_to_pid()` | Unknown — raw rows | ❌ No code-level filtering | Medium |
+| `owned_elections()` | Unknown — raw rows | ⚠️ Comment only, no code | Medium |
+| `get_voters_for_email()` | Yes — full PII | ⚠️ Returns name+email (CLI only) | Low (not web-exposed) |
+| `tally_issue()` | Yes — decrypted votes | ✅ Not called from web handlers | Low |
+
+### `v3/server/pages.py` — Endpoint Authorization Coverage
+
+| Endpoint | Auth Required | Ownership Check | Data Scope Appropriate? |
+|----------|--------------|-----------------|------------------------|
+| `GET /voter` | Committer | N/A (own data) | ✅ |
+| `GET /vote-on/<eid>` | Committer | Partial (any mayvote) | ⚠️ Returns all issues |
+| `GET /manage/<eid>` | Committer | ❌ None | ❌ Any committer sees all |
+| `POST /do-vote/<eid>` | Committer | ✅ (in add_vote) | ✅ |
+| `GET /do-open/<eid>` | Committer | ❌ None | ❌ Any committer can open |
+| `GET /do-close/<eid>` | Committer | ❌ None | ❌ Any committer can close |
+| `POST /do-add-issue/<eid>` | Committer | ❌ None | ❌ |
+| `POST /do-edit-issue/<eid>/<iid>` | Committer | ❌ None | ❌ |
+| `POST /do-delete-issue/<eid>/<iid>` | Committer | ❌ None | ❌ |
+| `GET /docs/<iid>/<docname>` | Any session | ✅ (mayvote check) | ✅ |
+
+---
+
+## Findings
+
+### ASVS-1426-HIGH-001
+
+**Severity:** HIGH
+**Gap Type:** Type B (Control EXISTS in concept but NOT CALLED)
+**File:** `v3/server/pages.py` — multiple management endpoints
+**Lines:** 308 (`manage_page`), 355 (`do_set_open_at_endpoint`), 361 (`do_set_close_at_endpoint`), 423 (`do_open_endpoint`), 441 (`do_close_endpoint`), 457 (`do_add_issue_endpoint`), 479 (`do_edit_issue_endpoint`), 500 (`do_delete_issue_endpoint`)
+
+**Description:** Election management endpoints require only `R.committer` authentication but perform no ownership or authorization verification. Any authenticated committer can access `/manage/<eid>` for ANY election, receiving sensitive election management data (full issue details, election state, owner identity, configuration) that exceeds the minimum required for their voter role.
+
+**Vulnerable Code:**
+```python
+@APP.get('/manage/<eid>')
+@asfquart.auth.require({R.committer}) ### need general solution
+@load_election
+@APP.use_template(TEMPLATES / 'manage.ezt')
+async def manage_page(election):
+ result = await basic_info()
+ result.title = 'Manage an Election'
+ result.eid = election.eid
+
+ ### check authz # <-- NOT IMPLEMENTED
+
+ result.election = election.get_metadata()
+ result.e_title = result.election.title
+ result.e_state = result.election.state
+ # ... returns full election metadata, all issues, state to ANY committer
+```
+
+**Related Functions Checked:**
+- `load_election` decorator (no ownership verification)
+- `do_set_open_at_endpoint` (L355)
+- `do_set_close_at_endpoint` (L361)
+- `do_open_endpoint` (L423)
+- `do_close_endpoint` (L441)
+- `do_add_issue_endpoint` (L457)
+- `do_edit_issue_endpoint` (L479)
+- `do_delete_issue_endpoint` (L500)
+
+**Data Flow:**
+`Any committer` → `GET /manage/<any-eid>` → `load_election` (no ownership check) → `get_metadata() + list_issues()` → Full election details returned to unauthorized user
+
+**Proof of Concept:**
+```http
+# Authenticated as committer "alice" who is NOT the election owner
+GET /manage/a1b2c3d4e5 HTTP/1.1
+Cookie: session=<alice_session>
+
+# Returns: full election title, state, all issue titles/descriptions,
+# open/close dates, owner PID — data alice should not see
+```
+
+**Impact:** Any committer sees the full management view of any election, exposing: election strategy/state, all issue titles and descriptions (which may be confidential pre-announcement), the election owner's identity, and advisory dates. For elections with embargoed content or sensitive board matters, this violates the minimum-data-return principle. Furthermore, the state-changing endpoints (`do-open`, `do-close`, `do-add-issue`, `do-edit-issue`, `do-delete-issue`) are similarly unprote [...]
+
+**Remediation:**
+```python
+def load_election(func):
+ @functools.wraps(func)
+ async def loader(eid):
+ try:
+ e = steve.election.Election(DB_FNAME, eid)
+ except steve.election.ElectionNotFound:
+ # ... existing 404 handling ...
+
+ # ADD: Verify the user is authorized to manage this election
+ result = await basic_info()
+ md = e.get_metadata()
+ if md.owner_pid != result.uid:
+ # Optionally check md.authz for group-based access
+ quart.abort(403)
+
+ return await func(e)
+ return loader
+
+# OR: Create separate decorators for voter vs. management access
+def load_election_for_management(func):
+ """Decorator requiring election ownership."""
+ @functools.wraps(func)
+ async def loader(eid):
+ e = steve.election.Election(DB_FNAME, eid)
+ result = await basic_info()
+ md = e.get_metadata()
+ if md.owner_pid != result.uid: # and not in authz group
+ quart.abort(403)
+ return await func(e)
+ return loader
+```
+
+---
+
+### ASVS-1426-MEDIUM-002
+
+**Severity:** MEDIUM
+**Gap Type:** Type A (Entry point with NO control for per-issue filtering)
+**File:** `v3/server/pages.py` — `vote_on_page()` function
+**Lines:** 244–270
+
+**Description:** The voting page performs a coarse-grained eligibility check (does the voter have ANY `mayvote` entries for this election?) but then returns ALL issues for the election, including issues the voter is not authorized to vote on. The `mayvote` table is designed for per-issue authorization, but the voting interface ignores this granularity.
+
+**Vulnerable Code:**
+```python
+async def vote_on_page(election):
+ # ...
+ # Check if user can vote in this election (has mayvote entries)
+ election.q_find_issues.perform(result.uid, election.eid)
+ if not election.q_find_issues.fetchall():
+ # abort 404
+ pass
+
+ # Returns ALL issues — not just the ones the voter is authorized for
+ all_issues = election.list_issues() # <-- returns every issue in election
+
+ issues_yna = [i for i in all_issues if i.vtype == 'yna']
+ issues_stv = [i for i in all_issues if i.vtype == 'stv']
+```
+
+**Related Functions Checked:**
+- `election.q_find_issues` (L244-250) — checks for ANY mayvote entry
+- `election.list_issues()` (L253) — returns all issues without filtering
+- Template rendering in `vote-on.ezt` — displays all returned issues
+
+**Data Flow:**
+`Voter with partial authorization` → `q_find_issues` (checks ANY mayvote) → `list_issues()` (returns ALL issues) → Full issue details including titles, descriptions, and STV candidates rendered to voter
+
+**Proof of Concept:**
+```http
+# Election has 10 issues; voter "bob" is authorized for 3 of them
+GET /vote-on/a1b2c3d4e5 HTTP/1.1
+Cookie: session=<bob_session>
+
+# Response includes ALL 10 issues with full titles, descriptions,
+# and STV candidate data — 7 issues bob shouldn't see
+```
+
+**Impact:** In elections where different voter groups are authorized for different issues (e.g., board members see board issues, general members see general issues), a voter authorized for even one issue sees all issues and their full descriptions. For STV elections, the complete candidate list with names is embedded in client-side JavaScript. This is more data than the minimum required for the voter's authorized scope.
+
+**Remediation:**
+```python
+async def vote_on_page(election):
+ # ...
+ # Get only the issues this voter is authorized to vote on
+ election.q_find_issues.perform(result.uid, election.eid)
+ authorized_iids = {row.iid for row in election.q_find_issues.fetchall()}
+
+ if not authorized_iids:
+ # abort 404
+ pass
+
+ # Filter issues to only those the voter is authorized for
+ all_issues = election.list_issues()
+ voter_issues = [i for i in all_issues if i.iid in authorized_iids]
+
+ issues_yna = [i for i in voter_issues if i.vtype == 'yna']
+ issues_stv = [i for i in voter_issues if i.vtype == 'stv']
+```
+
+---
+
+### ASVS-1426-MEDIUM-003
+
+**Severity:** MEDIUM
+**Gap Type:** Type B (Control EXISTS but NOT CALLED at all entry points)
+**File:** `v3/steve/election.py` — `open_to_pid()` (L410), `upcoming_to_pid()` (L432)
+**File:** `v3/server/pages.py` — `voter_page()` (L137), `admin_page()` (L275)
+
+**Description:** The `get_metadata()` method (L147–159) implements explicit field filtering to exclude cryptographic material (`salt`, `opened_key`). However, the list-query methods (`open_to_pid()`, `upcoming_to_pid()`) return raw database rows without code-level field filtering. While `owned_elections()` has a defensive comment noting this concern, the other methods lack equivalent protections. These raw results are passed through `postprocess_election()` and directly into template con [...]
+
+**Vulnerable Code:**
+```python
+# election.py — get_metadata() correctly filters fields:
+def get_metadata(self):
+ 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),
+ )
+
+# election.py — open_to_pid() does NOT filter fields:
+@classmethod
+def open_to_pid(cls, db_fname, pid):
+ db = cls.open_database(db_fname)
+ db.q_open_to_me.perform(pid)
+ return [row for row in db.q_open_to_me.fetchall()] # raw rows
+
+# Contrast with owned_elections() which at least documents the intent:
+@classmethod
+def owned_elections(cls, db_fname, pid):
+ # NOTE: contains subset of columns. We don't want to return the
+ # SALT or OPENED_KEY values. <-- comment only, no code enforcement
+ db.q_owned.perform(pid)
+ return [row for row in db.q_owned.fetchall()]
+```
+
+```python
+# pages.py — raw rows passed to templates without filtering:
+election = steve.election.Election.open_to_pid(DB_FNAME, result.uid)
+result.open_elections = [postprocess_election(e) for e in election]
+# postprocess_election() adds formatting but does NOT strip sensitive fields
+```
+
+**Related Functions Checked:**
+- `get_metadata()` (L147-159) — implements proper filtering
+- `open_to_pid()` (L410) — returns raw rows
+- `upcoming_to_pid()` (L432) — returns raw rows
+- `owned_elections()` — comment only, no code enforcement
+- `postprocess_election()` in `pages.py` — no field stripping
+
+**Data Flow:**
+`Database query` → raw row (potentially including `salt`, `opened_key`) → `postprocess_election()` (no field stripping) → template context (fields available even if not rendered)
+
+**Impact:** If any of these queries (`q_open_to_me`, `q_upcoming_to_me`, `q_owned`) return election `salt` or `opened_key` columns, this cryptographic material enters the template rendering context. While EZT templates only render explicitly referenced variables (so the data doesn't appear in HTML), the lack of code-level defense-in-depth means a future template change could inadvertently expose this material. The inconsistency between `get_metadata()`'s careful filtering and the list me [...]
+
+**Remediation:**
+```python
+@classmethod
+def _safe_election_row(cls, row):
+ """Strip sensitive fields from election query results before
+ returning to the web layer."""
+ return edict(
+ eid=row.eid,
+ title=row.title,
+ owner_pid=row.owner_pid,
+ authz=row.authz,
+ closed=row.closed,
+ open_at=row.open_at,
+ close_at=row.close_at,
+ # Include any other needed fields
+ # Explicitly EXCLUDE: salt, opened_key
+ **{k: getattr(row, k) for k in ('issue_count', 'is_opened')
+ if hasattr(row, k)},
+ )
+
+@classmethod
+def open_to_pid(cls, db_fname, pid):
+ db = cls.open_database(db_fname)
+ db.q_open_to_me.perform(pid)
+ return [cls._safe_election_row(row)
+ for row in db.q_open_to_me.fetchall()]
+```
+
+---
+
+## Positive Security Patterns
+
+1. **Explicit field filtering in `get_metadata()`** — Constructs a new edict with only permitted fields, deliberately excluding `salt` and `opened_key`. This is the correct pattern for sensitive data minimization.
+
+2. **PersonDB salt exclusion** — `get_person()` returns only `(name, email)`, preventing voter salt exposure through the web layer.
+
+3. **Encrypted votes never exposed** — No web endpoint returns encrypted vote data (`ciphertext`) or decrypted vote content. The `tally_issue()` method exists only for CLI use.
+
+4. **Vote logging avoids content** — `_LOGGER.info(f'User[U:{result.uid}] voted on issue[I:{iid}]...')` records participation but NOT the vote value (`votestring`).
+
+5. **Error messages to users are minimal** — Flash messages like `'Error submitting vote for issue {iid}.'` avoid exposing internal error details; full details go only to server logs.
+
+6. **Document serving with authorization** — `serve_doc()` checks `q_get_mayvote` before serving per-issue documents, ensuring only authorized voters can access supporting materials.
+
+---
+
+## Architecture Observations
+
+1. **Debug print statements in production code** — `print('FORM:', form)` in `do_add_issue_endpoint` (L471) and `do_edit_issue_endpoint` (L491) write all form data to stdout. While issue titles/descriptions may not be vote content, in private elections this could expose embargoed information to log aggregation systems.
+
+2. **Vote participation logging creates voter-to-issue correlations** — The log `User[U:{uid}] voted on issue[I:{iid}]` creates a durable record linking voter identity to specific issues. While it doesn't log vote content, for elections where participation itself is sensitive, this could be a concern per the domain context requiring logs "avoid recording voter-vote correlations."
+
+3. **`get_voters_for_email()` returns unmasked PII** — This method returns full names and email addresses for all election voters. While currently used only by CLI tools, its availability on the `Election` class (which is instantiated by web handlers) creates a risk surface if future web features expose it.
+
+4. **No `Cache-Control` headers on sensitive pages** — Voting pages (`/vote-on/<eid>`) and management pages don't set `Cache-Control: no-store` headers. Browser or proxy caching could retain sensitive election data beyond the session lifetime.
+
+---
+
+## Recommendations Summary
+
+### Immediate Actions (Critical/High Priority)
+
+1. **Implement ownership/authz verification on all management endpoints** — Add authorization checks to `manage_page`, `do_open_endpoint`, `do_close_endpoint`, `do_add_issue_endpoint`, `do_edit_issue_endpoint`, and `do_delete_issue_endpoint` to verify the authenticated user is the election owner or in the authorized group before exposing management data or allowing state changes. *[Addresses ASVS-1426-HIGH-001]*
+
+### Short-term Actions (Medium Priority)
+
+2. **Filter `list_issues()` results in `vote_on_page()`** — Modify the voting page to return only issues the voter is authorized for based on their `mayvote` entries, rather than exposing all election issues. *[Addresses ASVS-1426-MEDIUM-002]*
+
+3. **Add consistent field filtering to list query methods** — Implement a `_safe_election_row()` method that strips sensitive fields (`salt`, `opened_key`) and apply it to `open_to_pid()`, `upcoming_to_pid()`, and `owned_elections()` to ensure defense-in-depth consistency with `get_metadata()`. *[Addresses ASVS-1426-MEDIUM-003]*
+
+4. **Remove debug print statements** — Eliminate `print('FORM:', form)` statements from production code in `do_add_issue_endpoint` (L471) and `do_edit_issue_endpoint` (L491) to prevent form data exposure in logs.
+
+### Long-term Actions (Architectural Improvements)
+
+5. **Set Cache-Control headers on sensitive pages** — Add `Cache-Control: no-store, no-cache` response headers to all authenticated pages, particularly voting (`/vote-on/<eid>`) and management routes, to prevent browser/proxy caching of sensitive election data.
+
+6. **Review vote participation logging** — Evaluate whether logging voter-to-issue correlations (`User[U:{uid}] voted on issue[I:{iid}]`) aligns with privacy requirements for elections where participation itself is sensitive; consider aggregated logging alternatives.
+
+7. **Restrict `get_voters_for_email()` availability** — Move voter PII export functionality to a dedicated CLI-only module to prevent accidental exposure through web handlers.
+
+---
+
+## Appendix: Files Analyzed
+
+<details>
+<summary>Click to expand full file list (20 files)</summary>
+
+- `v3/schema.sql` (relevance: 10)
+- `v3/server/pages.py` (relevance: 10)
+- `v3/server/templates/about.ezt` (relevance: 10)
+- `v3/server/templates/admin.ezt` (relevance: 10)
+- `v3/server/templates/e_bad_eid.ezt` (relevance: 10)
+- `v3/server/templates/e_bad_iid.ezt` (relevance: 10)
+- `v3/server/templates/e_bad_pid.ezt` (relevance: 10)
+- `v3/server/templates/flashes.ezt` (relevance: 10)
+- `v3/server/templates/footer.ezt` (relevance: 10)
+- `v3/server/templates/header.ezt` (relevance: 10)
+- `v3/server/templates/home.ezt` (relevance: 10)
+- `v3/server/templates/manage-stv.ezt` (relevance: 10)
+- `v3/server/templates/manage.ezt` (relevance: 10)
+- `v3/server/templates/privacy.ezt` (relevance: 10)
+- `v3/server/templates/profile.ezt` (relevance: 10)
+- `v3/server/templates/settings.ezt` (relevance: 10)
+- `v3/server/templates/vote-on.ezt` (relevance: 10)
+- `v3/server/templates/voter.ezt` (relevance: 10)
+- `v3/steve/election.py` (relevance: 10)
+- `v3/steve/persondb.py` (relevance: 10)
+
+</details>
+
+---
+
+**End of Report**
\ 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