Skip to content

Commit f4db2dd

Browse files
sgmillerbruj0
andauthored
Avoid disclosing IP addresses in unauthenticated requests (#10579)
* removing extra information from the returned error, to avoid leaking it to unauthenticated requests * removing extra information from the returned error, to avoid leaking it to unauthenticated requests * Change the error message in a way that is retains the HTTP status code Co-authored-by: bruj0 <[email protected]>
1 parent 5447fdd commit f4db2dd

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

http/logical.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,17 @@ func buildLogicalRequestNoAuth(perfStandby bool, w http.ResponseWriter, r *http.
112112
// and an incorrect content-type).
113113
head, err := bufferedBody.Peek(512)
114114
if err != nil && err != bufio.ErrBufferFull && err != io.EOF {
115-
return nil, nil, http.StatusBadRequest, err
115+
status := http.StatusBadRequest
116+
logical.AdjustErrorStatusCode(&status, err)
117+
return nil, nil, status, fmt.Errorf("error reading data")
116118
}
117119

118120
if isForm(head, r.Header.Get("Content-Type")) {
119121
formData, err := parseFormRequest(r)
120122
if err != nil {
121-
return nil, nil, http.StatusBadRequest, fmt.Errorf("error parsing form data: %w", err)
123+
status := http.StatusBadRequest
124+
logical.AdjustErrorStatusCode(&status, err)
125+
return nil, nil, status, fmt.Errorf("error parsing form data")
122126
}
123127

124128
data = formData
@@ -129,7 +133,9 @@ func buildLogicalRequestNoAuth(perfStandby bool, w http.ResponseWriter, r *http.
129133
err = nil
130134
}
131135
if err != nil {
132-
return nil, nil, http.StatusBadRequest, err
136+
status := http.StatusBadRequest
137+
logical.AdjustErrorStatusCode(&status, err)
138+
return nil, nil, status, fmt.Errorf("error parsing JSON")
133139
}
134140
}
135141
}

0 commit comments

Comments
 (0)