Skip to content

fix: do not allow dotenv to create/modify environment variables starting with CODEX_ - #2308

Merged
bolinfest merged 1 commit into
mainfrom
pr2308
Aug 14, 2025
Merged

bolinfest merged 1 commit into
mainfrom
pr2308

Conversation

@bolinfest

@bolinfest bolinfest commented Aug 14, 2025 •

Copy link
Copy Markdown
Collaborator

This ensures Codex cannot drop a .env file with a value of CODEX_HOME that points to a folder that Codex can control.

@bolinfest
bolinfest requested a review from khai-oai August 14, 2025 19:07
Comment thread codex-rs/arg0/src/lib.rs Outdated
})
}

const ILLEGAL_ENV_VAR_PREFIX: &str = "CONST_";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should this be CODEX_?

Comment thread codex-rs/arg0/src/lib.rs Outdated
I: IntoIterator<Item = Result<(String, String), dotenvy::Error>>,
{
for (key, value) in iter.into_iter().flatten() {
if !key.starts_with(ILLEGAL_ENV_VAR_PREFIX) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should normalize case sensitivity, e.g convert them to uppercase before comparing

@bolinfest

Copy link
Copy Markdown
Collaborator Author
  • fixed value of ILLEGAL_ENV_VAR_PREFIX
  • added to_ascii_uppercase() as part of the comparison
  • moved set_filtered() to a top-level function

@bolinfest
bolinfest requested a review from khai-oai August 14, 2025 19:22

@khai-oai khai-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

tysm!

@bolinfest
bolinfest merged commit c25f3ea into main Aug 14, 2025
@bolinfest
bolinfest deleted the pr2308 branch August 14, 2025 20:57
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants