Skip to content

net/http: Calling request.Body.Close() triggers DOS attack vector #9662

Closed
@klauspost

Description

@klauspost

This is related to Issue #2093 - however, I found that the issue can still be triggered, if the body of the request is closed.

Server: http://play.golang.org/p/bBhu-3VKAE

Client example: curl -X POST -T "/path/to/huge-file" http://localhost:8080/

Output from server:

2015/01/22 14:42:47 Closing Body
2015/01/22 14:42:53 Body Closed

The 8 seconds are spent transferring the entire POST body to the server, even though it is discarded. I would expect the Close() call to be a NO-OP at worst.

The fix for the server is simply to NOT close the request body. However there isn't any "calling Body.Close() is a bad idea", in fact people in the community have been encouraging it.

Github search

Go version: go version go1.4 windows/amd64

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions