Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: addressed greptile review

=920d4dfff472
diff --git a/backend/src/ee/routes/v1/saml-router.ts b/backend/src/ee/routes/v1/saml-router.ts
index adc0cc93a2..b860241ce8 100644
--- a/backend/src/ee/routes/v1/saml-router.ts
+++ b/backend/src/ee/routes/v1/saml-router.ts
@@ -354,12 +354,12 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
operationId: "samlAcs",
consumes: ["application/x-www-form-urlencoded"],
params: z.object({
- samlConfigId: z.string().trim()
+ samlConfigId: z.string().trim().describe(SamlSso.ACS.samlConfigId)
}),
// Unbounded on purpose: passport reads the body in preValidation, before this schema runs.
body: z.object({
- SAMLResponse: z.string().optional(),
- RelayState: z.string().optional()
+ SAMLResponse: z.string().optional().describe(SamlSso.ACS.SAMLResponse),
+ RelayState: z.string().optional().describe(SamlSso.ACS.RelayState)
})
},
preValidation: passport.authenticate(
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index ae0c819636..d8f014b536 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -4093,6 +4093,12 @@ export const SamlSso = {
cert: "The certificate to use for SAML authentication.",
enableGroupSync:
"Whether to enable automatic synchronization of group memberships from the SAML provider to Infisical groups."
+ },
+ ACS: {
+ samlConfigId: "The ID of the SAML configuration the response is for.",
+ SAMLResponse: "The base64-encoded SAML response the identity provider posted through the browser.",
+ RelayState:
+ "The RelayState Infisical sent with the authentication request, returned unchanged by the identity provider."
}
};
diff --git a/tests/clients/api/api.gen.go b/tests/clients/api/api.gen.go
index d2c6442a34..3241f0004c 100644
--- a/tests/clients/api/api.gen.go
+++ b/tests/clients/api/api.gen.go
@@ -11746,7 +11746,10 @@ type RedirectSamlByConfigIdParams struct {
// SamlAcsFormdataBody defines parameters for SamlAcs.
type SamlAcsFormdataBody struct {
- RelayState *string `form:"RelayState,omitempty" json:"RelayState,omitempty"`
+ // RelayState The RelayState Infisical sent with the authentication request, returned unchanged by the identity provider.
+ RelayState *string `form:"RelayState,omitempty" json:"RelayState,omitempty"`
+
+ // SAMLResponse The base64-encoded SAML response the identity provider posted through the browser.
SAMLResponse *string `form:"SAMLResponse,omitempty" json:"SAMLResponse,omitempty"`
}
diff --git a/tests/suites/sso/saml/assertion_test.go b/tests/suites/sso/saml/assertion_test.go
index e885a2c1c2..e9d2de30f7 100644
--- a/tests/suites/sso/saml/assertion_test.go
+++ b/tests/suites/sso/saml/assertion_test.go
@@ -9,6 +9,7 @@ import (
"github.com/Infisical/infisical/tests/fakes/samlidp"
"github.com/Infisical/infisical/tests/harness"
"github.com/Infisical/infisical/tests/internal/id"
+ "github.com/Infisical/infisical/tests/internal/spec"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
)
@@ -60,13 +61,18 @@ func TestSAMLAssertion_Rejected(t *testing.T) {
reason: "Responder error",
},
{
- name: "should reject the response when email or first name is missing",
+ name: "should reject the response when the email is missing",
corrupt: func(_ *testing.T, _ *sso, r *samlidp.Response) {
r.NameID = r.Email
r.Email = ""
},
reason: "Missing email or first name",
},
+ {
+ name: "should reject the response when the first name is missing",
+ corrupt: func(_ *testing.T, _ *sso, r *samlidp.Response) { r.FirstName = "" },
+ reason: "Missing email or first name",
+ },
}
for _, c := range cases {
@@ -91,6 +97,28 @@ func TestSAMLAssertion_Rejected(t *testing.T) {
})
}
+ t.Run("should reject the response when the assertion alone is signed and altered after signing", func(t *testing.T) {
+ t.Parallel()
+ spec.Why(t, "Azure accepts an unsigned outer response, so the assertion's own signature is the only check left.")
+
+ // Setup
+ s := setup(t, azure)
+ alice := s.person()
+ alice.Signing = samlidp.SignAssertionOnly
+ alice.AlterSigned = func(xml string) string {
+ return strings.ReplaceAll(xml, alice.Email, s.tn.Email("admin"))
+ }
+
+ // Action
+ res := s.idpLogin(t, alice)
+
+ // Assert
+ require.Equal(t, http.StatusBadRequest, res.StatusCode())
+ require.Contains(t, string(res.Body), "Saml authentication failed. Invalid signature")
+ require.Nil(t, refreshCookie(res))
+ require.Nil(t, membershipOf(t, s.tn, alice.Email))
+ })
+
t.Run("should reject the response when the config id does not exist", func(t *testing.T) {
t.Parallel()