Skip to content

Commit b8ee206

Browse files
committed
feat(ssh): set data limiter to payload received after sucessful ssh request
1 parent 74a97b2 commit b8ee206

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ssh/pkg/dialer/target.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bufio"
55
"encoding/json"
66
"fmt"
7+
"io"
78
"net"
89
"net/http"
910
"strconv"
@@ -108,7 +109,10 @@ func (t HTTPProxyTarget) prepare(conn net.Conn, version ConnectionVersion) (net.
108109
return nil, err
109110
}
110111
result := map[string]string{}
111-
if err := json.NewDecoder(conn).Decode(&result); err != nil {
112+
113+
// NOTE: limit the size of the response to avoid DoS via large payloads.
114+
const Limit = 512
115+
if err := json.NewDecoder(io.LimitReader(conn, Limit)).Decode(&result); err != nil {
112116
return nil, err
113117
}
114118
if result["status"] != "ok" {

0 commit comments

Comments
 (0)