Skip to content

fix: add allow-list for global config keys from Docker labels#487

Merged
CybotTM merged 4 commits intomainfrom
fix/global-label-allowlist
Feb 18, 2026
Merged

fix: add allow-list for global config keys from Docker labels#487
CybotTM merged 4 commits intomainfrom
fix/global-label-allowlist

Conversation

@CybotTM
Copy link
Member

@CybotTM CybotTM commented Feb 18, 2026

Summary

  • Adds a globalLabelAllowList in cli/docker-labels.go that defines which global config keys may be set via Docker labels on service containers
  • Blocks security-sensitive keys (allow-host-jobs-from-labels, web auth settings, pprof, default-user) from being overridden via labels — they can only be set via config file
  • Blocked keys emit a SECURITY: Blocked global config key ... warning log
  • Adds 3 test cases: blocked keys filtered, allowed keys pass through, full attack scenario (label cannot enable host job execution)

Security Context

Any container with ofelia.service=true could override any global config field via Docker labels, including allow-host-jobs-from-labels (enabling host code execution) and web authentication settings. This PR closes that privilege escalation vector with a secure-by-default allow-list.

See detailed analysis in #486.

Test Plan

  • TestGlobalLabelAllowListBlocksSecurityKeys — verifies 7 security-sensitive keys are blocked
  • TestGlobalLabelAllowListPermitsSafeKeys — verifies 5 safe keys pass through
  • TestGlobalLabelAllowListPreventsHostJobEscalation — full attack scenario end-to-end
  • Full test suite passes (go test ./...)
  • golangci-lint clean, go vet clean

Closes #486

Prevent Docker labels on service containers from overriding
security-sensitive global config fields like allow-host-jobs-from-labels,
web authentication settings, pprof, and default-user.

Only explicitly allow-listed keys (notifications, logging, scheduling)
can be set via labels. Blocked keys emit a security warning.

Closes #486
Add tests for:
- Blocked security-sensitive keys (host jobs, web auth, pprof, default-user)
- Allowed safe keys (notifications, logging, scheduling)
- Full attack scenario: label cannot enable host job execution
Copilot AI review requested due to automatic review settings February 18, 2026 15:54
@gemini-code-assist
Copy link

Summary of Changes

Hello @CybotTM, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the security posture by introducing an allow-list mechanism for global configuration keys derived from Docker labels. It prevents malicious or misconfigured containers from overriding critical security settings, thereby closing a privilege escalation vector and ensuring that sensitive configurations can only be managed through the main configuration file.

Highlights

  • Security Enhancement: Introduced a globalLabelAllowList in cli/docker-labels.go to explicitly define which global configuration keys can be set via Docker labels.
  • Privilege Escalation Prevention: Implemented logic to block security-sensitive global configuration keys (e.g., allow-host-jobs-from-labels, web authentication settings) from being overridden by Docker labels, preventing potential privilege escalation.
  • Warning Logs: Added warning logs for any attempts to set blocked global config keys via Docker labels, providing visibility into potential security issues.
  • Comprehensive Testing: Included comprehensive test cases to verify that security-sensitive keys are blocked, safe keys are permitted, and host job escalation is prevented.
Changelog
  • cli/docker-labels.go
    • Defined globalLabelAllowList to specify allowed global config keys from Docker labels.
    • Modified the buildFromDockerContainers method to filter global config keys based on the new allow-list, logging warnings for blocked keys.
  • cli/docker_labels_test.go
    • Added TestGlobalLabelAllowListBlocksSecurityKeys to confirm security-sensitive keys are not applied.
    • Added TestGlobalLabelAllowListPermitsSafeKeys to verify non-sensitive keys are correctly processed.
    • Added TestGlobalLabelAllowListPreventsHostJobEscalation to test the prevention of host job execution via labels.
Activity
  • Verified that 7 security-sensitive keys are blocked as intended.
  • Confirmed that 5 safe keys are correctly passed through.
  • Validated the prevention of a full attack scenario involving host job escalation.
  • Ensured the entire test suite passes without errors.
  • Confirmed that golangci-lint and go vet report no issues.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

github-actions bot commented Feb 18, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

github-actions[bot]
github-actions bot previously approved these changes Feb 18, 2026
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Automated approval for solo maintainer project

All CI checks passed. See SECURITY.md for compensating controls.

@github-actions
Copy link

✅ Mutation Testing Results

Mutation Score: 100.00% (threshold: 60%)

✨ Good job! Mutation score meets the threshold.

What is mutation testing?

Mutation testing measures test quality by introducing small changes (mutations) to the code and checking if tests detect them. A higher score means better test effectiveness.

  • Killed mutants: Tests caught the mutation (good!)
  • Survived mutants: Tests missed the mutation (needs improvement)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements a security fix to prevent privilege escalation via Docker labels by introducing an allow-list for global configuration keys that can be set by service containers. The fix addresses issue #486 where malicious containers with ofelia.service=true could override security-critical settings like allow-host-jobs-from-labels to enable arbitrary command execution on the host.

Changes:

  • Adds globalLabelAllowList map in cli/docker-labels.go defining which global config keys may be set via Docker labels
  • Implements filtering logic that blocks non-allowed keys and logs security warnings
  • Adds comprehensive test coverage for blocked/allowed keys and end-to-end attack prevention

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
cli/docker-labels.go Adds globalLabelAllowList map with 23 allowed keys and filtering logic to block security-sensitive keys from being set via Docker labels
cli/docker_labels_test.go Adds three test cases validating blocked keys, allowed keys, and end-to-end host job escalation prevention

Address findings from 3 independent code reviews (Codex, Gemini Security,
Gemini Full):

- Remove save-folder, allow-remote-presets, trusted-preset-sources, and
  preset-cache-dir from the allow-list (arbitrary file write and remote
  config injection vectors)
- Add bounds check for parts[1] to prevent panic on malformed labels
  with no dots (pre-existing DoS vector)
- Include container name in security warning log for incident attribution
- Update tests to cover newly blocked keys
github-actions[bot]
github-actions bot previously approved these changes Feb 18, 2026
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Automated approval for solo maintainer project

All CI checks passed. See SECURITY.md for compensating controls.

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 18, 2026

Merging this PR will degrade performance by 40.19%

❌ 3 regressed benchmarks
✅ 23 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
BenchmarkExecutionMemoryWithoutPool 7 ms 11.7 ms -40.19%
remove 31.3 µs 42.4 µs -26.36%
BenchmarkRateLimiter 99.4 µs 113.1 µs -12.16%

Comparing fix/global-label-allowlist (c0d1704) with main (95f8485)

Open in CodSpeed

Address Copilot review feedback:
- Remove webhook-allowed-hosts from allow-list (SSRF risk)
- Add comment explaining why webhook security keys are blocked
- Expand blocked-keys test to cover all 16 security-sensitive keys
  (web-address, web-username, web-token-expiry, web-max-login-attempts,
  pprof-address, webhook-allowed-hosts)
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Automated approval for solo maintainer project

All CI checks passed. See SECURITY.md for compensating controls.

@CybotTM CybotTM added this pull request to the merge queue Feb 18, 2026
Merged via the queue into main with commit 652f9b3 Feb 18, 2026
30 of 31 checks passed
@CybotTM CybotTM deleted the fix/global-label-allowlist branch February 18, 2026 16:25
@github-actions github-actions bot added the released:v0.21.0 Included in v0.21.0 release label Mar 7, 2026
@github-actions
Copy link

github-actions bot commented Mar 7, 2026

🚀 Released in v0.21.0

Thank you for your contribution! 🙏

This is now available in the latest release. Please test and verify everything works as expected in your environment.

If you encounter any issues, please open a new issue.

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

Labels

released:v0.21.0 Included in v0.21.0 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security: service containers can override global config via Docker labels

2 participants