fix(policy): require all brace-expanded allow paths#39
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e1583a1480
ℹ️ 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".
| reason: Some(format!("path {path} not in allow list")), | ||
| matched_rule: Some("allow.paths (miss)".into()), | ||
| }; | ||
| for expanded_path in crate::common::shell::brace_expand(path, 64) { |
There was a problem hiding this comment.
Treat truncated brace expansions as an allow-list miss
In lockdown policies, this only checks the first 64 strings returned by brace_expand(path, 64), and src/common/shell.rs shows that helper silently stops once the cap is reached. A crafted brace list with 64 allowed alternatives followed by /tmp/secret is still expanded by the shell at runtime, but the new allow-list loop never sees the 65th path and can return Allow, leaving the same bypass shape available with a larger brace list. The check should fail closed when expansion is truncated or otherwise ensure every runtime expansion is accounted for.
Useful? React with 👍 / 👎.
e1583a1 to
b99e3c1
Compare
Motivation
{/repo/src/main.rs,/tmp/secret}) bypass adefault = "block"allow-list; allow rules must instead require that every runtime-expanded path is allowed.Description
matches_allow_pathcall a newmatches_path_env_all_expansionshelper so allow semantics require universal coverage across brace expansions instead of existential matching of any expansion. (matches_allow_path,matches_path_env_all_expansions,matches_path_resolved_all_expansions,path_expansions_match_anyinsrc/policy/matcher.rs).matches_path_resolvedsemantics unchanged for deny rules.src/policy/mod.rs).src/policy/matcher.rsandsrc/policy/mod.rs).Testing
cargo testand all tests passed (255 passed; 0 failed).cargo test allow_list_checks_each_brace_expanded_runtime_path,cargo test allow_list_accepts_brace_expansions_covered_by_different_rules, andcargo test deny_brace_expansion_matches_any_target_but_allow_requires_all, and each passed.git diff --check(no issues) and notedcargo fmt --checkreported repository-wide formatting differences unrelated to this minimal security fix, so formatting changes were not applied to avoid noisy unrelated edits.Codex Task