Skip to content

Potential fix for code scanning alert no. 24: Missing rate limiting #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 15, 2025

Conversation

vprusso
Copy link
Collaborator

@vprusso vprusso commented May 12, 2025

Potential fix for https://github.com/unitaryfoundation/metriq-api/security/code-scanning/24

To fix the issue, we will add rate limiting to the accountController.update_password route. We will use the express-rate-limit package to define a rate limiter and apply it specifically to this route. The rate limiter will restrict the number of requests a client can make to the update_password endpoint within a specified time window, mitigating the risk of brute-force or denial-of-service attacks.

Steps:

  1. Install the express-rate-limit package if it is not already installed.
  2. Import the express-rate-limit package in the api-routes.js file.
  3. Define a rate limiter with appropriate settings (e.g., a maximum of 5 requests per minute).
  4. Apply the rate limiter to the router.route('/user/password').post(accountController.update_password) route.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@vprusso vprusso marked this pull request as ready for review May 12, 2025 18:05
@vprusso vprusso requested a review from cosenal May 12, 2025 18:05
Copy link
Contributor

@cosenal cosenal left a comment

Choose a reason for hiding this comment

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

Build is failing (related to the npm lock file)

@vprusso vprusso requested a review from cosenal May 14, 2025 23:48
vprusso and others added 6 commits May 15, 2025 16:29
…m user-controlled sources

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…257)

* Potential fix for code scanning alert no. 23: Missing rate limiting

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* chore: update npm lock

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…nsitive information (#255)

* Potential fix for code scanning alert no. 1: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* chore: remove console log statement.

* chore: remove sanitize function

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…243)

* Potential fix for code scanning alert no. 22: Missing rate limiting

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* chore: update lock file

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@cosenal cosenal merged commit b2574b7 into main May 15, 2025
4 checks passed
@cosenal cosenal deleted the alert-autofix-24 branch May 15, 2025 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants