Skip to content

feat: manage bad requests with 'allow request methods' package #1325

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 4 commits into from
Feb 11, 2025

Conversation

CyntiBinti
Copy link
Contributor

@CyntiBinti CyntiBinti commented Feb 4, 2025

Current behaviour: a DDoS can use an unexpected HTTP method to bypass the Fastly cache and cause interruption to service. For example, making a request to the homepage as a POST rather than a GET. Express will return a 404 for this error.

Ideal future work: If we can transform this 404 error into a 405 Method Not Allowed, we may be able to use Signal Sciences to block this kind of attack very quickly. This is because it’s highly unlikely that a genuine user will accidentally make a POST request.

Definition of done for this ticket: Build and release a package containing an Express middleware that applications can consume which will cause unexpected request methods to error with a 405 rather than a 404.

Inspo: https://github.com/rowanmanning/allow-methods/blob/main/index.js

To-Do:

  • Write tests

See Also: CPREL-1276

Copy link
Member

@rowanmanning rowanmanning left a comment

Choose a reason for hiding this comment

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

This is looking great so far, I decided to swoop in with a review on your draft because I think these changes will reduce the number of tests and types you have to write by quite a lot!

@CyntiBinti CyntiBinti marked this pull request as ready for review February 7, 2025 20:50
Copy link
Member

@rowanmanning rowanmanning left a comment

Choose a reason for hiding this comment

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

Two really small type-related things and then we're ready to go! Exciting :) thanks for all the back and forth on this

Copy link
Member

@rowanmanning rowanmanning left a comment

Choose a reason for hiding this comment

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

Woo! Thanks, let's ship it 🚀 first new package in a while

Current behaviour: a DDoS can use an unexpected HTTP method to bypass the Fastly cache and cause
interruption to service. For example, making a request to the homepage as a POST rather than a GET.
Express will return a 404 for this error.

Ideal future work: If we can transform this 404 error into a 405 Method Not Allowed, we may be able
to use Signal Sciences to block this kind of attack very quickly. This is because it’s highly
unlikely that a genuine user will accidentally make a POST request.

Definition of done for this ticket: Build and release a package containing an Express middleware
that applications can consume which will cause unexpected request methods to error with a 405 rather
than a 404.

See Also: [CPREL-1276]
@CyntiBinti CyntiBinti enabled auto-merge (rebase) February 11, 2025 16:53
@CyntiBinti CyntiBinti merged commit 6a6a755 into main Feb 11, 2025
11 checks passed
@CyntiBinti CyntiBinti deleted the cprel-1276 branch February 11, 2025 17:03
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