-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Kong admin fails (500) to handle HTTP-request with duplicated header keys Content-Type
#14187
Comments
Content-Type
in the headerContent-Type
It's not kind of valid to have multiple headers of the same type. Check https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7 |
@khaled4vokalz, Hello. Yes, I agree, the HTTP packet I provided may be somewhat of invalid. Moreover, (2) other inconsistencies in HTTP packets (three examples below) are being handled correctly (anyway, there is always a way to check the type and return, for example, 400 instead of script crash). kong/kong/plugins/jwt/handler.lua Line 59 in 898882d
Line 455 in 898882d
kong/kong/router/traditional.lua Line 971 in 898882d
Thus, based on points (1) and (2) I conclude that the behavior described in the issue is a bug in Kong. |
@Toliak I agree, this seems to be a bug. I'll create a ticket to track this issue. Thank you very much for your report! |
Is there an existing issue for this?
"Content-Type" 500
,"bad argument #1 to 'sub'"
)Can be related: #8734
Kong version (
$ kong version
)Kong Enterprise 3.9.0.0
Current Behavior
I'm using
kong:3.9.0-ubuntu
docker image.When I send crafted HTTP-packet with multiple
Content-Type
keys in the header, Kong fails with Internal Server Error 500.Expected Behavior
Maybe it should return Bad request (400).
Steps To Reproduce
The
start.sh
file (based on the docker image documentation):The Packet
packet.txt
(two empty lines at the end. The line-endings must be CRLF):The
send.sh
script:Steps:
bash start.sh
bash send.sh packet.txt
Anything else?
Logs from netcat:
Logs from server:
Source (260 instead of 267 due to 7 lines of copyright in the beginning of the file in the docker image): https://github.com/Kong/kong/blob/3.9.0/kong/api/api_helpers.lua#L260-L262
As I can see,
sub
function expects string incontent_type
variable (and receives it, if there is only one header with keyContent-Type
). However, if multiple linesContent-Type: ...
provided, thecontent_type
variable will contain a table.Same issue happens if I change
POST
toPUT
in the packet.txt.Similar issue happens if I change
POST
toGET
in the packet.txt, however, the error relates to/usr/local/share/lua/5.1/lapis/application.lua
so I will create an issue in the Lapis repository. (leafo/lapis#794)The issue will not happen if I change
POST
toDELETE
in the packet.txt.The text was updated successfully, but these errors were encountered: