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:14 UTC

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

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

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

diff --git a/ASVS/reports/steve/v3/d0aa7e9/all/1.5.2.md b/ASVS/reports/steve/v3/d0aa7e9/all/1.5.2.md
new file mode 100644
index 0000000..1420f4d
--- /dev/null
+++ b/ASVS/reports/steve/v3/d0aa7e9/all/1.5.2.md
@@ -0,0 +1,130 @@
+# Security Audit Report: ASVS 1.5.2
+
+## Executive Summary
+
+| Field | Value |
+|-------|-------|
+| **Repository** | apache/steve/v3 |
+| **Audit Date** | May 05, 2026 |
+| **Auditor** | Tooling Agents (bundled-pass mode) |
+| **ASVS Requirement** | ASVS 1.5.2 |
+| **Files Analyzed** | 4 relevant / 49 total |
+| **Files Skipped** | 12 |
+
+**Requirement description:** Verify that deserialization of untrusted data enforces safe input handling, such as using an allowlist of object types or restricting client-defined object types, to prevent deserialization attacks. Deserialization mechanisms that are explicitly defined as insecure must not be used with untrusted…
+
+### Findings Overview
+
+| Severity | Count |
+|----------|-------|
+| πŸ”΄ Critical | 0 |
+| 🟠 High | 0 |
+| 🟑 Medium | 0 |
+| 🟒 Low | 1 |
+
+---
+
+## ASVS-1.5.2: Safe Deserialization
+
+### Findings for 1.5.2
+
+### [LOW]
+
+**Finding ID**: ASVS-152-LOW-001
+
+**Title**: Deserialized JSON `kv` data lacks schema validation before use in vote tallying
+
+**File**: `v3/steve/election.py`, function `tally_issue`, line ~292 and `json2kv` at line 368
+
+**Vulnerable code**:
+```python
+# v3/steve/election.py:292-293
+m = vtypes.vtype_module(issue.type)
+return m.tally(votes, self.json2kv(issue.kv)), voters
+
+# v3/steve/election.py:368
+@staticmethod
+def json2kv(j):
+    "Convert the KV JSON string back into its structured value."
+    return j and json.loads(j)
+```
+
+**Data flow**: Database `issue.kv` column (TEXT) β†’ `json.loads()` β†’ passed directly to `vtypes` module `tally()` function without structural validation.
+
+**Analysis**: While `json.loads()` is inherently safe from code execution (only produces basic Python types: dict, list, str, int, float, bool, None), the deserialized structure is passed to vote-type-specific modules without validation against an expected schema. If the `kv` data were corrupted or maliciously set (e.g., via an authorization bypass β€” the code inventory notes multiple `### check authz` placeholders are unimplemented), unexpected data structures could cause logic errors in [...]
+
+**Mitigating factors**:
+- Data originates from authorized election administrators (write path is `add_issue`/`edit_issue` which assert `is_editable()`)
+- `json.loads()` cannot instantiate arbitrary objects
+- `issue.type` is validated against `vtypes.TYPES` at creation time
+- Risk is LOW because exploitation requires bypassing multiple controls
+
+**Impact**: Potential logic errors in vote tallying if `kv` structure is unexpected.
+
+**Remediation**:
+```python
+@staticmethod
+def json2kv(j):
+    "Convert the KV JSON string back into its structured value."
+    if not j:
+        return None
+    parsed = json.loads(j)
+    # Validate that parsed result is a dict (expected schema)
+    if not isinstance(parsed, dict):
+        raise ValueError(f"Expected dict for kv, got {type(parsed).__name__}")
+    return parsed
+```
+
+Additionally, each `vtypes` module should validate the `kv` structure it receives in its `tally()` function.
+
+### Security Controls Inventory for 1.5.2
+
+| Control | Location | Status |
+|---------|----------|--------|
+| `json.loads()` (safe deserializer) | `v3/steve/election.py:368` | βœ… Used correctly |
+| No `pickle`, `yaml.unsafe_load`, `marshal` usage | All files | βœ… Absent |
+| Vote type validation | `v3/steve/election.py:169,186` | βœ… `assert vtype in vtypes.TYPES` |
+| State assertion before writes | `v3/steve/election.py:169` | βœ… `assert self.is_editable()` |
+| Schema-level type enforcement | `v3/schema.sql` (STRICT mode) | βœ… Prevents type confusion at DB level |
+
+### Positive Patterns for 1.5.2
+
+1. **Safe deserialization choice**: The application exclusively uses `json.loads()` which cannot instantiate arbitrary object types β€” only basic Python primitives are produced.
+2. **No insecure deserialization**: No use of `pickle.loads()`, `yaml.load()` (without SafeLoader), `marshal.loads()`, or `eval()` on user data.
+3. **Write-path validation**: The `vtype` field is validated against `vtypes.TYPES` before being stored, preventing arbitrary module loading during tallying.
+4. **Database as trust boundary**: The `kv` JSON is stored and retrieved from the application's own SQLite database, not directly from user input during deserialization.
+
+---
+
+
+
+## Cross-cutting Architecture Observations
+
+1. **Language-Level Safety**: The choice of Python as the implementation language inherently satisfies ASVS 1.4.x requirements (memory safety, integer overflow prevention, automatic resource management). These requirements are primarily relevant for applications written in C, C++, or other systems languages with manual memory management.
+
+2. **Cryptographic Library Trust**: The application delegates all cryptographic operations to well-maintained libraries (`cryptography`, `argon2-cffi`, `hashlib`). These libraries handle their own internal memory safety for their C/Rust backends.
+
+3. **Data Serialization Strategy**: The exclusive use of JSON for structured data interchange is a sound architectural decision that avoids both XXE (no XML) and unsafe deserialization (no pickle/YAML) attack surfaces.
+
+4. **Consistent Single-Parser Approach**: The codebase maintains consistency by using a single parser for each data format, preventing parser differential attacks.
+
+5. **State Machine Enforcement**: The election lifecycle (Editable β†’ Open β†’ Closed) is enforced through assertions and metadata checks, providing defense-in-depth against operations performed in inappropriate states.
+
+## Cross-cutting Recommendations
+
+### Immediate (No issues requiring immediate action for these requirements)
+
+None. The audited requirements (1.4.1–1.4.3, 1.5.1–1.5.3) are well-satisfied by the current architecture.
+
+### Short-term
+
+1. **Add schema validation for `kv` JSON** (ASVS 1.5.2): Implement per-vtype JSON schema validation in `json2kv()` or at the `vtypes` module level to ensure deserialized data conforms to expected structure before use in tallying logic.
+
+2. **Document language safety rationale**: Add a security design document noting that Python was chosen in part for its memory safety properties, satisfying ASVS 1.4.x requirements. This aids future auditors and prevents introduction of unsafe native code without review.
+
+### Long-term
+
+3. **Dependency security monitoring**: While the current cryptographic libraries are safe, establish automated monitoring (e.g., `pip-audit`, Dependabot) for vulnerabilities in `cryptography`, `argon2-cffi`, and other dependencies that contain native code β€” these are the only paths through which memory safety issues could be introduced.
+
+4. **Consider typed data classes**: Replace `EasyDict` usage with Python `dataclass` or `TypedDict` types for deserialized data, providing compile-time type safety and documentation of expected data structures.
+        
\ 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