Skip to content

Handle invalid security config safely across managed, project, and session layers#15064

Open
evawong-oai wants to merge 8 commits intomainfrom
codex/eva-pr14818
Open

Handle invalid security config safely across managed, project, and session layers#15064
evawong-oai wants to merge 8 commits intomainfrom
codex/eva-pr14818

Conversation

@evawong-oai
Copy link

@evawong-oai evawong-oai commented Mar 18, 2026

Summary

This follow up aligns config loading across managed, project, and session sources.

For security related config, malformed inputs degrade safely by failing closed or restricting permissions, while non security config remains fail soft.

For managed config, malformed MDM security controls still fail closed while non security entries are sanitized and ignored.

For project .codex/config.toml and session flags, malformed approval_policy or sandbox_mode now fail closed, while malformed non security entries are ignored and valid entries continue to apply. The session path preserves partial overrides that depend on existing config, such as MCP enablement patches.

This PR also keeps the macOS config service tests isolated from host managed preferences.

Validation

cargo test -p codex-utils-absolute-path
cargo test -p codex-config
CARGO_TARGET_DIR=/tmp/codex-target-eva cargo test -p codex-core --lib config::service::tests::
CARGO_TARGET_DIR=/tmp/codex-target-eva cargo test -p codex-core --lib config_loader::tests::

Notes

Follow up to #14818.

Full codex-core still has unrelated js_repl sandbox failures in this local environment.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@evawong-oai
Copy link
Author

@codex review

@evawong-oai evawong-oai marked this pull request as ready for review March 18, 2026 19:25
@evawong-oai
Copy link
Author

@codex review

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a0f95b69b8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +195 to +199
fn is_invalid_security_managed_config_entry(dropped_entry: &str) -> bool {
matches!(
managed_entry_top_level_key(dropped_entry),
"approval_policy" | "sandbox_mode"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

P1 Badge Reject malformed security keys inside managed profiles

is_invalid_security_managed_config_entry only checks the top-level path segment. If sanitization drops profiles.<name>.approval_policy or profiles.<name>.sandbox_mode, the top-level key is profiles, so the code logs and continues instead of failing closed. That lets malformed profile-level managed security controls slip through, which undermines the intended fail-closed behavior.

Useful? React with 👍 / 👎.

Copy link
Author

Choose a reason for hiding this comment

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

Addressed in 064bcae60. Managed config security detection now checks the leaf field name instead of only the top level path, so dropped entries like profiles.team.approval_policy and profiles.team.sandbox_mode fail closed as intended. I also extended the managed preferences regression to cover those profile scoped cases, and CARGO_TARGET_DIR=/tmp/codex-target-eva cargo test -p codex-core --lib managed_preferences_ passes.

@evawong-oai
Copy link
Author

@codex address that feedback

@evawong-oai
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

@evawong-oai
Copy link
Author

recheck

github-actions bot added a commit that referenced this pull request Mar 18, 2026
@chatgpt-codex-connector
Copy link
Contributor

Codex couldn't complete this request. Try again later.

@evawong-oai evawong-oai changed the title Fix managed MDM requirements validation Handle invalid security config safely across managed, project, and session layers Mar 18, 2026
@evawong-oai evawong-oai changed the base branch from greg/mdm-managed-config-sanitize to main March 18, 2026 22:54
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