Repository navigation
Limit how often a visitor may send a storefront form or upload a file - #1113
Merged
Merged
Conversation
The guest-order and storefront form limits (permits and window) move to the Security section, with the previous values as defaults; 0 turns a limit off.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The only rate limit in the storefront was the guest-order link page. The forms that mail the store or keep what a visitor sent (contact us, contact a vendor, e-mail a friend, ask a question, product and vendor reviews, blog and news comments, newsletter, password recovery) relied on the optional captcha alone, and the three attribute uploads (product, checkout, contact) store every file in the database with no limit on how many a guest sends. A script could flood the store's mailbox, fill the review queue, or fill the database with uploads.
Changes
StorefrontForminGrandCommonStartup: 10 posts in 10 minutes per IP address and per form; the next post in the window gets the existing 429 answer ("Too many requests. Please try again later.").Securitysection of appsettings:StorefrontFormRateLimitPermits/StorefrontFormRateLimitWindowMinutes(10 / 10) andGuestOrderRateLimitPermits/GuestOrderRateLimitWindowMinutes(5 / 10). A missing key keeps the default; 0 turns a limit off.Notes
UseForwardedHeadersis on, as for the guest-order page already.MaxRequestBodySize10 MB, which bounds one upload; what was open was the number of uploads, which this limit covers.Tests
RateLimitPartitionTests(new): the configured number of posts passes and the next one is refused; a zero limit or window turns the limit off.StorefrontFormRateLimitTests(new): each of the 13 form and upload POSTs namesStorefrontForm.Grand.Web.Tests(668) pass.