Skip to content

fix(security): RBAC M3 follow-up — memory ACL fail-closed for anonymous callers#3239

Merged
houko merged 2 commits into
mainfrom
followup/3205-memory-loopback-failclose
Apr 26, 2026
Merged

fix(security): RBAC M3 follow-up — memory ACL fail-closed for anonymous callers#3239
houko merged 2 commits into
mainfrom
followup/3205-memory-loopback-failclose

Conversation

@houko

@houko houko commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to MERGED #3205. Closes the loopback fail-open in routes/memory.rs::guard_for_request.

The bug

When the auth middleware did NOT attach AuthenticatedApiUser (loopback dev, single-user mode, or any LIBREFANG_ALLOW_NO_AUTH=1 deployment), the fallback handed out an owner-equivalent ACL:

readable_namespaces: vec!["*"]
writable_namespaces: vec!["*"]
pii_access: true
export_allowed: true
delete_allowed: true

Any process at 127.0.0.1 or any opt-in no-auth deployment could exfiltrate every memory fragment (PII included) and bulk-delete across agents — exactly the surface RBAC M3 was supposed to gate.

The other admin-gated RBAC endpoints (/api/audit/query, /api/budget/users/*, /api/authz/effective/*) already reject anonymous callers with PermissionDenied audit rows. Memory ACL was the outlier.

Fix

Replaced the fallback with a Viewer-equivalent ACL (anonymous_fallback_acl()):

Capability Pre-fix (anonymous) Post-fix (anonymous)
Read proactive
Read kv:* / shared:* / kg 🔒 deny
Write any namespace 🔒 deny
Export 🔒 deny
Delete 🔒 deny
PII access 🔒 deny

Loopback dashboard reads on the proactive surface keep working; everything sensitive now AuthDenied → 403 at the namespace_acl layer. To regain the broad-access behaviour, configure a user with an api_key + Admin/Owner role and authenticate with that token.

Tests

Two unit tests in the new #[cfg(test)] mod tests:

  • anonymous_fallback_denies_pii_export_and_delete — pins each ACL flag value
  • anonymous_fallback_guard_gates_match_acl_intent — walks the guard through every leak vector (read kv:*/shared:*/kg, write proactive, export proactive, delete proactive) and asserts Deny at each

Refs #3205 (review item #6).

…us callers

Closes the fail-open in routes/memory.rs::guard_for_request — when the
auth middleware doesn't attach an AuthenticatedApiUser (loopback dev or
LIBREFANG_ALLOW_NO_AUTH=1), the previous fallback granted full
read/write across every namespace plus pii_access, export_allowed, and
delete_allowed. Any process at 127.0.0.1 or any deployment with the
no-auth env opt-in could exfiltrate every memory fragment including
PII and bulk-delete across agents.

Other admin-gated RBAC endpoints (audit query, per-user budget, authz
effective) already reject anonymous callers; memory ACL was the
outlier.

Replaced the fallback with a Viewer-equivalent ACL inlined as
anonymous_fallback_acl(): read access scoped to the proactive
namespace only; writes, exports, deletes, and PII access all denied.
Loopback dashboard reads continue to work for the proactive surface;
sensitive operations now fail closed at the namespace_acl layer (return
AuthDenied → 403).

Two new unit tests in #[cfg(test)] mod tests pin the contract:
- anonymous_fallback_denies_pii_export_and_delete asserts each flag
- anonymous_fallback_guard_gates_match_acl_intent walks the guard
  through every namespace gate to make sure the four leak channels
  (read kv:*/shared:*/kg, write proactive, export proactive, delete
  proactive) all return Deny

Refs PR #3205 review item #6.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions github-actions Bot added ready-for-review PR is ready for maintainer review size/M 50-249 lines changed labels Apr 26, 2026
@houko
houko merged commit c202f75 into main Apr 26, 2026
20 checks passed
@houko
houko deleted the followup/3205-memory-loopback-failclose branch April 26, 2026 14:33
@github-actions github-actions Bot removed the ready-for-review PR is ready for maintainer review label Apr 26, 2026
@houko houko mentioned this pull request Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M 50-249 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant