CVE-2022-29164 (Go, published 2022-05-06T00:15Z)
Description: value: Argo Workflows is an open source container-native workflow engine for orchestrating parallel jobs on Kubernetes. In affected versions an attacker can create a workflow which produces a HTML artifact containing an HTML file that contains a script which uses XHR calls to interact with the Argo Server API. The attacker emails the deep-link to the artifact to their victim. The victim opens the link, the script starts running. As the script has access to the Argo Server API (as the victim), so may read information about the victim’s workflows, or create and delete workflows. Note the attacker must be an insider: they must have access to the same cluster as the victim and must already be able to run their own workflows. The attacker must have an understanding of the victim’s system. We have seen no evidence of this in the wild. We urge all users to upgrade to the fixed versions.
Severity: MEDIUM (CVSS v3 base score: 7.1)
Weakness: NVD-CWE-noinfo \u2014 Insufficient Information
There is insufficient information about the issue to classify it; details are unkown or unspecified.
Repository: https://github.com/argoproj/argo-workflows
Files changed:
server/apiserver/argoserver.go
server/artifacts/artifact_server.go
test/e2e/argo_server_test.go
Commit message: fix: Added artifact Content-Security-Policy (#8585)

Signed-off-by: Alex Collins <alex_collins@intuit.com>

Vulnerable code:
	mux.HandleFunc("/artifacts/", artifactServer.GetOutputArtifact)
	mux.HandleFunc("/input-artifacts/", artifactServer.GetInputArtifact)
	mux.HandleFunc("/artifacts-by-uid/", artifactServer.GetOutputArtifactByUID)
	mux.HandleFunc("/input-artifacts-by-uid/", artifactServer.GetInputArtifactByUID)
	mux.HandleFunc("/artifact-files/", artifactServer.GetArtifactFile)

Fixed code:

	// emergency environment variable that allows you to disable the artifact service in case of problems
	if os.Getenv("ARGO_ARTIFACT_SERVER") != "false" {
		mux.HandleFunc("/artifacts/", artifactServer.GetOutputArtifact)
		mux.HandleFunc("/input-artifacts/", artifactServer.GetInputArtifact)
		mux.HandleFunc("/artifacts-by-uid/", artifactServer.GetOutputArtifactByUID)
		mux.HandleFunc("/input-artifacts-by-uid/", artifactServer.GetInputArtifactByUID)
		mux.HandleFunc("/artifact-files/", artifactServer.GetArtifactFile)
	}
	"k8s.io/utils/env"
	w.Header().Add("Content-Security-Policy", env.GetString("ARGO_ARTIFACT_CONTENT_SECURITY_POLICY", "sandbox; base-uri 'none'; default-src 'none'; img-src 'self'; style-src 'self'"))
	w.Header().Add("X-Frame-Options", env.GetString("ARGO_ARTIFACT_X_FRAME_OPTIONS", "SAMEORIGIN"))
		resp.Header("Content-Security-Policy").
			Equal("sandbox; base-uri 'none'; default-src 'none'; img-src 'self'; style-src 'self'") // MSB

		resp.Header("X-Frame-Options").
			Equal("SAMEORIGIN")
		resp.Header("Content-Security-Policy").
			Equal("sandbox; base-uri 'none'; default-src 'none'; img-src 'self'; style-src 'self'") // MSB

		resp.Header("X-Frame-Options").
			Equal("SAMEORIGIN")
		resp.Header("Content-Security-Policy").
			Equal("sandbox; base-uri 'none'; default-src 'none'; img-src 'self'; style-src 'self'") // MSB

		resp.Header("X-Frame-Options").
			Equal("SAMEORIGIN")