[security] tool_security.py fails closed on auth errors, locking out admins #675

Closed
opened 2026-06-02 23:41:14 +02:00 by sleepy · 1 comment
Owner

Security: tool_security.py fails closed on auth errors

File: src/tool_security.py

The owner_is_admin_or_single_user() function (line 56-67):

def owner_is_admin_or_single_user(owner: Optional[str]) -> bool:
    try:
        from core.auth import AuthManager
        auth = AuthManager()
        if not auth.is_configured:
            return True
        return bool(owner and auth.is_admin(owner))
    except Exception as exc:
        logger.warning("Unable to evaluate owner admin status: %s", exc)
        return False

Issue

  • When AuthManager() instantiation fails or is_admin() throws, the function returns False
  • This means any auth system error blocks all non-trivial tool access for every user including admins
  • A transient database error, import failure, or misconfiguration would lock out even admin users from bash, python, file operations, email, calendar, etc.
  • The except Exception is too broad — it catches ImportError, AttributeError, configuration errors, DB connection failures

Suggested fix

  • Distinguish between "auth checked and user is not admin" vs. "auth check failed unexpectedly"
  • On unexpected errors, either:
    • Log the error and allow access (fail-open for availability), or
    • Return a tri-state (admin / not-admin / unknown) and let callers decide based on context
  • Narrow the exception catch to specific expected failures
## Security: tool_security.py fails closed on auth errors ### File: `src/tool_security.py` The `owner_is_admin_or_single_user()` function (line 56-67): ```python def owner_is_admin_or_single_user(owner: Optional[str]) -> bool: try: from core.auth import AuthManager auth = AuthManager() if not auth.is_configured: return True return bool(owner and auth.is_admin(owner)) except Exception as exc: logger.warning("Unable to evaluate owner admin status: %s", exc) return False ``` ### Issue - When `AuthManager()` instantiation fails or `is_admin()` throws, the function returns `False` - This means **any auth system error blocks all non-trivial tool access** for every user including admins - A transient database error, import failure, or misconfiguration would lock out even admin users from bash, python, file operations, email, calendar, etc. - The `except Exception` is too broad — it catches `ImportError`, `AttributeError`, configuration errors, DB connection failures ### Suggested fix - Distinguish between "auth checked and user is not admin" vs. "auth check failed unexpectedly" - On unexpected errors, either: - Log the error and **allow** access (fail-open for availability), or - Return a tri-state (admin / not-admin / unknown) and let callers decide based on context - Narrow the exception catch to specific expected failures
Author
Owner

Fixed via PR #893 — fail-open for known users on auth errors, fail-closed for anonymous. Added error+warning logging.

Fixed via PR #893 — fail-open for known users on auth errors, fail-closed for anonymous. Added error+warning logging.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sleepy/odysseus#675
No description provided.