diff doc/reference.txt @ 8575:b1024bf0d9f7

feature: add nonceless/tokenless CSRF protection Add tokenless CSRF protection following: https://words.filippo.io/csrf/ Must be enabled using use_tokenless_csrf_protection in config.ini. By default it's off. If enabled the older csrf_* settings are ignored. The allowed_api_origins setting is still used for Origin comparisons. This should also improve performance as a nonce isn't required so generating random nonce and saving it to the otks database is eliminated. doc/admin_guide.txt, doc/reference.txt doc/upgrading.txt doc updates. roundup/configuration.py add use_tokenless_csrf_protection setting. move allowed_api_origins directly after use_tokenless_csrf_protection and before the older csrf_* settings. It's used by both of them. Rewrite description of allowed_api_origins as its applied to all URLs with tokenless protection, not just API URLs. roundup/anypy/urllib_.py import urlsplit, it is used in new code. urlparse() is less efficient and splits params out of the path component. Since Roundup doesn't require that params be split from the path. I expect future patch will replace urlparse() with urlsplit() globally and not need urlparse(). roundup/cgi/client.py add handle_csrf_tokenless() and call from handle_csrf() if use_tokenless_csrf_protection is enabled. refactor code that expires csrf tokens when used with the wrong methods (i.e. GET) into expire_exposed_keys(). Call same from handle_csrf and handle_csrf_tokenless. Also improve logging if this happens including both Referer and Origin headers if available. Arguably we dont care about CSRF tokens exposed via GET/HEAD/OPTIONS in the tokenless case, but this cleans them up in case the admin has to switch back. At some future date we can delete all the nonce based CSRF from 2018. Update handle_csrf() docstring about calling/returning handle_csrf_tokenless() when enabled. Call expire_exposed_keys(method) if token is supplied with wrong method. roundup/cgi/templating.py disable nonce generation/save and always return "0" when use_tokenless_csrf_protection enabled.
author John Rouillard <rouilj@ieee.org>
date Sun, 19 Apr 2026 20:50:07 -0400
parents 0e712d67a783
children 023a83cf3ae8
line wrap: on
line diff
--- a/doc/reference.txt	Tue Apr 14 19:40:15 2026 -0400
+++ b/doc/reference.txt	Sun Apr 19 20:50:07 2026 -0400
@@ -2231,15 +2231,48 @@
 **search**
  Determine whether the user has permission to view this class.
 
+.. _`nonceless CSRF`:
+
 Protecting users from web application attacks
 ---------------------------------------------
 
-There is a class of attacks known as Cross Site Request Forgeries
-(CSRF). Malicious code running in the browser can making a
-request to Roundup while you are logged into Roundup. The
-malicious code piggy backs on your existing Roundup session to
-make changes without your knowledge. Roundup 1.6 has support for
-defending against this by analyzing the
+There is a type of attack known as Cross Site Request Forgeries
+(CSRF). Malicious code running in the browser can send a request
+to Roundup while you are logged in. The malicious code takes
+advantage of your active Roundup session to make changes without
+your knowledge.
+
+Roundup 2.6 added support for tokenless (nonceless) protection.
+This is based on `Cross-Site Request Forgery by Filippo Valsorda
+<https://words.filippo.io/csrf/>`_. Currently you must manually
+enable it. At some point in the future, it will be the default
+CSRF protection method.
+
+You can enable it for each tracker using ``config.ini``. In the
+``[web]`` section of ``config.ini`` setting
+``use_tokenless_csrf_protection`` to ``yes`` enables it. Since
+this is a replacement for the prior anti-CSRF protections, it
+turns off the older nonce and header-based CSRF settings.
+
+The Origin header is checked against the value of the
+``allowed_api_origins`` option. You can use it to allow access to
+Roundup from other web sites. For example your homepage at
+www.example.com displays the 10 most recently updated issues from
+Roundup running at issues.example.com. To allow this, you would
+set the ``allowed_api_origins`` to ``https://www.example.com``.
+
+If your users have older browsers (pre 2023) you may need to
+continue using the older token/nonce based CSRF protection method.
+See Valsorda's page for details.
+
+With this mode enabled, the ``utils.anti_csrf_nonce()`` function
+always returns `"0". It does not generate a nonce nor store it to
+the otks database which should improve response times.
+
+Token/nonce based CSRF protection
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Roundup 1.6 has support for defending against this by analyzing the
 
 * Referer,
 * Origin, and

Roundup Issue Tracker: http://roundup-tracker.org/