From 48e72eb4599189e85f32503f4d9cce5707ae7874 Mon Sep 17 00:00:00 2001 From: kippmorris7 Date: Mon, 10 Jul 2023 10:55:18 -0500 Subject: [PATCH] Add `Cache-Control: private, no-store` HTTP header to server endpoints that respond with sensitive info. Fixes #793 --- authority/admin/api/provisioner.go | 7 +++++++ authority/admin/api/webhook.go | 3 +++ scep/api/api.go | 1 + 3 files changed, 11 insertions(+) diff --git a/authority/admin/api/provisioner.go b/authority/admin/api/provisioner.go index c584361bd7..41641324b3 100644 --- a/authority/admin/api/provisioner.go +++ b/authority/admin/api/provisioner.go @@ -55,6 +55,8 @@ func GetProvisioner(w http.ResponseWriter, r *http.Request) { render.Error(w, err) return } + + w.Header().Set("Cache-Control", "private, no-store") render.ProtoJSON(w, prov) } @@ -72,6 +74,7 @@ func GetProvisioners(w http.ResponseWriter, r *http.Request) { render.Error(w, errs.InternalServerErr(err)) return } + render.JSON(w, &GetProvisionersResponse{ Provisioners: p, NextCursor: next, @@ -102,6 +105,8 @@ func CreateProvisioner(w http.ResponseWriter, r *http.Request) { render.Error(w, admin.WrapErrorISE(err, "error storing provisioner %s", prov.Name)) return } + + w.Header().Set("Cache-Control", "private, no-store") render.ProtoJSONStatus(w, prov, http.StatusCreated) } @@ -198,6 +203,8 @@ func UpdateProvisioner(w http.ResponseWriter, r *http.Request) { render.Error(w, err) return } + + w.Header().Set("Cache-Control", "private, no-store") render.ProtoJSON(w, nu) } diff --git a/authority/admin/api/webhook.go b/authority/admin/api/webhook.go index 3939d55e71..5b48a872d7 100644 --- a/authority/admin/api/webhook.go +++ b/authority/admin/api/webhook.go @@ -127,6 +127,7 @@ func (war *webhookAdminResponder) CreateProvisionerWebhook(w http.ResponseWriter return } + w.Header().Set("Cache-Control", "private, no-store") render.ProtoJSONStatus(w, newWebhook, http.StatusCreated) } @@ -231,5 +232,7 @@ func (war *webhookAdminResponder) UpdateProvisionerWebhook(w http.ResponseWriter Auth: newWebhook.Auth, DisableTlsClientAuth: newWebhook.DisableTlsClientAuth, } + + w.Header().Set("Cache-Control", "private, no-store") render.ProtoJSONStatus(w, whResponse, http.StatusCreated) } diff --git a/scep/api/api.go b/scep/api/api.go index 98da818be0..3462750d6c 100644 --- a/scep/api/api.go +++ b/scep/api/api.go @@ -359,6 +359,7 @@ func writeResponse(w http.ResponseWriter, res Response) { } w.Header().Set("Content-Type", contentHeader(res)) + w.Header().Set("Cache-Control", "private, no-store") _, _ = w.Write(res.Data) }