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 13:37:49 UTC

(tooling-agents) branch main updated: ASVS L3 audit: 6.3.5 (ch06_general)

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 aedcd8c  ASVS L3 audit: 6.3.5 (ch06_general)
aedcd8c is described below

commit aedcd8c1e9dcadeeb15c1277ff9d6907bc652db5
Author: ASF Tooling Team <ro...@apache.org>
AuthorDate: Wed Apr 22 15:37:44 2026 +0200

    ASVS L3 audit: 6.3.5 (ch06_general)
---
 .../reports/steve/v3/d0aa7e9/ch06_general/6.3.5.md | 484 +++++++++++++++++++++
 1 file changed, 484 insertions(+)

diff --git a/repos/apache/ASVS/reports/steve/v3/d0aa7e9/ch06_general/6.3.5.md b/repos/apache/ASVS/reports/steve/v3/d0aa7e9/ch06_general/6.3.5.md
new file mode 100644
index 0000000..d70326a
--- /dev/null
+++ b/repos/apache/ASVS/reports/steve/v3/d0aa7e9/ch06_general/6.3.5.md
@@ -0,0 +1,484 @@
+# ASVS 6.3.5 Security Audit Report
+
+**Suspicious Authentication Notification Analysis**
+
+---
+
+## Executive Summary
+
+| Attribute | Value |
+|-----------|-------|
+| **Repository** | apache/steve |
+| **Audit Date** | Apr 22, 2026 |
+| **Auditor** | Tooling Agents |
+| **ASVS Requirement** | 6.3.5 — Verify that users are notified of suspicious authentication attempts (successful or unsuccessful). This may include authentication attempts from an unusual location or client, partially successful authentication (only one of multiple factors), an authentication attempt after a long period of inactivity or a successful authentication after several unsuccessful attempts. |
+| **ASVS Level** | 3 |
+| **Section** | General Authentication Security |
+| **Files Analyzed** | 4 relevant out of 49 total, 12 skipped |
+
+### Finding Summary
+
+| Severity | Count | Status |
+|----------|-------|--------|
+| 🔴 Critical | 0 | - |
+| 🟠 High | 2 | Require immediate attention |
+| 🟡 Medium | 1 | Should be addressed |
+| 🔵 Low | 0 | - |
+| **Total** | **3** | **Control entirely absent** |
+
+### Key Findings
+
+**ASVS 6.3.5 Control Status: ❌ NOT IMPLEMENTED (0% Coverage)**
+
+This audit reveals a **complete absence** of suspicious authentication notification capabilities. The application lacks:
+- Authentication event tracking and storage infrastructure
+- Suspicious pattern detection logic
+- User notification mechanisms for security events
+- Authentication history visibility for users
+
+For an ASVS Level 3 voting system, this represents a critical gap in security controls that could allow undetected credential compromise and unauthorized voting activity.
+
+---
+
+## Security Controls Inventory
+
+| Control | Defined? | Location | Applied? | Coverage |
+|---------|----------|----------|----------|----------|
+| Authentication event logging | ❌ No | N/A | N/A | 0% - No auth events recorded |
+| Failed login attempt tracking | ❌ No | N/A | N/A | 0% - No tracking mechanism |
+| Suspicious login detection | ❌ No | N/A | N/A | 0% - No detection logic |
+| User notification on suspicious auth | ❌ No | N/A | N/A | 0% - No notification system |
+| Login history/audit table | ❌ No | `schema.sql` | N/A | 0% - No schema support |
+| Session metadata capture (IP, UA) | ❌ No | `pages.py:basic_info()` | N/A | 0% - Only uid/name/email stored |
+| Inactivity-based alerting | ❌ No | N/A | N/A | 0% - No last-login tracking |
+
+---
+
+## Critical File Review
+
+### `v3/server/pages.py` — Authentication Event Handling
+
+| Entry Point | Auth Required? | Auth Event Logged? | Suspicion Checked? | User Notified? |
+|-------------|---------------|-------------------|-------------------|----------------|
+| `GET /voter` | ✅ `R.committer` | ❌ | ❌ | ❌ |
+| `GET /vote-on/<eid>` | ✅ `R.committer` | ❌ | ❌ | ❌ |
+| `POST /do-vote/<eid>` | ✅ `R.committer` | ❌ | ❌ | ❌ |
+| `GET /admin` | ✅ `R.committer` | ❌ | ❌ | ❌ |
+| `GET /manage/<eid>` | ✅ `R.committer` | ❌ | ❌ | ❌ |
+| `POST /do-create-election` | ✅ `R.pmc_member` | ❌ | ❌ | ❌ |
+| `GET /do-open/<eid>` | ✅ `R.committer` | ❌ | ❌ | ❌ |
+| `GET /do-close/<eid>` | ✅ `R.committer` | ❌ | ❌ | ❌ |
+| `GET /profile` | ✅ bare auth | ❌ | ❌ | ❌ |
+| `GET /settings` | ✅ bare auth | ❌ | ❌ | ❌ |
+| `GET /docs/<iid>/<docname>` | ✅ bare auth | ❌ | ❌ | ❌ |
+
+**Coverage: 0/11 authenticated endpoints have any authentication event analysis or notification.**
+
+### `v3/schema.sql` — Authentication Data Storage
+
+| Required Data | Table Exists? | Column Exists? |
+|--------------|--------------|----------------|
+| Login timestamps | ❌ | ❌ |
+| Source IP addresses | ❌ | ❌ |
+| User agent strings | ❌ | ❌ |
+| Geographic hints | ❌ | ❌ |
+| Failed attempt counter | ❌ | ❌ |
+| Security alert queue | ❌ | ❌ |
+| Last successful login | ❌ (`person` table has no such field) | ❌ |
+
+---
+
+## Findings
+
+### 🟠 HIGH Severity Findings
+
+#### Finding ASVS-635-SEV-001: Complete Absence of Authentication Event Tracking and Storage
+
+| Attribute | Detail |
+|-----------|--------|
+| **Severity** | **HIGH** |
+| **Finding ID** | ASVS-635-SEV-001 |
+| **File** | `v3/schema.sql` (entire file), `v3/docs/schema.md` |
+| **Location** | Database schema definition |
+| **Gap Type** | Type A — Entry point with NO control |
+| **CWE** | CWE-778: Insufficient Logging |
+
+**Description:**
+
+The database schema defines five tables (`election`, `issue`, `person`, `mayvote`, `vote`) — none of which track authentication events. There is no table for storing login attempts, login timestamps, source IP addresses, user agents, geolocation data, or authentication outcomes (success/failure). Without persistent storage of authentication events, it is structurally impossible to detect suspicious patterns or notify users.
+
+**Evidence from schema.sql:**
+
+```sql
+-- The complete set of tables:
+CREATE TABLE election ( ... ) STRICT;
+CREATE TABLE issue ( ... ) STRICT;
+CREATE TABLE person (
+    pid  TEXT PRIMARY KEY NOT NULL,
+    name  TEXT,
+    email  TEXT NOT NULL
+) STRICT;
+CREATE TABLE mayvote ( ... ) STRICT;
+CREATE TABLE vote ( ... ) STRICT;
+-- No authentication_event, login_history, or security_alert table exists
+```
+
+The `person` table stores only `pid`, `name`, and `email` — no `last_login`, `last_login_ip`, `failed_login_count`, or similar fields.
+
+**Data Flow Analysis:**
+
+- **Source:** Authentication events occur via `asfquart.auth` framework
+- **Processing:** No capture or storage mechanism exists
+- **Sink:** Events are lost — no persistence layer
+- **Missing Controls:** Event logging, audit trail, forensic capability
+
+**Impact:**
+
+- Users are never informed when someone authenticates as them from an unusual location or device
+- Credential compromise goes undetected — an attacker who obtains valid credentials can authenticate and cast votes without the legitimate user being alerted
+- For a voting system at ASVS L3, this is particularly concerning as undetected account compromise directly undermines election integrity
+- No forensic capability to investigate suspicious voting patterns or disputed authentication events
+- Violates ASVS 6.3.5 requirement for notification of suspicious authentication attempts
+
+**Remediation:**
+
+Add an authentication audit table and last-login tracking:
+
+```sql
+CREATE TABLE auth_event (
+    event_id   INTEGER PRIMARY KEY AUTOINCREMENT,
+    pid        TEXT NOT NULL,
+    event_type TEXT NOT NULL CHECK (event_type IN ('login_success', 'login_failure', 'mfa_partial', 'logout')),
+    ip_address TEXT,
+    user_agent TEXT,
+    geo_hint   TEXT,
+    created_at INTEGER NOT NULL,  -- seconds since epoch
+    notified   INTEGER DEFAULT 0 CHECK (notified IN (0, 1)),
+    FOREIGN KEY (pid) REFERENCES person(pid) ON DELETE RESTRICT
+) STRICT;
+
+CREATE INDEX idx_auth_event_pid ON auth_event(pid);
+CREATE INDEX idx_auth_event_created ON auth_event(created_at);
+
+-- Add last_login tracking to person table
+ALTER TABLE person ADD COLUMN last_login_at INTEGER;
+ALTER TABLE person ADD COLUMN last_login_ip TEXT;
+```
+
+---
+
+#### Finding ASVS-635-SEV-002: No Suspicious Authentication Detection Logic in Session Handling
+
+| Attribute | Detail |
+|-----------|--------|
+| **Severity** | **HIGH** |
+| **Finding ID** | ASVS-635-SEV-002 |
+| **File** | `v3/server/pages.py` |
+| **Function** | `basic_info()` |
+| **Lines** | 57–86 |
+| **Gap Type** | Type A — Entry point with NO control |
+| **CWE** | CWE-223: Omission of Security-relevant Information |
+
+**Description:**
+
+The `basic_info()` function is the central session-reading function called by every authenticated endpoint. It reads `uid`, `fullname`, and `email` from the session but performs no analysis of authentication context. It does not capture or evaluate the client's IP address, user agent, geolocation, time since last authentication, or prior failed attempts.
+
+**Vulnerable Code (`pages.py` lines 57–86):**
+
+```python
+async def basic_info():
+    """Return base-level EZT template data."""
+    basic = edict()
+    basic.flashes = [
+        edict(message=f[1], category=f[0])
+        for f in quart.get_flashed_messages(with_categories=True)
+    ]
+    s = await asfquart.session.read()
+    if s:
+        basic.update(
+            uid=s['uid'],
+            name=s['fullname'],
+            email=s['email'],
+        )
+    else:
+        basic.update(uid=None, name=None, email=None)
+    ### generate a real token and store in the session
+    basic.csrf_token = 'placeholder'
+    return basic
+```
+
+**Related Functions Checked:**
+
+- `voter_page()` (lines 136–169) — calls `basic_info()`, no suspicion checks
+- `vote_on_page()` (lines 171–264) — calls `basic_info()`, no suspicion checks
+- `admin_page()` (lines 391–398) — calls `basic_info()`, no suspicion checks
+- `profile_page()` (lines 570–576) — calls `basic_info()`, no suspicion checks
+
+Additionally, authentication is delegated entirely to `asfquart.auth.require` decorators (used on ~20 endpoints), but no post-authentication hook exists to evaluate the authentication event:
+
+```python
+@APP.get('/voter')
+@asfquart.auth.require({R.committer})  # Auth happens here — no event analysis
+@APP.use_template(TEMPLATES / 'voter.ezt')
+async def voter_page():
+    result = await basic_info()  # Session read — no suspicious check
+    ...
+```
+
+**Data Flow:**
+
+- **Source:** `asfquart.session.read()` returns session data
+- **Processing:** Only `uid`, `fullname`, `email` extracted
+- **Missing:** No extraction of `request.remote_addr`, `request.headers.get('User-Agent')`, no comparison against prior login context, no suspicious pattern evaluation
+- **Sink:** Session data passed to templates with zero security analysis
+
+**Proof of Concept:**
+
+An attacker who compromises credentials can:
+
+1. Authenticate from a completely different country/IP range
+2. Use a different browser/device than the legitimate user has ever used
+3. Authenticate after the account has been dormant for months
+4. Successfully authenticate after dozens of failed attempts
+
+In all cases, the legitimate user receives no notification, and the system performs no additional verification.
+
+**Impact:**
+
+- Authentication from a completely new geographic region goes unnoticed
+- A successful login after dozens of failed attempts triggers no alert
+- Login after months of account inactivity appears identical to regular use
+- An attacker who compromises credentials faces no detection barriers
+- Violates ASVS 6.3.5 requirements for notification of unusual location, long inactivity, and success after failures
+
+**Remediation:**
+
+Implement a post-authentication hook that captures context and evaluates suspicion:
+
+```python
+async def check_auth_suspicion(session_data):
+    """Evaluate authentication event for suspicious patterns."""
+    pid = session_data['uid']
+    current_ip = quart.request.remote_addr
+    current_ua = quart.request.headers.get('User-Agent', '')
+    now = int(datetime.datetime.now().timestamp())
+    
+    db = steve.election.Election.open_database(DB_FNAME)
+    
+    # Check 1: Unusual IP/location
+    last_event = db.q_last_auth_event.first_row(pid)
+    if last_event and last_event.ip_address != current_ip:
+        await notify_user_suspicious_login(pid, 'new_location', current_ip)
+    
+    # Check 2: Login after long inactivity
+    if last_event and (now - last_event.created_at) > INACTIVITY_THRESHOLD:
+        await notify_user_suspicious_login(pid, 'long_inactivity', 
+                                            days=(now - last_event.created_at) // 86400)
+    
+    # Check 3: Success after failures
+    recent_failures = db.q_recent_failures.first_row(pid, now - 3600)
+    if recent_failures and recent_failures.count >= FAILURE_THRESHOLD:
+        await notify_user_suspicious_login(pid, 'success_after_failures',
+                                            failure_count=recent_failures.count)
+    
+    # Record this authentication event
+    db.c_record_auth_event.perform(pid, 'login_success', current_ip, current_ua, now)
+```
+
+---
+
+### 🟡 MEDIUM Severity Findings
+
+#### Finding ASVS-635-SEV-003: No User-Facing Notification Mechanism for Security Events
+
+| Attribute | Detail |
+|-----------|--------|
+| **Severity** | **MEDIUM** |
+| **Finding ID** | ASVS-635-SEV-003 |
+| **File** | `v3/server/pages.py` |
+| **Functions** | `profile_page()` (lines 570–576), `voter_page()` (lines 136–169) |
+| **Gap Type** | Type A — Entry point with NO control |
+| **CWE** | CWE-356: Product UI does not Warn User of Unsafe Actions |
+
+**Description:**
+
+Even if authentication events were tracked (Finding 1) and analyzed (Finding 2), there is no delivery mechanism to notify users. The application has:
+
+- **No email notification system** for security events (the `person.email` field exists but is described in schema.md as being for "sending ballot links," not security alerts)
+- **No in-app security alert display** — the flash message system (`flash_success`, `flash_danger`, etc.) is only used for operational feedback (e.g., "Votes submitted successfully!"), never for security notifications
+- **No security event display on profile/dashboard pages** — `profile_page()` and `voter_page()` render no authentication history or alerts
+
+**Evidence — `profile_page` (lines 570–576):**
+
+```python
+@APP.get('/profile')
+@asfquart.auth.require
+@APP.use_template(TEMPLATES / 'profile.ezt')
+async def profile_page():
+    result = await basic_info()
+    result.title = 'Profile'
+    return result
+    # No authentication history, no security alerts, no last-login display
+```
+
+**Evidence — `voter_page` (lines 136–169):**
+
+```python
+@APP.get('/voter')
+@asfquart.auth.require({R.committer})
+@APP.use_template(TEMPLATES / 'voter.ezt')
+async def voter_page():
+    result = await basic_info()
+    result.title = 'Voting'
+    # ... election listing only ...
+    # No security notifications displayed on the primary authenticated landing page
+    return result
+```
+
+**Related Functions Checked:**
+
+- `flash_success()`, `flash_info()`, `flash_warning()`, `flash_danger()` — all used only for operational messages
+- Email sending capability — not implemented for security notifications
+
+**Data Flow:**
+
+- **Source:** Hypothetical security events (currently not captured)
+- **Processing:** No notification generation logic exists
+- **Sink:** No delivery channel — neither email nor in-app display
+- **Missing Controls:** Notification service, alert display UI, email templating for security events
+
+**Impact:**
+
+- Even if suspicious activity were somehow detected externally, users have no channel through which to receive alerts within the application
+- Users cannot review their own authentication history to identify compromise
+- For a voting system, users should be able to verify that only they have accessed their voting sessions
+- Violates ASVS 6.3.5 explicit requirement to "notify users of suspicious authentication attempts"
+- Users cannot take protective action (password change, session revocation) in response to suspicious activity
+
+**Remediation:**
+
+Add security notification display to authenticated pages:
+
+```python
+@APP.get('/profile')
+@asfquart.auth.require
+@APP.use_template(TEMPLATES / 'profile.ezt')
+async def profile_page():
+    result = await basic_info()
+    result.title = 'Profile'
+    
+    # Display authentication history
+    db = steve.election.Election.open_database(DB_FNAME)
+    db.q_recent_auth_events.perform(result.uid, limit=10)
+    result.auth_history = [row for row in db.q_recent_auth_events.fetchall()]
+    
+    # Display pending security alerts
+    db.q_unread_security_alerts.perform(result.uid)
+    result.security_alerts = [row for row in db.q_unread_security_alerts.fetchall()]
+    
+    return result
+
+
+async def notify_user_suspicious_login(pid, reason, **context):
+    """Notify user of suspicious authentication via email and in-app alert."""
+    pdb = steve.persondb.PersonDB.open(DB_FNAME)
+    person = pdb.get_person(pid)
+    email = person[1]  # email field
+    
+    _LOGGER.warning(f'Suspicious auth for User[U:{pid}]: reason={reason}, context={context}')
+    
+    # Send email notification
+    await send_security_email(email, reason, context)
+    
+    # Store in-app notification for next login
+    db = steve.election.Election.open_database(DB_FNAME)
+    db.c_add_security_alert.perform(pid, reason, json.dumps(context), 
+                                     int(datetime.datetime.now().timestamp()))
+```
+
+Additionally, implement an email notification service for critical authentication events (unusual location, success after failures).
+
+---
+
+## Positive Security Patterns
+
+Despite the absence of suspicious authentication notification controls, the application demonstrates several strong security practices:
+
+1. **Strong authentication decorators**: All sensitive endpoints use `@asfquart.auth.require` with appropriate role levels (`R.committer`, `R.pmc_member`), ensuring authentication is consistently enforced across the application surface.
+
+2. **Comprehensive operational logging**: Security-relevant actions (election create/open/close, voting, issue management) are logged with user identity using the format `f'User[U:{result.uid}] <action>'`. While these are operational rather than authentication logs, they demonstrate awareness of audit trail importance.
+
+3. **Session-based identity**: User identity is consistently derived from `asfquart.session.read()` rather than client-supplied values, preventing identity injection attacks.
+
+4. **Non-predictable election/issue IDs**: 10-character hex IDs prevent enumeration attacks that could combine with authentication weaknesses to enable unauthorized access.
+
+5. **Consistent authentication enforcement**: No authenticated endpoints bypass the authentication decorator pattern, eliminating common authentication bypass vulnerabilities.
+
+---
+
+## Architecture Observations
+
+### Authentication Delegation Pattern
+
+1. **Authentication is fully delegated**: The application relies entirely on `asfquart.auth` for authentication. The `asfquart` module is not provided for review, so it's unknown whether it implements any suspicious login detection internally. However, the **application layer** has zero integration with any such capability, which means even if the auth framework tracked events, the application would not surface notifications to users.
+
+2. **No authentication middleware pattern**: There is no middleware or post-authentication hook in the request pipeline. The `basic_info()` function serves as the closest equivalent but only reads session identity — it does not evaluate authentication context.
+
+### Database Design Considerations
+
+3. **Schema is authentication-event-blind**: The database schema was designed exclusively for election operations. Adding authentication event tracking would require schema migration (new tables) and is not a minor patch. This architectural decision reflects the application's operational focus rather than security monitoring.
+
+### Integration Points
+
+4. **Email infrastructure exists but underutilized**: The `person.email` field is present and used for ballot distribution, but no security notification email capability has been implemented. This represents a missed opportunity for out-of-band security communication.
+
+---
+
+## Recommendations Summary
+
+### Immediate Actions (0-30 days)
+
+| Priority | Action | Effort | Impact | Files Affected |
+|----------|--------|--------|--------|----------------|
+| **1** | Add `auth_event` table to schema for tracking all authentication events (IP, UA, timestamp, outcome) | Medium | Enables all subsequent detection and notification capabilities | `v3/schema.sql` |
+| **2** | Implement post-authentication hook to record events and evaluate suspicious patterns (new IP, long inactivity, failures) | Medium-High | Core detection capability — addresses ASVS-635-SEV-002 | `v3/server/pages.py` |
+
+### Short-term Actions (1-3 months)
+
+| Priority | Action | Effort | Impact | Files Affected |
+|----------|--------|--------|--------|----------------|
+| **3** | Build email notification service for suspicious authentication events using existing `person.email` | Medium | Direct user notification per ASVS 6.3.5 — addresses ASVS-635-SEV-003 | `v3/server/pages.py`, new email module |
+| **4** | Add in-app security notification display to `/profile` and `/voter` pages (authentication history, pending alerts) | Low-Medium | Secondary notification channel, visible on every authenticated visit | `v3/server/pages.py`, templates |
+
+### Long-term Actions (3-6 months)
+
+| Priority | Action | Effort | Impact | Files Affected |
+|----------|--------|--------|--------|----------------|
+| **5** | If `asfquart` auth framework supports event callbacks/hooks, integrate with them to capture failed login attempts (which currently never reach application code) | Medium | Captures failed attempts that occur before session establishment | `v3/server/pages.py`, framework integration |
+| **6** | Implement geographic IP analysis for location-based suspicious login detection | Medium | Enhanced detection of account takeover from foreign locations | New geolocation module |
+| **7** | Add user-controllable security preferences (notification thresholds, trusted devices) | High | User empowerment and reduced false positive notifications | `v3/server/pages.py`, `v3/schema.sql` |
+
+---
+
+## Appendix: Files Analyzed
+
+<details>
+<summary>Click to expand file list (4 files)</summary>
+
+### High Relevance (Relevance: 10)
+- `v3/server/pages.py` — Primary application logic, session handling, all authenticated endpoints
+
+### Medium Relevance (Relevance: 5)
+- `v3/steve/election.py` — Database interaction patterns, potential event logging integration points
+
+### Low Relevance (Relevance: 2)
+- `v3/docs/schema.md` — Schema documentation, data model understanding
+- `v3/schema.sql` — Database schema definition, authentication data storage capability
+
+</details>
+
+---
+
+**End of Report**
+
+*This audit was conducted against ASVS v4.0 Level 3 requirements. For questions or clarifications, please contact the audit team.*
\ 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