Skip to content
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

Add x-forwarded-for to PDS-proxied requests to entryway #3553

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

devinivy
Copy link
Collaborator

As advertised: adding x-forwarded-for to PDS-proxied requests to entryway.

Can get rid of some minor noise in review by ignoring whitespace changes.

Comment on lines +127 to +130
const result: T | HeadersParam = params ?? { headers: {} }
if (ip) {
result.headers['x-forwarded-for'] = ip
}
Copy link
Contributor

@matthieusieben matthieusieben Feb 18, 2025

Choose a reason for hiding this comment

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

Wouldn't it be more accurate (in terms of semantics of that header), and easier/efficient, to simply add the req.socket.remoteAddress to the already provided list of x-forwarded-for ? (req.ip is a getter which we could avoid calling by doing this)

Another option would be to use req.ips.join(', ') in order to reveal all the (untrusted) proxies the request went through. Again, just as a matter of respecting the semantics of that header.

The reason it might be relevant to keep all the forwarded IPs is in case of a bad actor using a public proxy service. We would log only the public proxy's ip, and discard the IP of the bad actor (assuming the public proxy properly generates the forwarded for header).

Copy link
Contributor

@matthieusieben matthieusieben left a comment

Choose a reason for hiding this comment

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

Looks like the catchall handler (pipethrough) does not apply this. Is this on purpose?

Comment on lines +32 to +38
await ctx
.serviceAuthHeaders(
recipientDid,
ctx.cfg.entryway.did,
ids.ComAtprotoAdminSendEmail,
)
.then((x) => forwardIp(req, x)),
Copy link
Contributor

@matthieusieben matthieusieben Feb 19, 2025

Choose a reason for hiding this comment

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

Would it make sense to add dedicated methods that do this?

  • ctx.entrywayServiceAuthHeaders(req, did, lxm)
  • ctx.entrywayPassthruAuthHeaders(req)

It makes it less likely, in the future, that someone forgets to forward the ip when proxying towards entryway, don't you think ?

Copy link
Contributor

@matthieusieben matthieusieben left a comment

Choose a reason for hiding this comment

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

It looks like you missed one/two spot:

await pds.ctx.serviceAuthHeaders(
alice,
'did:example:entryway',
'com.atproto.identity.updateHandle',
),

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.

2 participants