Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Remove three no-op csrf_exempt decorator definitions and the unused is_token_authenticated stub (audit cleanup from GHSA-x4q4-3ww4-h329)
Murtaza Nasirf9c4b2b92f5b
diff --git a/src/api/admin.py b/src/api/admin.pyindex 2042de22..28c4a15e 100644--- a/src/api/admin.py+++ b/src/api/admin.py@@ -48,15 +48,6 @@ def init_admin_helpers(**kwargs):limiter = kwargs.get('limiter')-def csrf_exempt(f):- """Decorator placeholder for CSRF exemption - applied after initialization."""- from functools import wraps- @wraps(f)- def wrapper(*args, **kwargs):- return f(*args, **kwargs)- wrapper._csrf_exempt = True- return wrapper-# --- Routes ---@@ -754,7 +745,6 @@ def admin_update_setting():@admin_bp.route('/admin/auto-deletion/run', methods=['POST'])@login_required-@csrf_exempt # Exempt since already protected by admin authenticationdef run_auto_deletion():"""Admin endpoint to manually trigger auto-deletion process."""if not current_user.is_admin:diff --git a/src/api/auth.py b/src/api/auth.pyindex 294f5ca3..8888c8dc 100644--- a/src/api/auth.py+++ b/src/api/auth.py@@ -70,16 +70,6 @@ def rate_limit(limit_string):return decorator-def csrf_exempt(f):- """Decorator placeholder for CSRF exemption - applied after initialization."""- from functools import wraps- @wraps(f)- def wrapper(*args, **kwargs):- return f(*args, **kwargs)- wrapper._csrf_exempt = True- return wrapper--# --- Forms ---class RegistrationForm(FlaskForm):@@ -368,8 +358,12 @@ def sso_unlink():@auth_bp.route('/logout')-@csrf_exemptdef logout():+ # /logout is GET-only, so Flask-WTF's CSRF check (which runs only on+ # state-changing methods) does not apply. No explicit exemption is+ # needed. A future hardening pass should move logout to POST so a+ # CSRF-redirected GET can't log a victim out, but that is a behaviour+ # change deferred from this security release.logout_user()return redirect(url_for('auth.login'))diff --git a/src/api/system.py b/src/api/system.pyindex 78efb9e1..141ac6c4 100644--- a/src/api/system.py+++ b/src/api/system.py@@ -57,15 +57,6 @@ def init_system_helpers(**kwargs):chunking_service = kwargs.get('chunking_service')-def csrf_exempt(f):- """Decorator placeholder for CSRF exemption - applied after initialization."""- from functools import wraps- @wraps(f)- def wrapper(*args, **kwargs):- return f(*args, **kwargs)- wrapper._csrf_exempt = True- return wrapper-# --- Routes ---@@ -315,7 +306,6 @@ def get_config():@system_bp.route('/api/csrf-token', methods=['GET'])-@csrf_exempt # Exempt this endpoint from CSRF protection since it's providing tokensdef get_csrf_token():"""Get a fresh CSRF token for the frontend."""try:diff --git a/src/utils/__init__.py b/src/utils/__init__.pyindex 5d909f1a..0c1bb3da 100644--- a/src/utils/__init__.py+++ b/src/utils/__init__.py@@ -39,7 +39,7 @@ from .token_auth import (extract_token_from_request,hash_token,load_user_from_token,- is_token_authenticated+ load_user_from_token_headers_only,)from .error_formatting import (@@ -71,7 +71,7 @@ __all__ = ['extract_token_from_request','hash_token','load_user_from_token',- 'is_token_authenticated',+ 'load_user_from_token_headers_only',# Error formatting'is_transcription_error','format_error_for_user',diff --git a/src/utils/token_auth.py b/src/utils/token_auth.pyindex 1464fa7d..c6999390 100644--- a/src/utils/token_auth.py+++ b/src/utils/token_auth.py@@ -134,13 +134,3 @@ def load_user_from_token_headers_only():return api_token.user-def is_token_authenticated():- """Deprecated stub kept only for inbound import compatibility.-- The original implementation returned True on the mere PRESENCE of a- token-looking parameter, which was the root cause of GHSA-x4q4-3ww4-h329.- It is no longer used by the CSRF protection hook; the replacement is- :func:`load_user_from_token_headers_only` plus the- :func:`src.app.csrf_token_aware_check` before_request handler.- """- return load_user_from_token_headers_only() is not None