Skip to content

Commit

Permalink
Block direct requests to private IPs (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
M4tthewDE authored Sep 13, 2023
1 parent e000a93 commit 6716075
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Minor: Block direct requests to private IPs. (#529)
- Breaking: Remove the `/twitchemotes/` endpoints. See [issue 332](https://github.com/Chatterino/api/issues/332) for more information. (#465)
- Minor: Use Twitter OG tags if no Twitter credentials are configured. (#522)
- Minor: Support `x.com` for tweets. (#527)
Expand Down
6 changes: 6 additions & 0 deletions internal/resolvers/default/link_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package defaultresolver
import (
"context"
"errors"
"net"
"net/http"
"net/url"
"strings"
Expand Down Expand Up @@ -44,6 +45,11 @@ func (r *LinkResolver) shouldIgnore(u *url.URL) bool {
return true
}

ip := net.ParseIP(u.Host)
if ip != nil && ip.IsPrivate() {
return true
}

return false
}

Expand Down

0 comments on commit 6716075

Please sign in to comment.