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:55:05 UTC
(tooling-agents) branch main updated: ASVS audit: 2.1.1.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 4079e7c ASVS audit: 2.1.1.md (redacted) [source: apache/steve/v3 @ d0aa7e9]
4079e7c is described below
commit 4079e7c3c340f15c0397cbb0dd540d1276e81c06
Author: ASF Tooling Team <ro...@apache.org>
AuthorDate: Tue May 5 22:54:59 2026 +0200
ASVS audit: 2.1.1.md (redacted) [source: apache/steve/v3 @ d0aa7e9]
---
ASVS/reports/steve/v3/d0aa7e9/all/2.1.1.md | 170 +++++++++++++++++++++++++++++
1 file changed, 170 insertions(+)
diff --git a/ASVS/reports/steve/v3/d0aa7e9/all/2.1.1.md b/ASVS/reports/steve/v3/d0aa7e9/all/2.1.1.md
new file mode 100644
index 0000000..f997f4f
--- /dev/null
+++ b/ASVS/reports/steve/v3/d0aa7e9/all/2.1.1.md
@@ -0,0 +1,170 @@
+# Security Audit Report: ASVS 2.1.1
+
+## Executive Summary
+
+| Field | Value |
+|-------|-------|
+| **Repository** | apache/steve/v3 |
+| **Audit Date** | May 05, 2026 |
+| **Auditor** | Tooling Agents (bundled-pass mode) |
+| **ASVS Requirement** | ASVS 2.1.1 |
+| **Files Analyzed** | 10 relevant / 49 total |
+| **Files Skipped** | 12 |
+
+**Requirement description:** Verify that the application's documentation defines input validation rules for how to check the validity of data items against an expected structure. This could be common data formats such as credit card numbers, email addresses, telephone numbers, or it could be an internal data format.
+
+### Findings Overview
+
+| Severity | Count |
+|----------|-------|
+| 🔴 Critical | 0 |
+| 🟠High | 0 |
+| 🟡 Medium | 1 |
+| 🟢 Low | 1 |
+
+---
+
+## ASVS-2.1.1: Validation and Business Logic Documentation - Input Validation Rules
+
+### Findings for 2.1.1
+
+### [MEDIUM]
+**Finding ID: ASVS-211-MED-001**
+**Title: Incomplete documentation of input validation rules for user-supplied text fields**
+
+**File:** `v3/docs/schema.md`, `v3/server/pages.py`
+**Function:** Multiple endpoints (do_create_endpoint, do_add_issue_endpoint, do_edit_issue_endpoint, do_vote_endpoint)
+
+The documentation (`schema.md`) defines structural rules for internal identifiers (eid, iid as 10-char hex, salt as 16 bytes, etc.) but fails to document validation rules for user-supplied input data:
+
+```markdown
+# Missing from schema.md or any other documentation:
+# - Election title: max length, allowed characters, format
+# - Issue title: max length, allowed characters
+# - Issue description: max length, allowed characters, format
+# - Vote string (votestring): format per vote type (yna: expected values, stv: ranking format)
+# - Person email: format validation rules (RFC 5322 compliance)
+# - Person name: max length, allowed characters
+# - Date inputs: expected format, range constraints
+# - Authorization group (authz): allowed values/format
+```
+
+**Data flow:** User form input → server endpoint → database storage → no documented validation specification
+
+**Impact:** Developers implementing or maintaining the application have no reference for what constitutes valid input. This leads to inconsistent validation (some fields validated, others not), making it difficult to verify correctness or identify gaps.
+
+**Remediation:**
+Create an `input-validation.md` document specifying:
+```markdown
+# Input Validation Rules
+
+## Election Title
+- Type: String
+- Required: Yes
+- Max length: 200 characters
+- Allowed: Unicode printable characters, no control characters
+- Validation: Non-empty after trimming whitespace
+
+## Vote String (YNA)
+- Type: String
+- Required: Yes
+- Allowed values: "yes", "no", "abstain"
+- Case-insensitive
+
+## Vote String (STV)
+- Type: String
+- Required: Yes
+- Format: Comma-separated candidate labels from issue's labelmap
+- Validation: Each label must exist in issue.kv.labelmap, no duplicates
+```
+
+---
+
+### [LOW]
+**Finding ID: ASVS-211-LOW-001**
+**Title: Vote type enumeration not documented outside of code**
+
+**File:** `v3/docs/schema.md` (lines referencing `type` column)
+
+The schema documentation mentions `yna` and `stv` as vote types but does not document the complete set of valid values, how they are validated, or their expected input/output formats:
+
+```markdown
+ - `type` (TEXT, NOT NULL): The voting mechanism. Currently supports:
+ - `yna`: Yes/No/Abstain voting.
+ - `stv`: Single Transferable Vote.
+ Additional types may be added in the future.
+```
+
+**Impact:** Low. The enumeration exists partially in documentation and is enforced in code (`vtypes.TYPES`), but the validation rules for each type's vote data are not documented.
+
+**Remediation:** Document the expected vote input format for each type and the validation rules that apply.
+
+---
+
+### Security Controls Inventory for 2.1.1
+
+| Control | Location | Coverage Status |
+|---------|----------|-----------------|
+| Schema CHECK constraints (eid, iid format) | `schema.sql` lines 62-64, 114-116 | Applied at DB layer |
+| Vote type enumeration | `steve/vtypes.py` (referenced) | Applied in `add_issue`, `edit_issue` |
+| Date format validation | `pages.py` line 98 (`fromisoformat`) | Applied in `_set_election_date` only |
+| STV kv validation | `create-election.py` line 63-69 | Applied in CLI tool only, NOT in web endpoints |
+
+### Positive Patterns for 2.1.1
+
+- **Database-level format enforcement:** `schema.sql` uses CHECK constraints with GLOB patterns to enforce ID formats (10-char hex), salt lengths (16 bytes), and key lengths (32 bytes).
+- **Schema documentation exists:** `schema.md` provides structured documentation of table columns, their types, and constraints.
+- **Sample file documents expected formats:** `election.yaml.sample` illustrates valid input structures for the CLI tool.
+
+---
+
+
+
+## Cross-cutting Architecture Observations
+
+1. **Documentation vs. Implementation Gap:** The application has solid database-level documentation (`schema.md`) describing data types and constraints, but lacks a separate input validation specification document. The database schema enforces internal ID formats but not user-input content rules.
+
+2. **Defense-in-Depth Pattern:** The architecture employs multiple layers — database CHECK constraints, foreign keys, application-level state assertions, and authentication decorators. However, the input validation layer (between user input and business logic) is largely absent.
+
+3. **Type A Gaps Dominate:** Most vulnerabilities are "entry point with no control" rather than controls that exist but aren't applied. This suggests input validation was deferred during development (evidenced by multiple TODO/`###` comments).
+
+4. **Asymmetric Validation:** The CLI tool (`create-election.py`) has more validation (STV kv fields, seat count, PID existence) than the web endpoints for equivalent operations. This creates inconsistent security posture between entry points.
+
+5. **State Machine is Well-Implemented:** The election lifecycle (editable → open → closed) is consistently enforced via assertions in `election.py`. This is a strong positive architectural pattern for business logic.
+
+6. **Cryptographic Layer is Solid:** Vote encryption, token generation, and anti-tamper detection are well-structured and correctly separate concerns from the input validation layer.
+
+7. **GET for State Changes:** Using GET requests for irreversible operations (`do-open`, `do-close`) violates REST conventions and makes CSRF prevention more difficult.
+
+## Cross-cutting Recommendations
+
+### Immediate (Critical/High Priority)
+
+1. **Implement votestring validation** in `Election.add_vote()` — this is the core function of the application and currently accepts arbitrary input. Create `validate_vote()` methods in each vtype module.
+
+2. **Convert state-changing GET endpoints to POST** (`/do-open/<eid>`, `/do-close/<eid>`) and implement CSRF token generation and validation. Replace the placeholder token.
+
+3. **Add server-side required field validation** for all form-submitted text fields (title, description) in `do_create_endpoint`, `do_add_issue_endpoint`, and `do_edit_issue_endpoint`.
+
+### Short-term (Medium Priority)
+
+4. **Add cross-field date validation** ensuring `close_at > open_at` when both are set, and consider restricting past dates.
+
+5. **Implement explicit mayvote NULL check** in `add_vote()` to provide clear error handling rather than relying on AttributeError.
+
+6. **Add length limits** on text input fields (title: 200 chars, description: 10,000 chars) both in validation code and as database CHECK constraints.
+
+7. **Create an input validation specification document** covering all user-input fields, their formats, constraints, and cross-field rules.
+
+8. **Validate `docname`** explicitly with an allowlist pattern, even though `send_from_directory` provides framework protection.
+
+### Long-term (Architectural)
+
+9. **Implement authorization (authz) checks** — currently all `### check authz` comments indicate no ownership/permission validation beyond basic authentication.
+
+10. **Create a centralized input validation module** that can be reused across endpoints, rather than inline validation in each handler.
+
+11. **Add per-user and global rate limits** for election creation, issue management, and vote submission to prevent abuse.
+
+12. **Document all business logic rules** in a dedicated specification, including state transitions, temporal constraints, limits, and cross-entity consistency rules.
+
\ 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