Skip to content

Changes around FILE:/DIR: ccache checks#8344

Merged
alexey-tikhonov merged 5 commits intoSSSD:masterfrom
alexey-tikhonov:cc-setup
Jan 13, 2026
Merged

Changes around FILE:/DIR: ccache checks#8344
alexey-tikhonov merged 5 commits intoSSSD:masterfrom
alexey-tikhonov:cc-setup

Conversation

@alexey-tikhonov
Copy link
Member

  • only perform those operations if capabilities to manipulate ccache are set in general
  • use ruid/rgid instead of CAP_DAC_READ_SEARCH
  • perform those operations doesn't matter what cmd is to cover the case when a single execution of 'krb5_child'
    handles both PREUATH and AUTH

Resolves: #8331

@alexey-tikhonov alexey-tikhonov added the no-backport This should go to target branch only. label Jan 9, 2026
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 refactors the ccache checking logic for FILE: and DIR: type ccaches. The changes are a good improvement, especially the move from using CAP_DAC_READ_SEARCH to switching to the user's UID/GID for permission checks, which enhances security by reducing the process's privileges. The logic is also updated to perform these checks regardless of the command type, which correctly handles more complex authentication flows. I've found one minor issue with an outdated debug message that should be corrected for consistency and to avoid confusion during future debugging.

@alexey-tikhonov alexey-tikhonov force-pushed the cc-setup branch 3 times, most recently from ad160b2 to 7177266 Compare January 9, 2026 16:15
@alexey-tikhonov
Copy link
Member Author

/gemini review

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 refactors the ccache handling logic in krb5_child. The changes are well-aligned with the goals stated in the description.

The removal of sss_krb5_precheck_ccache simplifies the code by delegating permission checks to the OS during ccache creation, which is a sound approach. This also removes the need for CAP_DAC_READ_SEARCH for this purpose.

The logic for reusing an old ccache is now consolidated into the new k5c_ccache_check function. The call to this function is now correctly conditioned on the presence of setid capabilities and is no longer skipped during pre-authentication, which is a good improvement.

Finally, replacing sss_set_cap_effective(..., false) with sss_drop_cap(...) is a good security hardening measure, as it drops capabilities from all sets, not just the effective set.

Overall, the changes are positive and improve the correctness and security of the code.

@alexey-tikhonov alexey-tikhonov added the coverity Trigger a coverity scan label Jan 9, 2026
@alexey-tikhonov
Copy link
Member Author

Note: Covscan is green.

* this currently use 'CAP_DAC_READ_SEARCH'.
* Cache files are not needed during preauth. */
if (kr->pd->cmd != SSS_PAM_PREAUTH) {
if (kr->krb5_child_has_setid_caps && (kr->pd->cmd != SSS_PAM_PREAUTH)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi,

do I understand correctly that if SSSD is "classically" build and configured to as root krb5_child will automatically have all needed capabilities so that kr->krb5_child_has_setid_caps is true?

bye,
Sumit

Copy link
Member Author

Choose a reason for hiding this comment

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

If "classically" means --with-sssd-user=root then difference vs --with-sssd-user=sssd in current 'master' branch is negligible.

In all cases service configuration file has:

SecureBits=noroot noroot-locked

so no process will gain any capabilities "automatically" but will rely on "file capabilities" of corresponding binaries, limited by a
capabilities = CapabilityBoundingSet= CAP_SETGID CAP_SETUID CAP_DAC_READ_SEARCH

But I must admit we do not test building --with-sssd-user=root, PR CI only has limited testing coverage for "--with-sssd-user=sssd but run under root".

Copy link
Member Author

Choose a reason for hiding this comment

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

But if anything is broken for this ./configure option then most probably it is broken for some time already, not in this PR.
Practically our spec-file example caters for --with-sssd-user=sssd case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi,

ok, thanks.

bye,
Sumit

Copy link
Member Author

Choose a reason for hiding this comment

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

But I must admit we do not test building --with-sssd-user=root

Well, looks like Debian (for some reason) is stick to --with-sssd-user=root:
https://salsa.debian.org/sssd-team/sssd/-/blob/master/debian/rules#L48

@sumit-bose
Copy link
Contributor

/gemini review

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 refactors the ccache handling in krb5_child to improve security. The main change is the removal of sss_krb5_precheck_ccache, which eliminates the need for CAP_DAC_READ_SEARCH capability when checking ccache paths. Instead, the logic now relies on setting the real UID/GID of the process to the user's and then switching the effective UID to perform ccache operations with user privileges. This is a solid security improvement. The changes also include consolidating ccache check logic into a new k5c_ccache_check function and adjusting the call sites to perform these checks regardless of the command type, which covers more use cases. The use of sss_drop_cap instead of sss_set_cap_effective is another good security hardening measure. The code is cleaner and more secure. I have no issues to report.

Copy link
Contributor

@ikerexxe ikerexxe left a comment

Choose a reason for hiding this comment

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

Just a minor comment inline and another one in a commit message. In commit KRB5_CHILD: allow k5c_ccache_check() during SSS_PAM_PREAUTH you wrote PREUATH instead of PREAUTH

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,

thank you for the patches, I have no further comments, ACK.

bye,
Sumit

Copy link
Contributor

@ikerexxe ikerexxe left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you for the fix!

'krb5_child' doesn't precreate path to FILE:/DIR: ccache since
5e17bc2

Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
to check FILE:/DIR: ccache path.

Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
This should cover a case when a single execution of 'krb5_child'
handles both PREAUTH and AUTH

Resolves: SSSD#8331
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
Inaccessible FILE:/DIR: path is a system configuration error that
needs to be fixed anyway. It doesn't make much difference to fail
before or after credentials check in this case.

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

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-42-x86_64:upstream (success)
🟢 rpm-build:fedora-43-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 / prepare (success)
🟢 ci / system (centos-10) (success)
🟢 ci / system (fedora-42) (success)
🟢 ci / system (fedora-43) (success)
🔴 ci / system (fedora-44) (failure)
➖ 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.

@alexey-tikhonov alexey-tikhonov merged commit 735fe23 into SSSD:master Jan 13, 2026
17 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kerberos ccache filename is replaced on every concurrent login with the same user

4 participants