Skip to content

Commit

Permalink
security: removed snyk issues involving OIDC (#167)
Browse files Browse the repository at this point in the history
removed writing empty req.body to httpWriter in OIDC authentication.
modified ras.GenerateKey to use 2048 bit encryption in
cicd-integration/generate_pki.go
  • Loading branch information
pacificcode authored Aug 8, 2024
1 parent 2ac6fb3 commit 13fb517
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changes/unreleased/security-20240807-120631.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: security
body: |-
removed writing empty req.body to httpWriter in OIDC authentication.
modified ras.GenerateKey to use 2048 bit encryption in cicd-integration/generate_pki.go
time: 2024-08-07T12:06:31.546382-07:00
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,6 @@ snapcraft-login

# mac
.DS_Store

# snyk
.dccache
5 changes: 1 addition & 4 deletions auth/method_oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,8 @@ func (a *authenticator) buildOIDCParams(at AuthType, provider string, callback s
// handleOidcAuth handles OIDC and Thycotic One auths.
func handleOidcAuth(at AuthType, doneCh chan<- authResponse) http.HandlerFunc {
return func(w http.ResponseWriter, req *http.Request) {
b, err := io.ReadAll(req.Body)
_, err := io.ReadAll(req.Body)
if err != nil {
w.Write([]byte(err.Error()))
doneCh <- authResponse{err: fmt.Errorf("reading body: %w", err)}
}

Expand All @@ -116,14 +115,12 @@ func handleOidcAuth(at AuthType, doneCh chan<- authResponse) http.HandlerFunc {
doneCh <- authResponse{
err: errors.New("missing values in callback, authorization code is empty"),
}
w.Write(b)
return
}
if state == "" {
doneCh <- authResponse{
err: errors.New("missing values in callback, authorization state is empty"),
}
w.Write(b)
return
}

Expand Down
9 changes: 6 additions & 3 deletions cicd-integration/generate_pki.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ import (
"time"
)

const leafCommonName = "example.com"
const (
leafCommonName = "example.com"
rsaEncrypt = 2048
)

func generateRootWithPrivateKey() ([]byte, []byte, error) {
privateKey, publicKey := generateRSAKeyPair(2048)
privateKey, publicKey := generateRSAKeyPair(rsaEncrypt)
ca := &x509.Certificate{
DNSNames: []string{"thycotic.com"},
SerialNumber: big.NewInt(int64(mrand.Int31n(big.MaxExp))),
Expand Down Expand Up @@ -52,7 +55,7 @@ func generateRootWithPrivateKey() ([]byte, []byte, error) {
}

func generateCSR() ([]byte, error) {
keyBytes, _ := rsa.GenerateKey(rand.Reader, 1024)
keyBytes, _ := rsa.GenerateKey(rand.Reader, rsaEncrypt)

subj := pkix.Name{
CommonName: leafCommonName,
Expand Down

0 comments on commit 13fb517

Please sign in to comment.