Skip to content

feat(cli): draft SECURITY.md for owner review - #536

Open
mldangelo-oai wants to merge 21 commits into
mainfrom
mdangelo/codex/security-policy-drafts
Open

feat(cli): draft SECURITY.md for owner review#536
mldangelo-oai wants to merge 21 commits into
mainfrom
mdangelo/codex/security-policy-drafts

Conversation

@mldangelo-oai

@mldangelo-oai mldangelo-oai commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add codex-security policy, which drafts a source-backed SECURITY.md without changing the checkout. It saves architecture, threat-model, and policy documents outside the repository and shows the exact policy diff for owner review.

This PR covers generation and preview. Stacked #489 adds saved-draft review and application.

Changes

  • Add policy [repository] (default: current directory), with --path for a component, interactive owner questions, --headless, local --dry-run, and Markdown or structured output. Existing authentication, model, knowledge-base and cost settings apply.
  • Add SDK preflight, generation and preview methods. Preserve owner questions, partial documents, cancellation and one cost budget across the three stages.
  • Keep model access read-only and scoped to the selected checkout, bound Git metadata, required plugin/Python files and optional knowledge base. Disable network, web search, apps, plugins and MCP servers. Host-written artifacts remain private and outside enclosing checkouts and Git metadata.
  • Merge main's credential and Windows ACL updates. Keep scan and policy permission profiles separate and test their distinct contracts.
  • Replace a buffered async generator with a direct array result, reuse the existing containment predicate, and shorten the policy guide. Keep public declarations independent of CLI implementation types.
  • Align test fixtures with canonical Python paths and Windows PowerShell modules. Resolve the local Administrator SID natively instead of assuming it is the current user's SID. Use the real Python read-root discovery in the native policy permission probe.

Testing

  • Merged baseline policy/configuration tests: 135 passed, 3 skipped.
  • Final affected policy, API, CLI, runtime, configuration and path suites: 439 passed, 18 skipped.
  • pnpm run types, pnpm run format, pnpm run build, and git diff --check: passed.
  • Static npm artifact check: passed, 285 entries.
  • Installed-package smoke: passed public import, NodeNext consumer types, policy help and dry-run, credential locking, 113 bundled plugin files, bundled Codex and nested-worker checks.
  • Full Bun suite with seed 12345: 1,996 passed, 33 skipped, one sandbox-blocked ps check. The exact process-group test passed outside the sandbox.

Final main refresh (01bd062): 439 affected tests passed with 18 platform skips;
the final configuration rerun passed 24 tests with two outer-sandbox skips.
Both native macOS scan/policy permission tests then passed outside the outer
sandbox. The policy probe reproduced a denied runtime launch before its fixture
was corrected; it now verifies permitted reads and denied writes with Python,
without widening the production permission profile.

Types/models, formatting, build, static package checks and full installed smoke
passed again. The bundle matches main's 0.1.60; the real 0.1.59 cache upgrade
matched all 118 files and preserved credentials. Native Windows/Linux and live
model-quality evaluation remain unverified. Unsupported native sandbox backends
are treated as unavailable, not proof of policy execution. CI is left for a second pass.

  • Final main refresh (fd98a90): package 0.1.21 includes the MCP launcher-permission fix; feature source and bundled payload are unchanged. Types/model generation, formatting, build, 28 focused tests, static artifact verification and full installed-package smoke passed, including MCP initialization. CI was not awaited.

Risk and rollout

Draft generation is opt-in and never installs a policy in the checkout. Owner approval is still required; supporting documents may contain sensitive details and need disclosure review. Policy snapshots do not freeze the rest of the source tree. Regenerate after relevant source changes.

The tests validate orchestration and local contracts with synthetic model responses, not the comparative quality or cost of three-stage generation. Existing scan defaults and the child PR's separate application lifecycle remain unchanged. No package release or PR merge is performed.

Public disclosure review

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.

Existing history includes work-email metadata, requester-only automated review links, and an older security-review discussion. They are not reproduced here; the second attestation remains unchecked. New changes use synthetic examples.

@mldangelo-oai
mldangelo-oai marked this pull request as ready for review August 18, 2026 02:12
@mldangelo-oai
mldangelo-oai requested a review from kmbroai August 18, 2026 02:12

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current head, 8c6eaccccc63c3bef68af8ed65e1ac390e51d2c1.

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 8c6eaccccc

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current head, 8c6eaccccc63c3bef68af8ed65e1ac390e51d2c1. The description now records the requester-only automated report link; the code is unchanged.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 8c6eaccccc

ℹ️ 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".

@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 Security Review

Here are some automated security review suggestions for this pull request.

Reviewed commit: 8c6eaccccc

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread sdk/typescript/src/api.ts Outdated
Base automatically changed from mdangelo/codex/shared-command-helpers to main August 18, 2026 03:40
@github-actions github-actions Bot added the enhancement New feature or request label Aug 18, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 22, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-27T08:48:17.378612Z 419e604 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current head, ffa18764bc4aa581b112c7c7899f66167d172503.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex security review

Please review the current head, ffa18764bc4aa581b112c7c7899f66167d172503.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: ffa18764bc

ℹ️ 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".

@kmbroai kmbroai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed head ffa18764bc4aa581b112c7c7899f66167d172503 for correctness, necessity, and simplification.

Is this feature necessary?

This is optional product work, not a prerequisite for scan correctness. The repository already ships a define-security-policy skill; this adds a separate three-turn orchestration, saved manifest and evidence lifecycle, owner-question UI, cost accumulation, SDK exports, and CLI output/error handling. That is a substantial permanent surface for drafting one owner-reviewed document.

My recommendation is to justify the three-stage workflow with representative output-quality/cost evidence against invoking the existing skill, and otherwise start with a narrower draft/preview entry point. Keep the architecture and threat-model documents as private supporting outputs, not new approval artifacts or mandatory user steps. Avoid exposing low-level target resolution and every orchestration concept as public API until there is a concrete consumer. Owner decisions must remain review notes, not inferred exclusions.

Correctness at this head

The earlier broad host-read finding is addressed in source. The policy profile uses :minimal plus explicit readable roots, disables plugins/apps/MCP/network, suppresses ambient project instructions, and rechecks the checkout/Git binding before starting the model work. Policy writes are performed by the host into an external private artifact directory; the generation API does not install the draft in the repository.

I also traced inherited-policy snapshots, strict UTF-8/size handling, custom-plugin selection, cancellation between stages, partial-document preservation, and cost aggregation across the three turns. I did not reproduce a new functional blocker. Source files other than the policy checkpoints are not frozen; the documentation correctly tells users to regenerate after relevant source changes. Do not describe the saved draft as a reproducible snapshot of the whole repository.

Simplification and verification

Share the existing runtime/authentication/observer machinery, but keep policy-specific orchestration outside the already large scan API where possible. Integrate the canonical-state work from #481 without creating another variant of path validation. Keep #489's repository-writing lifecycle separate from this draft-only feature so accepting generation does not implicitly accept the much riskier apply/recovery surface.

Ran the focused policy and API-policy suites: 71 passed, 0 failed, using cached dependencies. Those tests validate orchestration with synthetic model responses; they do not establish policy quality, source-citation accuracy, comparative three-stage value, or native sandbox behavior on every platform. I would narrow or defer the feature until that product justification is clear, even though the focused correctness checks passed.

@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: 07f656b6bd

ℹ️ 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".

const result = await options.run(stage, `${common}\n\n${instructions}`);
signal.throwIfAborted();
const hasDocument = result.markdown.trim().length > 0;
if (hasDocument) await writePolicyArtifact(path, result.markdown, signal);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate the policy before saving it

When the policy stage returns Markdown that exceeds the 1 MiB contract or contains an unpaired surrogate, this writes SECURITY.md before validatePolicyContent() rejects the response at line 801. The command therefore reports failure but leaves an invalid artifact behind—and invalid Unicode may already have been encoded as replacement characters—so callers can mistake the saved file for a reviewable partial result. Validate the policy-stage Markdown before calling writePolicyArtifact.

Useful? React with 👍 / 👎.

"Git metadata changed during security-policy validation. Retry with a stable checkout.",
);
}
return [...new Set([target.repository, ...binding.metadata])];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Exclude Git metadata from model-readable roots

For a linked worktree or checkout using a separate Git directory, this explicitly grants every policy turn read access to both the worktree Git directory and the common Git directory outside the selected checkout. Those directories can contain credential-bearing remote URLs and objects for deleted files, other branches, or other worktrees, so repository-controlled prompt injection can cause data outside the selected source tree to enter the inference turn. Fresh evidence beyond the earlier whole-filesystem report is that the narrowed profile still adds the common Git object/config store as a readable root; keep Git inspection host-side rather than exposing these metadata directories to the model.

AGENTS.md reference: sdk/typescript/AGENTS.md:L8-L12

Useful? React with 👍 / 👎.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants