Skip to content

oidc_child: Fix logic error and URL-encode short_name in Keycloak lookup#8950

Open
kkzhsh wants to merge 1 commit into
SSSD:masterfrom
kkzhsh:oidc
Open

oidc_child: Fix logic error and URL-encode short_name in Keycloak lookup#8950
kkzhsh wants to merge 1 commit into
SSSD:masterfrom
kkzhsh:oidc

Conversation

@kkzhsh

@kkzhsh kkzhsh commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Fixed a copy-paste logic error in the condition check and added URL encoding for the extracted short_name before using it in the Keycloak search query string.

:fixes: Fixed logic error and missing URL encoding in Keycloak group lookup that could produce invalid API requests.

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

Copy link
Copy Markdown

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 fixes a logical condition in keycloak_lookup when parsing group names, ensuring cases where the @ separator is missing or at the start of the input are correctly handled. The reviewer identified a security vulnerability where the extracted short_name is not URL-encoded before being used in the query string, which could lead to parameter injection or invalid URLs, and provided a code suggestion to resolve it.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

if (sep == NULL || sep == input) {
filter = talloc_asprintf(rest_ctx, "search=%s&exact=true&populateHierarchy=false&briefRepresentation=false", input_enc);
} else {
short_name = talloc_strndup(rest_ctx, input, sep - input);

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 extracted short_name is used directly in the Keycloak search filter query string without being URL-encoded. If the group name contains special characters (such as spaces, &, or #), this will result in an invalid URL or potentially parameter injection. We should URL-encode the short_name after duplicating it, similar to how input_enc is handled.

            char *short_name_raw = talloc_strndup(rest_ctx, input, sep - input);
            if (short_name_raw == NULL) {
                short_name = NULL;
            } else {
                short_name = url_encode_string(rest_ctx, short_name_raw);
                talloc_free(short_name_raw);
            }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi,

thank you for fixing the logic issues. The comment from Gemini is valid, would you like to add a fix for this as well?

bye,
Sumit

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.

ok. PR has been updated according to Gemini comment.

@kkzhsh kkzhsh changed the title oidc_child: Fix a logic error in Keycloak lookup oidc_child: Fix logic error and URL-encode short_name in Keycloak lookup Jul 16, 2026

@sumit-bose sumit-bose left a comment

Copy link
Copy Markdown
Contributor

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 fix and the updates, ACK.

The CI failures are not related imo.

bye,
Sumit

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants