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 frame ancestor configuration for web app to prevent clickjacking #2266

Closed
wants to merge 1 commit into from

Conversation

ariary
Copy link
Contributor

@ariary ariary commented Sep 6, 2021

Signed-off-by: ariary ariary9.2@hotmail.fr

Overview

Provide a way to configure the Content Security Policy frame-ancestor context to prevent clickjacking

What this PR does / why we need it

This PR enables the configuration of the Content-Security policy to prevent clickjacking. By filling dex configuration with the specific fields the application will send csp headers in responses defining the content security policy.

available CSP:
○ No domain could frame the content (recommended unless a specific need has been identified for framing.) DEFAULT
○ Only the current site could frame the content
○ Only certain site could frame the content (must specify the protocol)
○ No CSP (ie any domain could frame the content, INSECURE)

Special notes for your reviewer

The most critical endpoints for clickjacking is the /dex/auth one (as a user interaction is needed to provide credential) but by default it is a good point to apply the same policy for all endpoints

Does this PR introduce a user-facing change?

NONE

@sagikazarmark
Copy link
Member

@ariary thanks a lot for submitting this PR.

I have to admit, I'm not that familiar with CSP, but this looks mostly good. I'll let other maintainers jump in, maybe they are more familiar with CSP.

Also, can you please rebase your PR. CI wasn't triggered for some reason. Thanks!

Signed-off-by: ariary <ariary9.2@hotmail.fr>
@ariary
Copy link
Contributor Author

ariary commented Nov 9, 2021

@sagikazarmark rebase done! Waiting for other reviews hence ☺️

@justaugustus
Copy link
Member

justaugustus commented Nov 10, 2021

LGTM, but it would be worthwhile for @nabokihms to take a look before merging.

@nabokihms
Copy link
Member

nabokihms commented Nov 11, 2021

As for me, it does not look right to add more headers customization to Dex, besides the ones described in the oauth2 RFC. There are many options for CSP configuration (and for other security measurements) with myriads of use-cases that we will not be able to cover in Dex code.

Most of the time, we have a reverse proxy in front of Dex, e.g., ingress controllers in Kubernetes clusters or just Nginx installation for standalone deployments. This looks like the right place for adding headers modifications.

Anyway, I see no objections to merging this PR right now, but we definitely need to consider whether to accept headers modification settings in the future.

Copy link
Member

@justaugustus justaugustus left a comment

Choose a reason for hiding this comment

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

Thanks for the context, @nabokihms!
Approving based on your review.

@sagikazarmark sagikazarmark added this to the v2.31.0 milestone Nov 12, 2021
@sagikazarmark
Copy link
Member

Hm, I wonder if accepting this change is the right thing to do then. If we decide to remove it later, it's going to be harder to reason about.

I guess the alternative is providing sufficient documentation about configuring these headers.

I don't have a strong opinion on merging/rejecting this though. I'll leave the decision to you @nabokihms and @justaugustus

@sagikazarmark
Copy link
Member

We probably need this sooner or later, but we have to be careful about it, so moving to next release.

@sagikazarmark sagikazarmark modified the milestones: v2.31.0, v2.32.0 Feb 8, 2022
@nabokihms nabokihms removed their request for review March 3, 2022 19:08
@nabokihms nabokihms modified the milestones: v2.32.0, v2.33.0 May 30, 2022
@nabokihms nabokihms modified the milestones: v2.33.0, v2.34.0 Jul 26, 2022
@sagikazarmark sagikazarmark modified the milestones: v2.34.0, v2.35.0 Sep 14, 2022
@sagikazarmark
Copy link
Member

sagikazarmark commented Sep 14, 2022

I agree with @nabokihms: this would be better handled at ingress controllers/reverse proxies.

As a first step, I'll write some documentation to help with installation.

In the future, we might want to add a more general, http layer configuration (we do support a TLS server after all).

I'm going to leave this open for now (maybe we can still merge it before we find a more robust HTTP config solution).

@sagikazarmark sagikazarmark self-assigned this Sep 14, 2022
@sagikazarmark sagikazarmark modified the milestones: v2.35.0, v2.36.0 Sep 29, 2022
@FernandezBenjamin
Copy link

Hi,
We are facing the same issue and the frame ancestor configuration would be very helpful for our uses.
Is the merge planned for this pull request ?

Thanks a lot
Best Regards

@sagikazarmark sagikazarmark modified the milestones: v2.37.0, v2.38.0 May 12, 2023
@nabokihms nabokihms modified the milestones: v2.38.0, v2.39.0 Oct 24, 2023
@nabokihms
Copy link
Member

It should be fixed now starting from Dex v2.39.0. I'm closing this PR as superseded.

@nabokihms nabokihms closed this Mar 22, 2024
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.

5 participants