Skip to content

OIDC_CHILD: a couple of cosmetic fixes#8172

Merged
sumit-bose merged 2 commits intoSSSD:masterfrom
alexey-tikhonov:oidc-bzero
Nov 6, 2025
Merged

OIDC_CHILD: a couple of cosmetic fixes#8172
sumit-bose merged 2 commits intoSSSD:masterfrom
alexey-tikhonov:oidc-bzero

Conversation

@alexey-tikhonov
Copy link
Member

  • fixes compilation warning
  • makes consistent usage of sss_erase_mem_securely()

@alexey-tikhonov alexey-tikhonov added no-backport This should go to target branch only. Trivial A single reviewer is sufficient to review the Pull Request labels Nov 6, 2025
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 introduces a couple of cosmetic fixes, mainly to ensure consistent use of sss_erase_mem_securely() for clearing sensitive data and to fix a compilation warning by initializing a variable. The changes are good for code consistency and correctness.

However, I've noticed a minor security issue related to clearing secrets. When clearing the client secret strings, strlen() is used to determine the size, which omits the null-terminator. This means the allocated buffer is not fully cleared, potentially leaking the length of the secret. I've added suggestions to include the null-terminator in the memory clearing operation.

free(opts->scope);
if (opts->client_secret != NULL) {
explicit_bzero(opts->client_secret, strlen(opts->client_secret));
sss_erase_mem_securely(opts->client_secret, strlen(opts->client_secret));

Choose a reason for hiding this comment

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

high

When clearing the secret, strlen() is used for the size. This does not include the terminating null byte. As opts->client_secret was allocated using strdup, the allocated size is strlen(opts->client_secret) + 1. By not clearing the null byte, you are not clearing the entire allocated memory, which could potentially leak the length of the secret. It's better to clear the entire buffer, including the null terminator.

        sss_erase_mem_securely(opts->client_secret, strlen(opts->client_secret) + 1);

Copy link
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,

I agree with the changes, ACK.

About Gemini's comment, I think it has a point about potentially leaking the size of the secret (this would be true even if we would overwrite the final \0 with a \0). If we are concerned we might be able to fix this by allocating larger buffers, e.g. 1k or 4k and zero the whole buffer after using the secret.

bye,
Sumit

@sumit-bose sumit-bose added coverity Trigger a coverity scan Accepted and removed coverity Trigger a coverity scan labels Nov 6, 2025
This fixes
```
../src/oidc_child/oidc_child.c: In function ‘main’:
../src/oidc_child/oidc_child.c:682:17: warning: ‘client_secret_tmp’ may be used uninitialized [-Wmaybe-uninitialized]
  682 |                 explicit_bzero(client_secret_tmp, strlen(client_secret_tmp));
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/oidc_child/oidc_child.c:578:11: note: ‘client_secret_tmp’ was declared here
  578 |     char *client_secret_tmp;
      |           ^~~~~~~~~~~~~~~~~
```

Warning is a false positive but cheap to "fix".

Reviewed-by: Sumit Bose <sbose@redhat.com>
instead of `explicit_bzero()` as the latter might be unavaialble.

Reviewed-by: Sumit Bose <sbose@redhat.com>
@sssd-bot
Copy link
Contributor

sssd-bot commented Nov 6, 2025

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


🟢 CodeFactor (success)
🟢 CodeQL (success)
NEUTRAL osh-diff-scan:fedora-rawhide-x86_64:upstream (neutral)
🟢 rpm-build:centos-stream-10-x86_64:upstream (success)
🟢 rpm-build:fedora-41-x86_64:upstream (success)
🟢 rpm-build:fedora-42-x86_64:upstream (success)
🟢 rpm-build:fedora-43-x86_64:upstream (success)
🟢 rpm-build:fedora-rawhide-x86_64:upstream (success)
🟢 Analyze (target) / All tests are successful (success)
🟢 Analyze (target) / cppcheck (success)
🟢 Build / freebsd (success)
🟢 Build / make-distcheck (success)
🟢 ci / All tests are successful (success)
🟢 ci / intgcheck (centos-10) (success)
🟢 ci / intgcheck (fedora-41) (success)
🟢 ci / intgcheck (fedora-42) (success)
🟢 ci / intgcheck (fedora-43) (success)
🟢 ci / intgcheck (fedora-44) (success)
🟢 ci / prepare (success)
🟢 ci / system (centos-10) (success)
🟢 ci / system (fedora-41) (success)
🟢 ci / system (fedora-42) (success)
🟢 ci / system (fedora-43) (success)
🟢 ci / system (fedora-44) (success)
➖ Coverity scan / coverity (skipped)
🟢 Static code analysis / All tests are successful (success)
🟢 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 9c13976 into SSSD:master Nov 6, 2025
20 of 25 checks passed
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. Trivial A single reviewer is sufficient to review the Pull Request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants