Skip to content

server, auth, access, ui: reject invalid Authorization headers - #884

Merged
rgushchin merged 2 commits into
mainfrom
feat/reject-invalid-auth-headers
Nov 11, 2026
Merged

rgushchin merged 2 commits into
mainfrom
feat/reject-invalid-auth-headers

Conversation

@rgushchin

Copy link
Copy Markdown
Member

Summary

Previously, OptionalAuthUser, OptionalPrincipal, TranscriptPrincipal, and resolve_bug_read_principal downgraded malformed, expired, or revoked Authorization bearer tokens to the anonymous principal on public and capability-addressed routes. Beyond hiding expired or misconfigured tokens from CLI callers and leaving stale sessions shown in the web UI, swallowing invalid credentials prevents Cloud Armor from exempting Authorization-bearing requests from anti-scraper rate limits because spoofed headers still receive 200 OK responses.

This PR validates any presented Authorization header up front in a router middleware and in the optional extractors before running handlers or querying SQLite:

  • No Authorization header (or single-header local operator token): continues to resolve as anonymous on public and capability-addressed routes.
  • Duplicate, malformed, expired, wrong-type, or unverified Authorization header: rejected immediately in memory with 401 Unauthorized.
  • Blocklisted address or session ID (server.acl.blocklist): rejected with 403 Forbidden across all routes, and the web UI clears its stored session when /api/config returns 403.

(Includes the rustc 1.95 clippy fix commit so CI passes cleanly on latest stable Rust.)

Replace manual sort_by closures with sort_by_key in agenda_derive, drop
redundant into_iter calls inside zip arguments in scan and prefetch,
and rewrite the colon-prefix loop in strip_title_subsystem_prefix as a
while-let loop so cargo clippy passes without warnings on rustc 1.95.

Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
OptionalAuthUser, OptionalPrincipal, TranscriptPrincipal, and
resolve_bug_read_principal previously downgraded malformed, expired, or
revoked Authorization bearer tokens to the anonymous principal on
public and capability-addressed routes. Aside from hiding expired or
misconfigured credentials from CLI callers and leaving stale sessions
displayed in the web UI, swallowing invalid credentials prevents an
edge proxy from exempting Authorization-bearing requests from scraper
rate limits because spoofed tokens still receive 200 responses.

Validate any presented Authorization header at the router middleware
and in the optional extractors before running handlers or touching
SQLite:
- Requests omitting Authorization (or presenting the single-header
  local operator token) continue to resolve as anonymous on public and
  capability-addressed routes.
- Requests carrying duplicate, malformed, expired, wrong-type, or
  unverified Authorization headers are rejected immediately with 401
  Unauthorized.
- Requests carrying a session or API token whose address or session ID
  is in server.acl.blocklist are rejected with 403 Forbidden across all
  routes, and the web UI clears its stored session when /api/config
  returns 403.

Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
@sashiko-bot

sashiko-bot Bot commented Nov 11, 2026

Copy link
Copy Markdown

Sashiko review

✓ No issues found across 2 commits.

Full review log on sashiko.sashiko.dev

@rgushchin
rgushchin merged commit e36c859 into main Nov 11, 2026
1 check passed
@rgushchin
rgushchin deleted the feat/reject-invalid-auth-headers branch November 12, 2026 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant