Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Conversation

@alromh87
Copy link

@alromh87 alromh87 commented Dec 8, 2020

📊 Metadata *

Bounty URL: https://www.huntr.dev/bounties/1-other-node-login

⚙️ Description *

node-login is a template for quickly building login systems on top of Node.js & MongoDB. It is vulnerable to CSRF attacks in Update and Delete profile actions

💻 Technical Description *

Avoid CSRF by using csrf token using csurf

🐛 Proof of Concept (PoC) *

  1. Download and setup node-login
  2. Go to http://localhost:3000/signup and create an account
  3. Create payload and serve trough web
<html>
  <!-- CSRF PoC - generated by Burp Suite Professional -->
  <body>
  <script>history.pushState('', '', '/')</script>
    <form action="http://localhost:3000/home" method="POST">
      <input type="hidden" name="name" value="hacked" />
      <input type="hidden" name="email" value="hacked&#64;test&#46;com" />
      <input type="hidden" name="country" value="Afghanistan" />
      <input type="hidden" name="pass" value="hacked" />
      <input type="submit" value="Submit request" />
    </form>
  </body>
</html>
  1. Open payload from same browser as logged in user and click on Submit button
  2. User data has been tempered with
    Captura de pantalla de 2020-12-07 21-08-45

🔥 Proof of Fix (PoF) *

After fix data is unafected as csrf token is requiered for post actions

Captura de pantalla de 2020-12-17 10-02-44

👍 User Acceptance Testing (UAT)

All functinality is unafected
Captura de pantalla de 2020-12-07 21-44-31

Copy link

@mzfr mzfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, The fix looks good but I just think that instead of showing the complete debug message there should be some small error that won't give away internal paths etc.

@alromh87 alromh87 requested a review from mzfr December 17, 2020 16:02
@alromh87
Copy link
Author

@mzfr thanks for the comment, updated

Copy link

@mzfr mzfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now

Copy link

@Mik317 Mik317 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @alromh87 😄,
thanks for the great fix 👍

Could you add the protection also for the Delete action?

Cheers,
Mik

@alromh87
Copy link
Author

alromh87 commented Jan 14, 2021

Hello @Mik317 I think delete action is already taken care of, unless I'm missing another endpoint, you can try with this POC:

<html>
  <body>
  <script>history.pushState('', '', '/')</script>
    <form action="http://localhost:3000/delete" method="POST">
      <input type="submit" value="Submit request" />
    </form>
  </body>
</html>

And you should get:
Captura de pantalla de 2021-01-13 22-26-24

Before the fix you would get:
Captura de pantalla de 2021-01-13 22-30-58

Let me know what you think

@huntr-helper
Copy link

Congratulations alromh87 - your fix has been selected! 🎉

Thanks for being part of the community & helping secure the world's open source code.
If you have any questions, please respond in the comments section, or hit us up on Discord. Your bounty is on its way - keep hunting!

Come join us on Discord

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants