Skip to content

relay: remove SSRF protections for insecure localhost connections#1217

Open
bnewbold wants to merge 2 commits intomainfrom
bnewbold/relay-insecure-localhost
Open

relay: remove SSRF protections for insecure localhost connections#1217
bnewbold wants to merge 2 commits intomainfrom
bnewbold/relay-insecure-localhost

Conversation

@bnewbold
Copy link
Collaborator

@bnewbold bnewbold commented Dec 2, 2025

Closes: #1216

if !s.config.AllowInsecureHosts {
err = s.relay.HostChecker.CheckHost(ctx, hostURL)
} else {
hc := relay.NewHostClient("")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds simpler to set hc.Client = http.DefaultClient in NewRelay() if config.AllowInsecureHosts is set.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would impact all use of the HostChecker though. The current setup only allows the bypass when doing the request using admin authentication.

I flipped the ordering and added another admin boolean check to make it clearer to read and stricter in implementation.

Copy link
Contributor

@damz damz Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the code intelligence, relay.HostChecker is literally only used on that line, do you know of other users?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. Yeah, with the additional check on admin it makes sense 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But maybe use NewHostClient(s.config.UserAgent) like in NewRelay()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR starts using some of the account checking behavior: #1215. I guess that will probably not work with localhost stuff now that I think of it.

This is honestly a big messy tangle, I kind of want to just be secure all the time and not support the insecure/localhost mode at all.

@ThisIsMissEm
Copy link
Contributor

Oh neat! Thanks for this, took a little debugging yesterday to help the reporter figure out what was going wrong on this!

@ThisIsMissEm
Copy link
Contributor

The way I thought of handling this was like the safeFetch implementation in the atproto repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Relay refuses to connect to new localhost PDS over http

3 participants