fix: escape user-controlled data in order.log() and objects_to_hyperlinks() - #2522
fix: escape user-controlled data in order.log() and objects_to_hyperlinks()#2522TempleOfSats wants to merge 9 commits into
Conversation
…inks() - api/models/order.py: escape() level and event before storing in logs to prevent XSS via order IDs, usernames, addresses, descriptions etc. - api/utils.py: escape() entire logs string before regex substitution in objects_to_hyperlinks() as defense-in-depth against injected HTML/JS
|
The change in |
…inks() - api/models/order.py: escape() level and event before storing in logs to prevent XSS via order IDs, usernames, addresses, descriptions etc. - api/utils.py: escape() entire logs string before regex substitution in objects_to_hyperlinks() as defense-in-depth against injected HTML/JS #2522
|
As @jerryfletcher21 pointed out, this will break the rendering. There are also places in the code that add logs containing HTML tags. I think we should fix this by converting the logs column into a JSON column, then having the log message containing plain-text only, but with a few special behavior, like the existing |
|
@TempleOfSats any update on this? |
c1831bc
|
Well done! |
|
I asked AI to write a script to convert the old logs into the new format: https://gist.github.com/alicecoordinator/f96151ff1ca00eacd88abf2f83be0724. Just need to execute it from the root of the application (inside the container if it is the case). |
Changes
1. api/models/order.py — log() method
2. api/utils.py — objects_to_hyperlinks() function
Security Impact
Both fixes prevent XSS attacks via the order logs system.