99designs / 99designs/httpsignatures-go

Missing `Host` header causes signature mismatch

Đang mở
#10 0 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Go
Star
28
Fork
15
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

The 7th draft of the "Signing HTTP Messages" spec [recommends](https://tools.ietf.org/html/draft-cavage-http-signatures-07#appendix-C.2) the use of the `Host` header when calculating a signature.
However, it looks like `Request` from `net/http` removes `Host` from the headers and instead makes it available on the `Request` structure itself.

Example:
```
&http.Request{
Method:"GET",
URL:(*url.URL)(0xc42010d100),
Proto:"HTTP/1.1",
ProtoMajor:1,
ProtoMinor:1,
Header:http.Header{
"Date":[]string{"Tue, 03 Oct 2017 23:18:06 GMT"},
"Accept-Encoding":[]string{"gzip;q=1.0,deflate;q=0.6,identity;q=0.3"},
"Signature":[]string{"keyId=\"key1\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date\",signature=\"T09YOpz+vN+VltcLRok8NgZSVSgm4W6EhjRUNwX7JXQ=\""},
"Connection":[]string{"keep-alive"},
"Keep-Alive":[]string{"30"},
"Accept":[]string{"application/x-msgpack"},
"User-Agent":[]string{"The Client"}
},
Body:http.noBody{},
GetBody:(func() (io.ReadCloser, error))(nil),
ContentLength:0,
TransferEncoding:[]string(nil),
Close:false,
Host:"localhost:3500",
Form:url.Values(nil),
PostForm:url.Values(nil),
MultipartForm:(*multipart.Form)(nil),
Trailer:http.Header(nil),
RemoteAddr:"[::1]:53522",
RequestURI:"/v1/files?ids%5B%5D=1",
TLS:(*tls.ConnectionState)(nil),
Cancel:(<-chan struct {})(nil),
Response:(*http.Response)(nil),
ctx:(*context.cancelCtx)(0xc4201ff8c0)
}
```
Should the `Host` header be special-cased?

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

The issue is about the net/http Request struct in Go, which moves the Host header to a field. Look at the library's signature calculation code to see how headers are processed. The fix likely involves checking the Request.Host field and including it in the signature when the 'host' header is listed. Review the HTTP signatures spec draft and existing tests to understand the expected behavior.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
go
Lĩnh vực
api, backend
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
55/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.