Skip to content

parameterize entra_idp url#8491

Open
ezrizhu wants to merge 1 commit intoSSSD:masterfrom
ezrizhu:master
Open

parameterize entra_idp url#8491
ezrizhu wants to merge 1 commit intoSSSD:masterfrom
ezrizhu:master

Conversation

@ezrizhu
Copy link

@ezrizhu ezrizhu commented Mar 3, 2026

fixes #8446

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request parameterizes the Entra IDP URL, allowing it to be configured instead of being hardcoded. However, the current implementation introduces significant security risks, including the use of unencrypted HTTP which can lead to sensitive bearer token leakage, and vulnerability to OData injection due to improper escaping of user-supplied input in filter constructions. Additionally, a critical type safety issue exists where a constant string is assigned to a non-constant pointer, potentially causing a crash. These issues should be addressed by enforcing HTTPS, implementing proper sanitization for OData filters, and safely duplicating strings to resolve the type safety problem.

Comment on lines +76 to +77
base_url = default_base_url;
}

Choose a reason for hiding this comment

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

critical

Assigning a const char * (string literal) to a char * is a C language violation that can lead to undefined behavior, including crashes, if the string is later modified. To ensure type safety, you should duplicate the constant string into a mutable buffer and check for allocation failure.

        base_url = talloc_strdup(mem_ctx, default_base_url);
        if (base_url == NULL) {
            return ENOMEM;
        }
    }

Copy link
Author

@ezrizhu ezrizhu Mar 4, 2026

Choose a reason for hiding this comment

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

done

Comment on lines +66 to +70
if (*base_url == '\0' || strncasecmp(base_url, "http", 4) != 0) {
DEBUG(SSSDBG_OP_FAILURE, "Colon supplied in %s but no url supplied.\n",
idp_type);
return EINVAL;
}

Choose a reason for hiding this comment

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

security-high high

The base_url override allows the use of unencrypted HTTP (e.g., entra_id:http://...). When an HTTP URL is provided, the bearer_token (a sensitive credential) is transmitted in cleartext over the network. For a cloud service like Entra ID (Microsoft Graph), there is rarely a legitimate reason to use plain HTTP, and allowing it exposes the system to credential theft via man-in-the-middle (MITM) attacks. The code should enforce the use of HTTPS for the base URL.

case GET_USER:
case GET_USER_GROUPS:
uri = talloc_asprintf(rest_ctx, "https://graph.microsoft.com/v1.0/users?$filter=%s", filter_enc);
uri = talloc_asprintf(rest_ctx, "%s/users?$filter=%s", base_url, filter_enc);

Choose a reason for hiding this comment

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

security-high high

The input variable, which contains user-supplied data (such as a username or group name), is used to construct OData filter strings (e.g., at lines 84, 87, 95, 102, 105) without any sanitization or escaping of single quotes. Although the resulting filter is later URL-encoded, the OData logic itself remains vulnerable. An attacker can provide a crafted input containing single quotes (e.g., user') or (1 eq 1) to break out of the filter's quoting and inject arbitrary OData expressions. This could allow an attacker to manipulate identity lookups, potentially leading to unauthorized access or privilege escalation if the system relies on the lookup results for authorization decisions.

@alexey-tikhonov
Copy link
Member

Is this ready for review or do you plan to work more on this?

@ezrizhu
Copy link
Author

ezrizhu commented Mar 4, 2026

pretty much ready besides some docs additions, pending CI fixes

@ezrizhu ezrizhu marked this pull request as ready for review March 4, 2026 16:13
@alexey-tikhonov alexey-tikhonov added Waiting for review no-backport This should go to target branch only. labels Mar 5, 2026
Copy link
Member

@pbrezina pbrezina left a comment

Choose a reason for hiding this comment

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

Hi, would you mind refactoring the code a bit? The keycloak and entraid functions currently take idp_type parameter that was used only in keycloak to get the base url, the same you do in entraid_lookup now.

It would be nice if you could write a separate function to parse the idp_type into base_url, call this function from oidc_get_id and provide base_url as parameter to the lookup functions (NULL means use default value (entryid) or error out (keycloak)).

"https://graph.microsoft.com/v1.0/users/%s/getMemberGroups",
obj_id);
uri = talloc_asprintf(rest_ctx, "%s/users/%s/getMemberGroups",
base_url, obj_id);
Copy link
Member

Choose a reason for hiding this comment

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

Wrong indentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-backport This should go to target branch only. Waiting for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

oidc/entra hardcoded to graph.microsoft.com in 4 places

4 participants