Skip to content

Fix allow privilege escalation#49

Merged
mjiao merged 3 commits into
redhat-sap:masterfrom
mjiao:fix-AllowPrivilegeEscalation
Jan 27, 2026
Merged

Fix allow privilege escalation#49
mjiao merged 3 commits into
redhat-sap:masterfrom
mjiao:fix-AllowPrivilegeEscalation

Conversation

@mjiao
Copy link
Copy Markdown
Collaborator

@mjiao mjiao commented Jan 24, 2026

No description provided.

mjiao added 3 commits January 23, 2026 18:03
When upgrading from older SDI versions, the pos file at
/var/tmp/diagnostics-fluentd-sdi.log.pos may have been created by a
container running as a different UID (e.g., 999). The new version
runs as a different UID (e.g., 100 or 1000), causing permission denied
errors.

This fix adds an init container that runs chmod 666 on the pos file
before the main fluentd container starts, making it writable by any
UID. The init container:
- Runs as root with privileged security context and spc_t SELinux type
- Only modifies permissions if the file exists
- Uses minimal resources (10m CPU, 10Mi memory)

Also refactors the security context patching into helper functions:
- patchPodSecurityContext: handles pod-level security context
- patchContainerSecurityContext: handles container-level security context
- ensureFluentdInitContainer: injects the permission fix init container

The code now removes runAsUser: 0 if previously set, letting containers
run as their intended UID while still having the init container fix
permissions beforehand.
SDI 3.3.290 changed the vartmp volume from hostPath to emptyDir,
which eliminates the permission issues that required our security
patches. Running in privileged mode with spc_t SELinux on the new
version actually causes the fluentd 'have_capability?' error.

This change:
- Adds isVartmpHostPath() to detect volume type
- Adds cleanupFluentdPatches() to revert our patches when emptyDir is detected
- Only applies security patches (privileged, spc_t, init container) for hostPath
- Automatically cleans up patches during upgrade from 3.3.265 to 3.3.290

Behavior by volume type:
- hostPath (SDI 3.3.265): Apply privileged mode, init container for chmod 666
- emptyDir (SDI 3.3.290+): Remove patches, let container run as non-privileged
The updateExistingRouteCA function was detecting certificate changes
but never calling Client.Update() to persist the change to the cluster.
This meant that after an SDI upgrade, even if the ca-bundle.pem secret
changed, the route's DestinationCACertificate was never updated.

Changes:
- Add Client.Update() call when certificate differs
- Add info log when certificate is updated
- Change "unchanged" log to V(1) debug level
- Wrap update error with context
@mjiao mjiao force-pushed the fix-AllowPrivilegeEscalation branch from 0026a6e to c5c19fd Compare January 24, 2026 12:55
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0% with 139 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@790b8d6). Learn more about missing BASE report.

Files with missing lines Patch % Lines
observer-operator/pkg/adjuster/sdiconfig.go 0.00% 135 Missing ⚠️
observer-operator/pkg/adjuster/network.go 0.00% 4 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff            @@
##             master      #49   +/-   ##
=========================================
  Coverage          ?   13.08%           
=========================================
  Files             ?       10           
  Lines             ?     1032           
  Branches          ?        0           
=========================================
  Hits              ?      135           
  Misses            ?      884           
  Partials          ?       13           
Flag Coverage Δ
observer-operator 13.08% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mjiao mjiao merged commit 773cbfc into redhat-sap:master Jan 27, 2026
3 checks passed
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.

2 participants