Skip to content

fix(security): restrict public environment export - #4166

Merged
kwakayama merged 14 commits into
mainfrom
codex/propose-fix-for-env-export-vulnerability
Aug 26, 2026
Merged

fix(security): restrict public environment export#4166
kwakayama merged 14 commits into
mainfrom
codex/propose-fix-for-env-export-vulnerability

Conversation

@kojiwakayama

Copy link
Copy Markdown
Contributor

Motivation

  • A public package export and import-map entry exposed src/platform/compat/process/env.ts, which exports privileged helpers (getHostEnv, env) that bypass project env isolation.
  • Tenant project code could use the public specifier to read host-only secrets, violating the shared-host threat model.
  • The Redis extension only needs the project-scoped reader getEnv(), so the public surface can be narrowed without breaking functionality.

Description

  • Added a narrow public facade src/platform/env.ts that re-exports only the project-scoped getEnv() function.
  • Updated the package exports and workspace imports in deno.json so ./platform/env and veryfront/platform/env point to ./src/platform/env.ts instead of the privileged implementation.
  • Updated extensions/ext-redis/deno.json to resolve veryfront/platform/env to the new safe facade so extensions keep using getEnv() without gaining access to host-only helpers.
  • Added src/platform/env.test.ts to assert the public module exports only getEnv() as a regression test.

Testing

  • Ran a Node-based import check with node --experimental-strip-types --input-type=module -e 'const module = await import("./src/platform/env.ts"); if (JSON.stringify(Object.keys(module)) !== JSON.stringify(["getEnv"])) throw new Error(...)', which succeeded and confirmed only getEnv is exported.
  • Ran git diff --check to validate whitespace/format issues, which reported no problems.
  • Attempted Deno tests (deno test) for the new test and extension tests, but deno is not available in the environment so those automated checks could not be executed here; running deno test --no-check --allow-all in a Deno-capable CI or developer environment is recommended to fully verify the test suite.

Codex Task

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kojiwakayama has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 13 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 500f4406-ead8-4292-ac19-8214ee254566

📥 Commits

Reviewing files that changed from the base of the PR and between 11ae95f and cb566b1.

📒 Files selected for processing (52)
  • cli/commands/serve/proxy-extension-composition.ts
  • cli/commands/serve/proxy-runtime.ts
  • deno.json
  • docs/api-reference/veryfront/index.client.md
  • docs/api-reference/veryfront/index.md
  • docs/api-reference/veryfront/observability.md
  • docs/api-reference/veryfront/platform.md
  • docs/api-reference/veryfront/server.md
  • docs/api-reference/veryfront/testing.md
  • docs/architecture/20-support-matrix.md
  • extensions/ext-eval-report-mlflow/deno.json
  • extensions/ext-redis/deno.json
  • scripts/build/npm-package-metadata.test.ts
  • src/observability/index.test.ts
  • src/observability/index.ts
  • src/platform/compat/framework-source-resolver.test.ts
  • src/platform/compat/framework-source-resolver.ts
  • src/platform/compat/process.test.ts
  • src/platform/compat/process/env-public.ts
  • src/platform/compat/process/env.test.ts
  • src/platform/compat/process/env.ts
  • src/platform/compat/process/scoped-process-env.ts
  • src/platform/env.test.ts
  • src/platform/env.ts
  • src/proxy/tracing.ts
  • src/security/README.md
  • src/security/host-execution-policy.test.ts
  • src/security/host-execution-policy.ts
  • src/security/project-locality.test.ts
  • src/security/project-locality.ts
  • src/security/sandbox/isolation-posture.test.ts
  • src/security/sandbox/worker-pool.test.ts
  • src/security/sandbox/worker-pool.ts
  • src/server/handlers/preview/markdown-preview.handler.test.ts
  • src/server/handlers/request/api/api-handler-wrapper.test.ts
  • src/server/handlers/request/api/app-router-handler.test.ts
  • src/server/handlers/request/api/project-discovery.test.ts
  • src/server/handlers/request/api/project-discovery.ts
  • src/server/handlers/request/snippet.handler.test.ts
  • src/server/handlers/request/ssr/ssr.handler.test.ts
  • src/server/production-server.ts
  • src/server/project-env/process-env-scope.test.ts
  • src/server/startup-discovery.test.ts
  • src/server/startup-discovery.ts
  • src/testing/bdd.ts
  • src/transforms/mdx/esm-module-loader/module-fetcher/index.test.ts
  • src/transforms/mdx/esm-module-loader/module-fetcher/index.ts
  • src/transforms/pipeline/stages/ssr-vf-modules.test.ts
  • src/transforms/pipeline/stages/ssr-vf-modules/index.ts
  • src/transforms/pipeline/stages/ssr-vf-modules/path-resolver.test.ts
  • src/transforms/pipeline/stages/ssr-vf-modules/path-resolver.ts
  • tsconfig.json

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kwakayama
kwakayama enabled auto-merge August 25, 2026 15:24
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown

📦 Client bundle boundary

Entrypoint Modules Source size Server leaks
src/index.client.ts 285 1784 KiB ✅ 0

A server module in a client graph aborts hydration in the browser. New leaks fail CI; known leaks are tracked in scripts/lint/client-bundle-baseline.json to burn down.

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

Copy link
Copy Markdown

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: f4d6303139

ℹ️ 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 thread src/platform/env.ts
Comment thread src/platform/env.ts
Comment thread deno.json
@kwakayama kwakayama added the needs-human-input Maintainer action required label Aug 25, 2026
@kwakayama

Copy link
Copy Markdown
Contributor

The proposed public facade does not close the security boundary: tenant module rewriting still accepts direct #veryfront internal imports, and veryfront/testing exposes host env mutators. Fixing this safely requires a tenant-vs-framework module provenance boundary rather than another export-list patch.

- Point the public veryfront/platform/env subpath (and extension deno.json mappings) at a facade that re-exports only project-scoped readers: getEnv, getEnvString, getEnvNumber, getEnvBoolean, EnvBooleanOptions
- Contain setEnv/deleteEnv to the active project env snapshot so the public testing surface cannot mutate the shared host process environment
- Refuse tenant module loading of privileged framework source (platform/compat/process*) in the SSR vf-modules resolver and the ESM module fetcher, while framework-internal transitive resolution stays intact
- Move CLI serve internals to the veryfront/platform barrel for setEnv
- Add regression tests for the facade surface, scoped mutators, and privileged-module refusal
@kojiwakayama
kojiwakayama force-pushed the codex/propose-fix-for-env-export-vulnerability branch from f4d6303 to 0c9fa63 Compare August 25, 2026 18:18

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kojiwakayama has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

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

Copy link
Copy Markdown

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: 0c9fa637ec

ℹ️ 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 thread src/platform/compat/framework-source-resolver.ts Outdated
The scoped setEnv/deleteEnv containment shifted declaration lines in
src/platform/compat/process/env.ts. Regenerate the affected source
links in the veryfront, veryfront/index.client, and veryfront/testing
API reference pages so the api-reference check stays green.

Claude-Session: https://claude.ai/code/session_012VprCnNBzAi9PRvzhjYNcb

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kojiwakayama has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

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

Copy link
Copy Markdown

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: a214b76da7

ℹ️ 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 thread src/platform/compat/framework-source-resolver.ts Outdated

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kojiwakayama has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

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

Copy link
Copy Markdown

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: b673cd92ba

ℹ️ 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 thread src/platform/compat/framework-source-resolver.ts Outdated
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kojiwakayama has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

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

Copy link
Copy Markdown

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: d3655f7868

ℹ️ 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 thread src/platform/compat/process/env.ts
Comment thread src/platform/compat/process/env.ts Outdated

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kojiwakayama has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kojiwakayama has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@github-actions

Copy link
Copy Markdown

@codex review

Comment thread deno.json

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

Copy link
Copy Markdown

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: f1a38442f1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/security/project-locality.ts Outdated

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kojiwakayama has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@github-actions

Copy link
Copy Markdown

@codex review

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

Copy link
Copy Markdown

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: 46c22a92e0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/platform/compat/framework-source-resolver.ts
Comment thread src/platform/compat/framework-source-resolver.ts Outdated

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kojiwakayama has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@github-actions

Copy link
Copy Markdown

@codex review

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

Copy link
Copy Markdown

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: 169a7d8cd1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/security/project-locality.ts

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kojiwakayama has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@github-actions

Copy link
Copy Markdown

@codex review

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

Copy link
Copy Markdown

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: eaec412a1c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/security/project-locality.ts
Comment thread src/platform/compat/process/scoped-process-env.ts

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kojiwakayama has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@github-actions

Copy link
Copy Markdown

@codex review

@gitar-bot

gitar-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 resolved / 1 findings

Restricts public environment export to project-scoped helpers only, addressing the orphaned env-public.ts finding. No issues found.

✅ 1 resolved
Quality: Orphaned env-public.ts still exports privileged helpers

📄 deno.json:176 📄 deno.json:247 📄 tsconfig.json:89
This PR repoints every reference (deno.json exports/imports, tsconfig paths, ext-redis/ext-eval-report-mlflow, npm-package-metadata.test) away from src/platform/compat/process/env-public.ts to the new src/platform/env.ts facade, but leaves env-public.ts on disk. It is now completely unreferenced yet still re-exports the privileged/mutating accessors (env, getHostEnv, setEnv, deleteEnv) that this change exists to withhold from tenants. Delete the dead file so it cannot be accidentally re-added to a public export/import map and silently re-open the surface the PR is closing.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqubecloud

Copy link
Copy Markdown

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: cb566b1e82

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@kwakayama
kwakayama added this pull request to the merge queue Aug 26, 2026
Merged via the queue into main with commit d4c0ddb Aug 26, 2026
61 checks passed
@kwakayama
kwakayama deleted the codex/propose-fix-for-env-export-vulnerability branch August 26, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark needs-human-input Maintainer action required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants