Skip to content
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

Safeguard against redirects on PUT request #1418

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/witness/client/http/witness_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ func (w Witness) Update(ctx context.Context, logID string, sth []byte, proof [][
if err != nil {
return nil, fmt.Errorf("failed to do http request: %v", err)
}
if resp.Request.Method != "PUT" {
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections#permanent_redirections
return nil, fmt.Errorf("PUT request to %q was converted to %s request to %q", u.String(), resp.Request.Method, resp.Request.URL)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
Expand Down
Loading