Skip to content

Commit

Permalink
Enforce a maximum packet length
Browse files Browse the repository at this point in the history
Permanently fixes CVE-2015-5159 for all applications.
  • Loading branch information
npmccallum committed Aug 3, 2015
1 parent e4a7119 commit f274aa6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion kdcproxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def __str__(self):


class Application:
MAX_LENGTH = 128 * 1024
SOCKTYPES = {
"tcp": socket.SOCK_STREAM,
"udp": socket.SOCK_DGRAM,
Expand Down Expand Up @@ -180,7 +181,11 @@ def __call__(self, env, start_response):
try:
length = int(env["CONTENT_LENGTH"])
except AttributeError:
length = -1
raise HTTPException(411, "Length required.")
if length < 0:
raise HTTPException(411, "Length required.")
if length > self.MAX_LENGTH:
raise HTTPException(413, "Request entity too large.")
try:
pr = codec.decode(env["wsgi.input"].read(length))
except codec.ParsingError as e:
Expand Down

0 comments on commit f274aa6

Please sign in to comment.