KEYCLOAK-14071 Valid Redirect URI for review apps (wildcard in hostname?)#8187
KEYCLOAK-14071 Valid Redirect URI for review apps (wildcard in hostname?)#8187DorianMazur wants to merge 4 commits intokeycloak:mainfrom
Conversation
|
Good job |
|
@DorianMazur Thanks for the PR. IMO this requires a bit more work to be secure by default and flexible at the same time. Few considerations regarding this PR:
IMO, the possible solution for this might be to add the option on the SecureClientUrisExecutor. The option might be like "Wildcards in Redirect URI" with the values like:
The alternative, which will be more flexible, is to use option like "Allowed Redirect URI regex pattern", which will allow more flexibility to specify both wildcards and protocol. This might be even better approach probably, however a bit harder for administrators to setup as not everyone is familiar with regexes. So we would need to document examples with the common use-cases (EG. Example for wildcards in the subdomain, wildcards at the end of the path etc). |
|
One thing to note when comparing this to the current capability, especially seen from a security angle, is that you can actually set just a lone wildcard currently, eg: valid_request_uri: "*". Ofcourse from a security point of view this is quite abhorrent, but it's just to say that while this flexible wildcard capability does add more refined ways to shoot oneself in the foot, the current approach has exactly the same potential for the same. And there are actually usecases (like those mentioned in the issue) that invite it. I believe the patch should considered as-is, perhaps with the addition of an interface warning when a wildcard is used anywhere in a redirect string. |
|
How about using |
|
Is this something that will be merged? Really need this implementation |
stianst
left a comment
There was a problem hiding this comment.
Although, I appreciate we already have support for wildcards in Keycloak we should not extend on it unless we make it configurable and can improve on recommended settings in production use-cases. To make it clear we have support for '*' as a redirect-uri in KC only as a convenience for development, and this should never be used in production.
In production wildcards should really be avoided completely, especially in the domain as that can lead to insecure setup and also bad practice in terms of multiple applications (as observed from the users perspective) using the same client.
What I'd like to see is client policies that allow setting what level of wildcards are supported. With Keycloak.X we have two different modes of the server, where we can by default allow wildcards in dev, and disallow in prod.
In it's current form I'm not okay with having this PR merged, to progress on this please open a discussion around it in GitHub Discussions.
|
I am closing for now. Anyone is welcome to open the discussions with more details. Please add the discussion link as a comment here to this PR when you do it. Bottom line is that we won't allow more wildcards by default, but we may need to drive this with client policies if better flexibility is needed (for example with wildcard in subdomains). |
|
I vote for reopening this issue. Why cant we implement like others already proposed: Is it just a question of security for the Keycloak team? I dont understand how such a feature would introduce any problems. As long as the wildcard is limited to the root domain foo.com |
|
For someone that uses deploy preview urls that are dynamically created for each pull request for the application, keycloak is rendered completely unuseable without this feature |
|
Wildcards in subdomains may be perfectly fine in some environments, but not in others. As previously mentioned we are happy to have this included, but not as a default. We are moving towards not allowing wildcards at all by default, and using client policies to opt-in to allow wildcards for all or some clients. |
|
For now you can use simple "*" for redirect uri instead of "https://*.review.example.com". It just works for me. |
|
I'm wondering what exactly is this attack vector that allows someone to add dns entries to match *.example.com, but prevents them from hijacking the foo.example.com record that's specified in your redirect URI? |
|
I think that for review deployments any kind of attack don't make sense, so i don't care about it. |
|
See here for a follow-up discussion on this topic: |
|
@jputney there are plenty of situations where a sub-domain is not fully owned by an individual application, and where subdomains are created dynamically on-behalf of other users (AWS for example). |
|
@navrocky |
At least "https://*.review.example.com" is something that is needed for every feature branch based test environment. |
|
I also support this for the reason @to-bee cites. |
|
Hi @stianst Real question: if this is a "terrible thing to use or advocate, and leads to a magnitude of vulnerabilities", why the simple |
https://issues.redhat.com/projects/KEYCLOAK/issues/KEYCLOAK-14071
Compare with wildcard algorithm based on https://www.geeksforgeeks.org/wildcard-pattern-matching
m = length of string, n = length of wildcard filter
Time complexity: O(m x n)
Auxillary space: O(m x n)