SECURITY: 413 for GET, HEAD or DELETE requests with payload.

This commit is contained in:
Guo Xiang Tan
2020-08-03 14:11:17 +08:00
parent 32af607b70
commit 105d560177
2 changed files with 18 additions and 0 deletions

View File

@ -307,7 +307,15 @@ module Middleware
@app = app
end
PAYLOAD_INVALID_REQUEST_METHODS = ["GET", "DELETE", "HEAD"]
def call(env)
if PAYLOAD_INVALID_REQUEST_METHODS.include?(env[Rack::REQUEST_METHOD]) &&
env[Rack::RACK_INPUT].size > 0
return [413, {}, []]
end
helper = Helper.new(env)
force_anon = false