Bug 37040: Prevent ErrorDocument subrequests from activating CSRF
authorDavid Cook <dcook@prosentient.com.au>
Thu, 6 Jun 2024 01:34:23 +0000 (01:34 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 10 Jun 2024 11:01:03 +0000 (12:01 +0100)
commitc1ac12417612799a0055046e10031943adb02e18
tree8ec17d223f1ff9501a5157419887298e3bc9aba1
parent1daccb71bece082841abcb41c6eb5f3a9f12fa30
Bug 37040: Prevent ErrorDocument subrequests from activating CSRF

This change improves the mechanism for preventing the CSRF middleware
being activated by ErrorDocument subrequests.

This change was necessary due to a subtle issue identified by
Bug 37041.

Test plan:
0. Apply the patch
1. Restart Koha
koha-plack --restart kohadev
2. Go to http://localhost:8081/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=9908
3. Log in
4. Note that you get a pretty 403 and not an ugly plain text error
5. Go to http://localhost:8081
6. Fill in the login details, but use the HTML inspector to delete
the csrf_token from the hidden inputs
7. Submit the login
8. Note a pretty 403 page

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Koha/Middleware/CSRF.pm