Skip to content

security(slm): a refused non-admin session leaves no audit record #20664

Closed

Description

@mrveiss

Problem

The SLM's admin-only rule (#20628, PR #20634) refuses a non-admin session in get_current_user (autobot-slm-backend/services/auth.py) with a 403 before the permission gate runs. That refusal only writes a log warning, so it leaves no audit record, while the gate's own denials do. Refused SSO logins are already audited as failures.

The cross-service parity test now scopes its audit rule to gate denials, so nothing checks this path.

Decision needed

Should a refused non-admin session write an audit record? Recording each one gives a paper trail, but it adds a write on every probe with a stale or non-admin token, so it may need rate limiting or aggregation.

Acceptance criteria

  • The decision is recorded on this issue.
  • If audited: a refused non-admin session writes a denial record, with a test, and repeated probes can't flood the store.
  • If not audited: the reason is written beside the refusal in get_current_user.

Activity

  1. mrveiss commented on Nov 2, 2026

    @mrveiss
    OwnerAuthor

    Maintainer decision (2026-11-02): audit refused non-admin SLM sessions, and rate-limit or group the repeats so probes can't flood the audit store. The PR waits until it's scheduled.

  2. mrveiss commented on Nov 3, 2026

    @mrveiss
    OwnerAuthor

    ✅ Closed with proof of implementation

    Landed: PR #20700 in merge train #20715 (merge 6f8c8d9f82), commits 240a288 and 6c98ac4. Checked on main at 6f8c8d9.
    Gate 2: the forward-reference check from pipeline-scripts/check-issue-close-refs.sh, run against origin/main → clear (5 historical mentions, none forward-tracking).

    Acceptance criteria (verbatim):

    • "The decision is recorded on this issue." — ✅ maintainer decision comment of 2026-11-02: audit refused non-admin sessions, grouping repeats so probes cannot flood the store.
    • "If audited: a refused non-admin session writes a denial record, with a test, and repeated probes can't flood the store." — ✅ autobot-slm-backend/services/auth.py:292-294 calls note_refused_session(payload.get("sub")) before refusing; services/refused_session_audit.py keeps one record per person per WINDOW_S (AUTOBOT_SLM_REFUSED_SESSION_AUDIT_WINDOW_S, default 300, clamped 1–86400) and caps tracked subjects at _MAX_TRACKED = 10_000. Tests in tests/services/test_refused_session_audit_20664.py: test_the_first_refusal_writes_a_denial_naming_the_person, test_repeats_in_the_window_write_nothing_and_the_next_record_counts_them, test_each_person_gets_their_own_record, test_the_tracked_set_cant_grow_past_its_cap, test_get_current_user_records_before_refusing.
    • "If not audited: the reason is written beside the refusal in get_current_user." — not applicable: the decision was to audit, so this branch does not apply. Left unticked deliberately.

    Follow-up filed: #20729 (a failed refused-session audit write still closes the person's audit window, so the next refusal in that window is not recorded).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions