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:14:29 UTC
(tooling-agents) branch main updated: ASVS audit: 16.2.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 e6a0ba0 ASVS audit: 16.2.2.md (redacted)
e6a0ba0 is described below
commit e6a0ba00bb5d447eb57d0c2e8fceea4d9c7a2ce9
Author: ASF Tooling Team <ro...@apache.org>
AuthorDate: Tue May 5 14:04:56 2026 +0200
ASVS audit: 16.2.2.md (redacted)
---
ASVS/reports/steve/v3/d0aa7e9/all/16.2.2.md | 195 ++++++++++++++++++++++++++++
1 file changed, 195 insertions(+)
diff --git a/ASVS/reports/steve/v3/d0aa7e9/all/16.2.2.md b/ASVS/reports/steve/v3/d0aa7e9/all/16.2.2.md
new file mode 100644
index 0000000..627bee5
--- /dev/null
+++ b/ASVS/reports/steve/v3/d0aa7e9/all/16.2.2.md
@@ -0,0 +1,195 @@
+# Security Audit Report: ASVS 16.2.2
+
+## Executive Summary
+
+| Field | Value |
+|-------|-------|
+| **Repository** | apache/steve/v3 |
+| **Audit Date** | May 05, 2026 |
+| **Auditor** | Tooling Agents (bundled-pass mode) |
+| **ASVS Requirement** | ASVS 16.2.2 |
+| **Files Analyzed** | 5 relevant / 49 total |
+| **Files Skipped** | 12 |
+
+**Requirement description:** Verify that time sources for all logging components are synchronized, and that timestamps in security event metadata use UTC or include an explicit time zone offset. UTC is recommended to ensure consistency across distributed systems and to prevent confusion during daylight saving time transitions.
+
+### Findings Overview
+
+| Severity | Count |
+|----------|-------|
+| 🔴 Critical | 0 |
+| 🟠High | 1 |
+| 🟡 Medium | 1 |
+| 🟢 Low | 1 |
+
+---
+
+## ASVS-16.2.2: General Logging - Time Synchronization
+
+### Findings for 16.2.2
+
+### [HIGH]
+
+**Finding ID:** ASVS-1622-HIGH-001
+
+**Title:** Log Timestamp Format Lacks Year, Seconds, and Timezone Information
+
+**File:** `v3/server/main.py`, line 18
+
+**Vulnerable Code:**
+```python
+DATE_FORMAT = '%m/%d %H:%M'
+```
+
+Used in both `run_standalone()` (line 55) and `run_asgi()` (line 82):
+```python
+logging.basicConfig(
+ level=logging.DEBUG,
+ style='{',
+ format='[{asctime}|{levelname}|{name}] {message}',
+ datefmt=DATE_FORMAT,
+)
+```
+
+**Impact:**
+
+The log timestamp format `%m/%d %H:%M` produces output like `01/15 14:30` which:
+1. **No year** — Cannot determine which year an event occurred (critical for long-running systems or historical analysis)
+2. **No seconds** — Cannot sequence events that happen within the same minute (elections/votes could occur in rapid succession)
+3. **No timezone** — Cannot determine if timestamps are UTC or local time. During daylight saving transitions, events could appear out of order or ambiguous
+4. **No sub-second precision** — Cannot correlate with external systems that log at millisecond granularity
+
+This directly violates the requirement that "timestamps in security event metadata use UTC or include an explicit time zone offset."
+
+**Remediation:**
+
+```python
+# Use ISO 8601 format with UTC timezone
+DATE_FORMAT = '%Y-%m-%dT%H:%M:%S%z'
+
+# Or better, force UTC:
+import time
+logging.Formatter.converter = time.gmtime # Force UTC timestamps
+
+DATE_FORMAT = '%Y-%m-%dT%H:%M:%SZ' # Z suffix indicates UTC
+```
+
+---
+
+### [MEDIUM]
+
+**Finding ID:** ASVS-1622-MED-001
+
+**Title:** No Time Source Synchronization Configuration
+
+**File:** `v3/server/main.py` (entire file)
+
+**Evidence:** There is no configuration or documentation ensuring that the server's time source is synchronized (e.g., NTP). The application relies on the system clock without validation.
+
+Additionally, `v3/server/pages.py` line 591:
+```python
+delta = dt.timestamp() - datetime.datetime.now().timestamp()
+```
+
+Uses `datetime.datetime.now()` (local time, timezone-naive) rather than `datetime.datetime.now(datetime.timezone.utc)` or `datetime.datetime.utcnow()`.
+
+**Impact:** In a distributed deployment, unsynchronized clocks between application servers would make log correlation impossible. The use of timezone-naive `now()` means log timestamps and application logic may disagree on the current time.
+
+**Remediation:**
+```python
+import datetime
+
+# Always use timezone-aware UTC
+now = datetime.datetime.now(datetime.timezone.utc)
+
+# Document NTP requirement in deployment docs
+# Verify time sync at startup:
+import subprocess
+def verify_time_sync():
+ """Log warning if NTP is not synchronized."""
+ try:
+ result = subprocess.run(['timedatectl', 'show', '--property=NTPSynchronized'],
+ capture_output=True, text=True)
+ if 'NTPSynchronized=yes' not in result.stdout:
+ _LOGGER.warning('System clock is NOT synchronized via NTP')
+ except Exception:
+ _LOGGER.warning('Unable to verify NTP synchronization')
+```
+
+---
+
+### [LOW]
+
+**Finding ID:** ASVS-1622-LOW-001
+
+**Title:** Mail Script Uses Default Timestamp Format
+
+**File:** `v3/server/bin/mail-voters.py`, line 85
+
+**Vulnerable Code:**
+```python
+logging.basicConfig(level=logging.INFO)
+```
+
+**Impact:** The mail script uses Python's default log format which includes a date but in local time with no timezone offset. This is inconsistent with the main application's format and doesn't use UTC.
+
+**Remediation:** Use the same UTC-aware format as the main application.
+
+### Security Controls Inventory for 16.2.2
+
+| Control | Location | Status |
+|---------|----------|--------|
+| UTC timestamp in logs | Not present | **MISSING** |
+| Timezone offset in logs | Not present | **MISSING** |
+| Year in timestamp | Not present (`%m/%d`) | **MISSING** |
+| Second-level precision | Not present (`%H:%M`) | **MISSING** |
+| NTP synchronization check | Not present | **MISSING** |
+| Consistent format across components | Inconsistent (main vs mail-voters) | **FAILING** |
+
+### Positive Patterns for 16.2.2
+
+- A centralized `DATE_FORMAT` constant exists, making it easy to fix in one place
+- The SQL queries use `unixepoch('now')` for database timestamps, which is UTC-based and consistent
+
+---
+
+
+
+## Cross-cutting Architecture Observations
+
+1. **Logging Architecture Maturity**: The application has basic logging in place with consistent patterns (module loggers, action logging), but lacks the maturity markers expected for ASVS Level 2/3: no documentation, no structured format, no correlation IDs, and insufficient timestamp precision.
+
+2. **Async/Sync Impedance Mismatch**: The application uses Quart (async) but all database operations via `asfpy.db`/`sqlite3` are synchronous. This creates a fundamental architectural issue affecting both concurrency fairness (15.4.4) and potentially logging reliability (if the event loop is blocked, log writes may also be delayed).
+
+3. **Centralized Logging Configuration with Gaps**: While `main.py` centralizes logging configuration, the `print()` statements in `pages.py` and the separate `basicConfig()` in `mail-voters.py` create inconsistencies that undermine all logging requirements simultaneously.
+
+4. **Security Event Coverage**: The application logs the right categories of events (CRUD operations, state changes, access decisions) but the metadata quality (missing source IP, missing correlation ID, imprecise timestamps) significantly reduces the investigative value of these logs.
+
+5. **No Separation of Security vs. Operational Logs**: All logs go to the same destination with the same format. There's no differentiation between security-relevant events (votes, election state changes, access denials) and operational events (loading elections, rendering templates).
+
+## Cross-cutting Recommendations
+
+### Immediate (Sprint 1)
+
+1. **Fix timestamp format** — Change `DATE_FORMAT` to `'%Y-%m-%dT%H:%M:%S%z'` and set `logging.Formatter.converter = time.gmtime` for UTC. Single-line fix with highest impact on 16.2.2.
+
+2. **Remove `print()` statements** — Replace the two `print('FORM:', form)` calls in `pages.py` with `_LOGGER.debug()` or remove entirely. Fixes 16.2.3 compliance.
+
+3. **Add source IP to log messages** — Include `quart.request.remote_addr` in security-relevant log entries. Improves 16.2.1 metadata.
+
+### Short-term (1-2 Sprints)
+
+4. **Implement request correlation IDs** — Add a `before_request` hook that generates and propagates a request ID through all log entries. Addresses 16.2.4 correlation.
+
+5. **Create logging inventory document** — Document all event types, destinations, formats, access controls, and retention. Addresses 16.1.1 entirely.
+
+6. **Adopt structured logging format** — Migrate to JSON logging format (e.g., `python-json-logger`) for machine parseability. Addresses 16.2.4.
+
+### Long-term (Next Quarter)
+
+7. **Implement async database layer** — Use `aiosqlite` or wrap synchronous calls in `asyncio.to_thread()` with a bounded thread pool to prevent event loop starvation. Addresses 15.4.4.
+
+8. **Add request timeout middleware** — Configure Hypercorn's `keep_alive_timeout` and add application-level timeouts for database operations. Further addresses 15.4.4.
+
+9. **Implement log access controls** — Define and enforce who can access logs, implement log rotation with retention policies, and consider separating security logs from operational logs. Addresses 16.1.1 comprehensively.
+
\ 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