Skip to content

fix: Don't allow arbitrary redirects at login#4780

Merged
jannfis merged 4 commits intoargoproj:masterfrom
jannfis:fix/2707-any-redirect-uri
Nov 16, 2020
Merged

fix: Don't allow arbitrary redirects at login#4780
jannfis merged 4 commits intoargoproj:masterfrom
jannfis:fix/2707-any-redirect-uri

Conversation

@jannfis
Copy link
Member

@jannfis jannfis commented Nov 6, 2020

Fixes #2707

Check for validity of return_url query parameter at OIDC auth in /auth/login.

This change ensures that return_url is pointing to the URL given in the url (settings.URL) configuration, or to a path within that URL. For example, if url is https://localhost:4000/argocd, then the following values for return_url will be valid:

  • https://localhost:4000/argocd
  • https://localhost:4000/argocd/applications

while the following URLs will not be considered valid and HTTP request is canceled:

  • https://localhost:4000/applications
  • https://localhost:4000/argocd/../some/other/app
  • https://www.google.com

Refer to https://cwe.mitre.org/data/definitions/601.html and https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html for more details.

Signed-off-by: jannfis jann@mistrust.net

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • Optional. My organization is added to USERS.md.
  • I've signed the CLA and my build is green (troubleshooting builds).

Signed-off-by: jannfis <jann@mistrust.net>
Signed-off-by: jannfis <jann@mistrust.net>
returnURL := r.FormValue("return_url")
// Check if return_url is valid, otherwise abort processing (see #2707)
if !isValidRedirectURL(returnURL, []string{a.settings.URL}) {
http.Error(w, "Invalid return_url", http.StatusBadRequest)
Copy link
Member Author

Choose a reason for hiding this comment

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

I was unsure what HTTP response code to chose. I picked HTTP 400 Bad Request, because that's what we basically considered it to be

@codecov-io
Copy link

codecov-io commented Nov 6, 2020

Codecov Report

Merging #4780 (3b9c884) into master (3e19b2f) will increase coverage by 0.03%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4780      +/-   ##
==========================================
+ Coverage   41.19%   41.22%   +0.03%     
==========================================
  Files         127      127              
  Lines       17667    17688      +21     
==========================================
+ Hits         7278     7292      +14     
- Misses       9349     9354       +5     
- Partials     1040     1042       +2     
Impacted Files Coverage Δ
util/oidc/oidc.go 18.66% <66.66%> (+5.36%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3e19b2f...3b9c884. Read the comment docs.

Signed-off-by: jannfis <jann@mistrust.net>
@jannfis jannfis marked this pull request as ready for review November 6, 2020 15:22
@jessesuen jessesuen requested a review from alexmt November 6, 2020 22:10
Signed-off-by: jannfis <jann@mistrust.net>
@jannfis jannfis merged commit 762b33c into argoproj:master Nov 16, 2020
tjamet added a commit to tjamet/argo-cd that referenced this pull request Jul 6, 2023
With argoproj#4780, were introduced security measures to ensure the `return_url`
is pointing to the current ArgoCD instance.

In several occasions, an ArgoCD isntance could be exposed through
multiple network connections. Internal addresses and restricted public
addresses.

Currently, a single base URL can be configured in the the argocd
configmap, preventing from exposing ArgoCD on several access paths.

This change allows to define multiple hosts on which ArgoCD can be
exposed, keeping backward compatibility by adding a field
`additionalUrls` accepting a list of additional URLS on which argoCD can
be exposed

Fixes argoproj#5388

Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>
tjamet added a commit to tjamet/argo-cd that referenced this pull request Aug 22, 2023
With argoproj#4780, were introduced security measures to ensure the `return_url`
is pointing to the current ArgoCD instance.

In several occasions, an ArgoCD isntance could be exposed through
multiple network connections. Internal addresses and restricted public
addresses.

Currently, a single base URL can be configured in the the argocd
configmap, preventing from exposing ArgoCD on several access paths.

This change allows to define multiple hosts on which ArgoCD can be
exposed, keeping backward compatibility by adding a field
`additionalUrls` accepting a list of additional URLS on which argoCD can
be exposed

Fixes argoproj#5388

Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>
tjamet added a commit to tjamet/argo-cd that referenced this pull request Sep 8, 2023
With argoproj#4780, were introduced security measures to ensure the `return_url`
is pointing to the current ArgoCD instance.

In several occasions, an ArgoCD isntance could be exposed through
multiple network connections. Internal addresses and restricted public
addresses.

Currently, a single base URL can be configured in the the argocd
configmap, preventing from exposing ArgoCD on several access paths.

This change allows to define multiple hosts on which ArgoCD can be
exposed, keeping backward compatibility by adding a field
`additionalUrls` accepting a list of additional URLS on which argoCD can
be exposed

Fixes argoproj#5388

Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>
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.

Phishing attacks possible due to non-validated redirects

3 participants