Skip to content

fix(auth): require admin session for passkey enrollment - #942

Merged
ImMohammad20000 merged 1 commit into
PasarGuard:devfrom
dr-hoseyn:codex/fix-passkey-api-key-escalation
Oct 4, 2026
Merged

ImMohammad20000 merged 1 commit into
PasarGuard:devfrom
dr-hoseyn:codex/fix-passkey-api-key-escalation

Conversation

@dr-hoseyn

@dr-hoseyn dr-hoseyn commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Require a valid admin bearer session for all four passkey enrollment endpoints.
  • Prevent a scoped API key from enrolling its own passkey and using it to obtain a full admin JWT.
  • Preserve API-key authentication on other endpoints.

Verification

  • Direct mocked checks: API key rejected for enrollment, invalid bearer plus API key rejected, valid bearer accepted, ordinary API-key authentication preserved.
  • Confirmed all four enrollment routes use the session-only dependency.
  • ruff check --no-fix on both changed files, Python compileall, and git diff --check passed.

Only runtime code is included; no test or documentation files were added.

Summary by CodeRabbit

  • Bug Fixes
    • Passkey registration and verification now require session-based authentication. API keys are no longer accepted for these actions, including admin-scoped registration. This ensures passkey operations use an authenticated session rather than API-key credentials.

@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 0d23cf10-2e76-4e09-827a-a310a247bf3c

📥 Commits

Reviewing files that changed from the base of the PR and between 26047f6 and 88411bb.

📒 Files selected for processing (2)
  • app/routers/authentication.py
  • app/routers/passkey.py

Included review availability: Your plan provides up to 8 included reviews per hour; 3 remain after this review.


Walkthrough

Authentication now supports disabling API-key fallback. Passkey registration options and verification routes use this session-specific authentication dependency.

Changes

Passkey session authentication

Layer / File(s) Summary
Add API-key fallback control
app/routers/authentication.py
Authentication functions accept an allow_api_key parameter. The new get_current_session dependency disables API-key authentication.
Use session authentication for passkey registration
app/routers/passkey.py
Passkey registration options and verification routes use get_current_session. The module also removes an unused FastAPI import.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: x0sina

Merge Risk: ⚪ Minimal · up to 88411

The four passkey enrollment endpoints require an enabled admin session, while ordinary API-key authentication remains available on other endpoints. No concrete merge-blocking risk remains in the reviewed changes.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 88411

The reviewed enrollment paths now require an admin bearer token instead of accepting an API key. Other API-key authentication remains available. No introduced security issue was established, although deployment behavior and some security coverage remain unverified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The narrowed boundary protects enrollment for the authenticated admin account: an API key alone no longer reaches passkey creation, which could otherwise establish a credential usable for admin-token issuance. The reviewed paths do not establish broader cross-account exposure.

Trust Boundaries and Controls

  • observed — The session-only dependency passes allow_api_key=False. Bearer resolution uses signed admin-token payload validation; if it does not authenticate an admin, the resolver does not extract or validate an API key in this mode.

Resilience and Maintainability Implications

  • observed — The existing challenge consumer selects a matching record, then deletes and commits it before cryptographic verification. This rejects sequential reuse but does not itself establish atomic single-use under concurrent verification; an invalid verification also consumes the challenge. The identified PR changes do not modify that lifecycle.

Hardening Proposals

  • proposed — Separately from this credential-boundary change, make successful challenge consumption atomic so concurrent verifications cannot both proceed from the same challenge.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: requiring an admin session for passkey enrollment.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the session door,
No API key slips in before.
Passkey options hop along,
Verification joins the song.
Soft paws leave the routes in tune.

Comment @coderabbitai help to get the list of available commands.

@dr-hoseyn

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ImMohammad20000
ImMohammad20000 merged commit 15a61fc into PasarGuard:dev Oct 4, 2026
10 checks passed
Free-Guy-IR added a commit to Free-Guy-IR/panel that referenced this pull request Nov 2, 2026
…e port queue

Owner decision of 2026-10-07: an unported security-relevant upstream commit must
turn the parity gate red at once unless it carries a Ported by design or Waived
decision; the port queue's dated grace is for other commits only.

A queued commit is security-relevant when its ledger reason carries "(security)"
or "[security]", or when its subject names security, a CVE or GHSA id, a
vulnerability, auth, authentication or authorization, permissions, privileges,
API keys, JWT, tokens, sessions, passkeys, WebAuthn, credentials, passwords,
injection, XSS, CSRF, SSRF, escaping or sanitizing. Such a commit, and any
patch-identical copy of it, is reported as unported with a ledger error that says
why, and turns green when its port lands with a trailer or it is decided.

On this branch line the gate is therefore red until the ports land: PasarGuard#938, PasarGuard#940 and
PasarGuard#942 (picked on parity/c2-port), eb50bfd (passkey login, picked on parity/c2-port
and release/v5.34.25-p13-sync) and the cryptography 50.0.2 bump e2707d9, which
has no port yet. Tests show each case failing in the queue and passing once
ported or waived; non-security ports keep their deadline.
Free-Guy-IR added a commit to Free-Guy-IR/panel that referenced this pull request Nov 2, 2026
… to ff6e596

Every Port queue line in the panel and side-repository ledgers now says
`security: yes` or `security: no`. Security: c9b445a (passkey client rename),
eb50bfd, PasarGuard#938, PasarGuard#940, PasarGuard#942, the cryptography 50.0.2 security release, and the ten
commits of upstream's PasarGuard#979 permission-leak batch (user list scopes, API-key
permissions, HWID visibility, users.read, the Telegram inline search), which no
branch ports yet.

Checked with git ls-remote on 2026-10-09: upstream dev moved to ff6e596. The
PasarGuard#979 batch, the node RPC fixes (PasarGuard#977, PasarGuard#978), the core-deletion restart (PasarGuard#934),
dashboard fixes (PasarGuard#852, PasarGuard#907, PasarGuard#949, PasarGuard#952), performance changes (PasarGuard#945, PasarGuard#853, PasarGuard#855) and
the merged dependabot bumps (ruff, uvloop, fastapi) join the queue; the ruff and
uvloop conditional waivers ended when upstream merged them. Waived: PasarGuard#980 and its
branch commit (the Telegram notifier workflow the fork deleted) and the superseded
fastapi dependabot head b021d6f. The refs snapshot records the five new heads.
Fork core-kit main 90701408 now contains upstream d2ecb5bd, so that ledger is empty.
No side repository gained an upstream commit since 2026-10-07.
Free-Guy-IR added a commit to Free-Guy-IR/panel that referenced this pull request Nov 3, 2026
RED for upstream 15a61fc (PasarGuard#942): an inheriting API key can request
passkey registration options for its admin; enrollment must need a session.
Free-Guy-IR pushed a commit to Free-Guy-IR/panel that referenced this pull request Nov 3, 2026
Co-authored-by: etm <etm@LAPTOP-62O1BVSJ>
(cherry picked from commit 15a61fc)
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.

2 participants