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

Improve Security Headers #9549

Closed
mraible opened this issue Apr 10, 2019 · 10 comments · Fixed by #9834
Closed

Improve Security Headers #9549

mraible opened this issue Apr 10, 2019 · 10 comments · Fixed by #9834
Assignees
Milestone

Comments

@mraible
Copy link
Contributor

mraible commented Apr 10, 2019

Overview of the feature request

We should improve our security headers to show we care about security.

jhipster.tech gets an F: https://securityheaders.com/?q=jhipster.tech&followRedirects=on
21-points.com gets a C: https://securityheaders.com/?q=21-points.com&followRedirects=on

In my experience with raibledesigns.com, a lot of the headers can be configured at the server level (rather than the app level), so it might just be a matter of documentation.

raibledesigns.com gets an A: https://securityheaders.com/?q=raibledesigns.com&followRedirects=on

Motivation for or Use Case

To show we care about security on the JHipster project.

Related: You can configure a Content Security Policy with Spring Security.

@atomfrede
Copy link
Member

Can we do much about jhipster.tech as it is hosted by github pages? Agree for our generated apps.

@atomfrede
Copy link
Member

@jhipster/developers Did we do anything about the headers for our generated apps already?

@PierreBesson
Copy link
Contributor

For www.jhipster.tech, it is served by Github Pages so I'm not sure we can do much. However for start.jhipster.tech, it's a JHipster app so we should be setting the CSP headers to improve security.

@PierreBesson
Copy link
Contributor

We should set all security headers by default and document them on a special page. The Spring Security docs, document them well: https://docs.spring.io/spring-security/site/docs/5.2.x/reference/html5/#default-security-headers-2

However this might impact the development experience, @mraible what do you think ?

@mraible
Copy link
Contributor Author

mraible commented Apr 30, 2019

It'd be cool to write some documentation on how to get from having a C to an A. I don't care if it's Heroku or someone else, but it'd be similar to https://developer.okta.com/blog/2019/04/11/site-security-cloudflare-netlify.

@atomfrede
Copy link
Member

atomfrede commented May 31, 2019

I will work on that. I propose to deny the page to be framed (or same origin) currently we do not send any information about that. Furthermore I would set the referrer policy to strict-origin-when-cross-origin.

For the headers feature-policy and content-security I think we should document that, as they are highly specific imho. For jhipster online we should set all headers with the features we want to allow. I can also do that.
Edit: We can set default-src 'self' for content-security which seems to be a reasonable default.

@jhipster/developers We could also set a very restrictive feature-policy (e.g. deny all features for example or only allow fullscreen).

Finally it looks like this:
Before:

Screenshot_2019-05-31 Scan results for https gradleheroku herokuapp com

After:

Screenshot_2019-05-31 Scan results for https gradleheroku herokuapp com-1

@atomfrede atomfrede self-assigned this May 31, 2019
@atomfrede
Copy link
Member

We need to set both unsafe-inline and unsafe-eval for the script sources in the content-security header, which reduces our rating to A. It seems angular or some plugin uses inline or eval somewhere.

What do you think? Leave the content-security header or set it with some "insecure" settings? https://securityheaders.com/?q=https%3A%2F%2Fgradleheroku.herokuapp.com%2F&followRedirects=on

atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue May 31, 2019
by setting conten-security and feature policy and deny embedding in an iFrame

closes jhipster#9549
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Jun 7, 2019
by setting conten-security and feature policy and deny embedding in an iFrame

closes jhipster#9549
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Jun 7, 2019
by setting conten-security and feature policy and deny embedding in an iFrame

closes jhipster#9549
@pascalgrimaud pascalgrimaud added this to the 6.1.0 milestone Jun 7, 2019
@SudharakaP
Copy link
Member

SudharakaP commented Aug 15, 2019

With reference to https://stackoverflow.com/questions/57500340/jhipster-doesnt-open-file-uploaded/57505766#57505766 and #10227. Maybe we need to add information about adding exceptions to content security policy in our documentation? I can add this if you like. 😄

@atomfrede
Copy link
Member

atomfrede commented Aug 15, 2019 via email

@gmarziou
Copy link
Contributor

@atomfrede I fully agree with you and no need to open a new bug, just re-open #10227

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

Successfully merging a pull request may close this issue.

6 participants