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

feat(ui): Enable CSP, HSTS, X-Frame-Options. Fixes #2760, #1376, #2761 #2971

Merged
merged 3 commits into from
May 13, 2020

Conversation

alexec
Copy link
Contributor

@alexec alexec commented May 7, 2020

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this is a chore.
  • The title of the PR is (a) conventional, (b) states what changed, and (c) suffixes the related issues number. E.g. "fix(controller): Updates such and such. Fixes #1234".
  • I've signed the CLA.
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My builds are green. Try syncing with master if they are not.
  • My organization is added to USERS.md.

Fixes #2760
Fixes #1376
Fixes #2761

@alexec alexec added the type/security Security related label May 7, 2020
@alexec alexec added this to the v2.10 milestone May 7, 2020
@alexec alexec changed the title feat(ui) Enable CSP, HSTS, X-Frame-Options. Fixes #2760, #1376, #2761 feat(ui): Enable CSP, HSTS, X-Frame-Options. Fixes #2760, #1376, #2761 May 7, 2020
@alexec alexec marked this pull request as ready for review May 7, 2020 16:37
@alexec alexec requested a review from alexmt May 8, 2020 18:08
@alexec
Copy link
Contributor Author

alexec commented May 8, 2020

@alexmt can I please request your review on these changes?
@jannfis you might have 2-cents on this maybe please?

Copy link
Member

@jannfis jannfis left a comment

Choose a reason for hiding this comment

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

Hi @alexec, please see my review comment.

@@ -26,6 +27,12 @@ func (s *FilesServer) ServerFiles(w http.ResponseWriter, r *http.Request) {
w = &responseRewriter{ResponseWriter: w, old: []byte(`<base href="/">`), new: []byte(fmt.Sprintf(`<base href="%s">`, s.baseHRef))}
}

w.Header().Set("X-Frame-Options", "DENY")
w.Header().Set("Content-Security-Policy", "default-src 'self' 'unsafe-inline'")
if s.secure {
Copy link
Member

Choose a reason for hiding this comment

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

IMHO, HSTS should be set from the final endpoint to the client (i.e. the LB or Ingress), because of several reasons. For one, once set, the browser will not access the URL on http endpoint anymore but will restrict to using https connection. Might lead to edge-case problems, i.e. Client -> (http) -> LB and/or Ingress -> (https) -> Argo)

But the more obvious reason might be, that the connection is Client -> (https) -> LB and/or Ingress -> (http) -> Argo). In this case, the HSTS header would not be set (because Argo server is serving plain HTTP), and then this might have no effect at all.

I think a better solution would be to document that users should set HSTS header on their Load Balancer or Ingress, if they want it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point - and you can front this with HTTP LB, in which case you would never want HSTS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I note your second case cannot apply - if we serve on HTTP - this flag won't be added - but I think we should make it optional - default on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, so new logic is this - --hsts is on by default - but only effected if --secure

@sonarqubecloud
Copy link

sonarqubecloud bot commented May 8, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@alexec alexec requested a review from sarabala1979 May 12, 2020 22:08
Copy link
Member

@sarabala1979 sarabala1979 left a comment

Choose a reason for hiding this comment

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

LGTM. I didn't test it. I hope you will test it.

@alexec
Copy link
Contributor Author

alexec commented May 13, 2020

LGTM. I didn't test it. I hope you will test it.

You should hope I have already tested it! Which I have.

@alexec alexec merged commit 9f86a4e into argoproj:master May 13, 2020
@alexec alexec deleted the feat-csp branch May 13, 2020 15:58
@alexec alexec modified the milestones: v2.10, v2.9 May 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants