Skip to content

parameterize entra_idp url#8491

Merged
sumit-bose merged 1 commit intoSSSD:masterfrom
ezrizhu:master
Apr 2, 2026
Merged

parameterize entra_idp url#8491
sumit-bose merged 1 commit intoSSSD:masterfrom
ezrizhu:master

Conversation

@ezrizhu
Copy link
Copy Markdown
Contributor

@ezrizhu ezrizhu commented Mar 3, 2026

fixes #8446

Copy link
Copy Markdown

@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 +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;
}
Copy link
Copy Markdown

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);
Copy link
Copy Markdown

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
Copy Markdown
Member

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

@ezrizhu
Copy link
Copy Markdown
Contributor 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
Copy Markdown
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
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wrong indentation.

@alexey-tikhonov
Copy link
Copy Markdown
Member

@ezrizhu, just a heads up: sssd-2-3 upstream release is coming, so if you need those patches there, could you please address @pbrezina comments?

@ezrizhu
Copy link
Copy Markdown
Contributor Author

ezrizhu commented Mar 25, 2026

Sounds good, will update PR shortly today or tomorrow.

@alexey-tikhonov alexey-tikhonov added the coverity Trigger a coverity scan label Mar 26, 2026
@alexey-tikhonov
Copy link
Copy Markdown
Member

Note: Covscan is green.

@alexey-tikhonov alexey-tikhonov removed the coverity Trigger a coverity scan label Mar 26, 2026
@sumit-bose
Copy link
Copy Markdown
Contributor

/gemini review

Copy link
Copy Markdown

@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 introduces the parse_base_url_from_idp_type function to extract and normalize base URLs from the idp_type string, enabling configurable API endpoints for Entra ID and Keycloak. The entra_id_lookup and keycloak_lookup functions were updated to utilize these dynamic base URLs. A critical issue was identified in the logic for stripping trailing slashes, which could incorrectly truncate URLs that only contain a scheme, such as "https://".

Copy link
Copy Markdown
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, thank you for the changes.

Can you squash it into a single commit and adhere to our commit template: https://github.com/SSSD/sssd/blob/master/.git-commit-template

Maybe even adding a :feature: release note to it (explained in the commit template).

Comment on lines +517 to +523
if (base_url == NULL) {
base_url = talloc_strdup(mem_ctx, "https://graph.microsoft.com/v1.0");
if (base_url == NULL) {
ret = ENOMEM;
goto done;
}
}
Copy link
Copy Markdown
Member

@pbrezina pbrezina Mar 26, 2026

Choose a reason for hiding this comment

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

I'd move this to entra_id_lookup.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
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, thank you. See one more minor thing inline.

Additionally, we need to rewrite the release note a little:

idp_type 
:feature: `idp_type` option allows entra_idp url to be specified if user is using a
  different microsoft entra endpoint.

Can you also update manual page saying it is not needed but possible? https://github.com/SSSD/sssd/blob/master/src/man/sssd-idp.5.xml#L62

Thank you.

Comment on lines +514 to +519
if (base_url == NULL) {
DEBUG(SSSDBG_OP_FAILURE, "Missing base URL in IdP type [%s].\n",
idp_type);
ret = EINVAL;
goto done;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I missed this one previously, sorry. Can you move it to keycloak_lookup?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@ezrizhu ezrizhu force-pushed the master branch 2 times, most recently from af4f7d6 to a12ebb0 Compare March 31, 2026 04:32
@ezrizhu ezrizhu requested a review from pbrezina March 31, 2026 04:54
Copy link
Copy Markdown
Contributor

@sumit-bose sumit-bose left a comment

Choose a reason for hiding this comment

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

Hi,

thank you, I have no further comments, ACK.

bye,
Sumit

@ezrizhu
Copy link
Copy Markdown
Contributor Author

ezrizhu commented Mar 31, 2026

I'll push the manpage updates sometime today aswell

edit: done

@sumit-bose
Copy link
Copy Markdown
Contributor

Hi,

thank you for updating the man page, looks good.

bye,
Sumit

Copy link
Copy Markdown
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.

Thank you for your changes. Ack.

@ezrizhu
Copy link
Copy Markdown
Contributor Author

ezrizhu commented Apr 1, 2026

Thanks for the reviews, the one CI failure appears to be unrelated(?)

Please let me know if anything else is needed on my end.

Have a good rest of your weeks

Creates a function to extract the idp url from idp_type instead of using
hardcoded entra url due to GCC High Entra instances using a different
url.

Resolves: SSSD#8446

idp_type
:feature: `idp_type` option allows entra_idp url to be specified if user is using a
  different microsoft entra endpoint.

Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
@sssd-bot
Copy link
Copy Markdown
Contributor

sssd-bot commented Apr 2, 2026

The pull request was accepted by @sumit-bose with the following PR CI status:


🟢 CodeQL (success)
🟢 osh-diff-scan:fedora-rawhide-x86_64:upstream (success)
🟢 rpm-build:centos-stream-10-x86_64:upstream (success)
🟢 rpm-build:fedora-42-x86_64:upstream (success)
🟢 rpm-build:fedora-43-x86_64:upstream (success)
🟢 rpm-build:fedora-44-x86_64:upstream (success)
🟢 rpm-build:fedora-rawhide-x86_64:upstream (success)
🟢 Analyze (target) / cppcheck (success)
🟢 Build / freebsd (success)
🟢 Build / make-distcheck (success)
🟢 ci / intgcheck (centos-10) (success)
🟢 ci / intgcheck (fedora-42) (success)
🟢 ci / intgcheck (fedora-43) (success)
🟢 ci / intgcheck (fedora-44) (success)
🟢 ci / intgcheck (fedora-45) (success)
🟢 ci / prepare (success)
🟢 ci / system (centos-10) (success)
🟢 ci / system (fedora-42) (success)
🟢 ci / system (fedora-43) (success)
🟢 ci / system (fedora-44) (success)
🟢 ci / system (fedora-45) (success)
➖ Coverity scan / coverity (skipped)
🟢 Static code analysis / codeql (success)
🟢 Static code analysis / pre-commit (success)
🟢 Static code analysis / python-system-tests (success)


There are unsuccessful or unfinished checks. Make sure that the failures are not related to this pull request before merging.

@sumit-bose sumit-bose merged commit 3bd74d9 into SSSD:master Apr 2, 2026
17 checks passed
@sumit-bose
Copy link
Copy Markdown
Contributor

Thanks for the reviews, the one CI failure appears to be unrelated(?)

Please let me know if anything else is needed on my end.

Have a good rest of your weeks

Thank you, no further steps are needed.

Have a good rest of your week as well.

bye,
Sumit

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

Labels

Accepted no-backport This should go to target branch only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

6 participants