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

Configurable webhook header filter #4290

Open
5 tasks done
K3das opened this issue Feb 4, 2025 · 9 comments · May be fixed by #4309
Open
5 tasks done

Configurable webhook header filter #4290

K3das opened this issue Feb 4, 2025 · 9 comments · May be fixed by #4309
Labels
feat New feature or request.

Comments

@K3das
Copy link
Contributor

K3das commented Feb 4, 2025

Preflight checklist

Ory Network Project

No response

Describe your problem

I talked about this a bit on slack, but the header filter implemented by #4048 is somewhat arbitrary and doesn't work for some configurations or use cases (for example, where you use x-forwarded-for instead of true-client-ip to get client IP, or if you need to process injected telemetry from a header).

Describe your ideal solution

Ideally there is a config value for allowed headers, possibly defaulting to the current list to avoid making significant changes.

Workarounds or alternatives

For getting the client IP, I've updated my proxy configuration to set True-Client-IP.

Version

v1.3.1

Additional Context

No response

@K3das K3das added the feat New feature or request. label Feb 4, 2025
@robert-sisutech
Copy link

robert-sisutech commented Feb 11, 2025

I'm on Kratos v.1.3.0.

I'm absolutely gutted that this header filtering was added without the possibility to add more headers to the allowlist in Kratos configuration. Recently updated Kratos to the latest version in our system and it broke some functionalities which relied on specific headers existing on the webhook requests as part of Kratos flows. Cannot downgrade as we need some latest Kratos features.
Requests to our system go through a reverse-proxy which decorates the request with some extra headers (ip address, ip country, plus some more implementation specific headers). I know we could transform the headers but the strict headers allowlist makes this almost impossible.

What was the benefit of strict allowlist for webhook request headers?
Ideally yes there would be a way to allow more headers than the current strict headers allowlist.

@aeneasr
Copy link
Member

aeneasr commented Feb 11, 2025

For getting the client IP, I've updated my proxy configuration to set True-Client-IP.

The workaround is a good option in my view.

@robert-sisutech is that workaround not working for you?

We have removed other headers due to security issues in our infra. At the moment there are no plans to change this

@K3das
Copy link
Contributor Author

K3das commented Feb 11, 2025

Is there any reason why a config option wouldn't work? This seems like a very instance-specific thing.

@aeneasr
Copy link
Member

aeneasr commented Feb 11, 2025

Not really (other than adding yet more config options), but it’s not a priority given that a workaround exists and we have no need for it!

@K3das
Copy link
Contributor Author

K3das commented Feb 12, 2025

@aeneasr would this be a per-webhook or instance-wide config? Doing it instance-wide would probably be a slightly easier implementation but I could imagine a scenario where someone wants to be selective about what hooks get what headers.

@robert-sisutech
Copy link

robert-sisutech commented Feb 12, 2025

@aeneasr we have like around 5 headers we require to be on the request and that we would need to be able to read in Kratos' webhook request handler.
Your suggestion is not a workaround for our usecase. Although hacky, yeah the True-Client-IP header is great and possible to do for us but we're missing bunch of other headers which we cannot re-assign to any of the headers in the strict allowlist.

Adding strict filtering of headers for everyone using Ory Kratos due to your infra's security concerns isn't a really thoughtful decision in my opinion. Many of us still need access to other headers thus why I and I imagine some more developers would want the headers allowlist to be configurable or at least it should be possible to disable the strict headers filtering.

@aeneasr
Copy link
Member

aeneasr commented Feb 12, 2025

@aeneasr we have like around 5 headers we require to be on the request and that we would need to be able to read in Kratos' webhook request handler. Your suggestion is not a workaround for our usecase. Although hacky, yeah the True-Client-IP header is great and possible to do for us but we're missing bunch of other headers which we cannot re-assign to any of the headers in the strict allowlist.

Adding strict filtering of headers for everyone using Ory Kratos due to your infra's security concerns isn't a really thoughtful decision in my opinion. Many of us still need access to other headers thus why I and I imagine some more developers would want the headers allowlist to be configurable or at least it should be possible to disable the strict headers filtering.

Did you see my last reply?

Regarding your message pre-edit: We are listening to OSS community demands but as you know running such a large project isn’t free and our priorities are with people who pay us to maintain and advance this project (otherwise it would be long dead). It’s even more frustrating when other companies use our stuff, demand a lot, make a lot of money with their customers, but don’t give back except frustrated messages. So please don’t get frustrated but stay constructive.

By the way, if you rely on that many headers, maybe transient payloads are a better option for you.

@aeneasr would this be a per-webhook or instance-wide config? Doing it instance-wide would probably be a slightly implementation but I could imagine a scenario where someone wants to be selective about what hooks get what headers.

Global should be fine, otherwise the config gets really convoluted. The biggest challenge is probably figuring out where to put the config key.

@robert-sisutech
Copy link

@aeneasr The aforementioned headers are something we don't have much control over. We could re-assign the headers but we cannot move them to transient payload while the request is in-flight. We don't add the headers ourself at the source of the request. The headers get added while the request is in flight in one part of our reverse-proxy/firewall/gateway of our infra. Transient payload is a good option if we can allow the data to be editable by end-user. In this case we don't want the end-user to have control of the data put in these headers so transient_payload unfortunately is not an option for us in this case. Transient payload however comes in very handy in some other flows we have.

I regret the tone in my pre-edit message. Edited it for a reason. I appreciate something like Ory Kratos exists and is open-source and available for everybody to use.

What would make the situation with strict headers allowlist better for some of us would be:

  • flag in configuration to disable strict header filtering altogether (easier to implement)
  • option in configuration to manually add more headers to the allowlist (bit more difficult to implement)

@aeneasr
Copy link
Member

aeneasr commented Feb 13, 2025

Apology accepted, no problem :)

I feel making the headers configurable strikes a balance between security and customizability and would not need recompilation in case more headers are added to the allow list

@K3das K3das linked a pull request Feb 14, 2025 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants