Skip to content

Fix DOS attack from malicious pongs #291

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

Merged
merged 2 commits into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
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: 2 additions & 2 deletions ci/container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ RUN go get golang.org/x/tools/cmd/stringer
RUN go get golang.org/x/lint/golint
RUN go get github.com/agnivade/wasmbrowsertest

RUN npm install -g prettier
RUN npm install -g netlify-cli
RUN npm --unsafe-perm=true install -g prettier
RUN npm --unsafe-perm=true install -g netlify-cli
2 changes: 1 addition & 1 deletion conn_notjs.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (c *Conn) Ping(ctx context.Context) error {
}

func (c *Conn) ping(ctx context.Context, p string) error {
pong := make(chan struct{})
pong := make(chan struct{}, 1)

c.activePingsMu.Lock()
c.activePings[p] = pong
Expand Down
5 changes: 4 additions & 1 deletion read.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ func (c *Conn) handleControl(ctx context.Context, h header) (err error) {
pong, ok := c.activePings[string(b)]
c.activePingsMu.Unlock()
if ok {
close(pong)
select {
case pong <- struct{}{}:
default:
}
}
return nil
}
Expand Down