Skip to content

fix: keep standard scoped scans out of ranking - #71

Closed
createsomethingtoday wants to merge 2 commits into
openai:mainfrom
createsomethingtoday:agent/standard-scan-scope-inventory
Closed

createsomethingtoday wants to merge 2 commits into
openai:mainfrom
createsomethingtoday:agent/standard-scan-scope-inventory

Conversation

@createsomethingtoday

@createsomethingtoday createsomethingtoday commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

What

  • replace the scoped standard-scan make-repo-rank-input bootstrap with a deterministic make-scope-inventory command
  • make the TypeScript SDK materialize that inventory before Codex starts, so setup cannot be deferred until after model spending
  • inventory every first-party regular file in the requested scopes, including tests, examples, README files, binaries, and generated files, while excluding .git, node_modules, and symlinks
  • use JSONL path records so unusual filenames remain data-safe
  • let candidate normalization consume the new inventory while retaining the legacy newline-delimited scope option for existing deep/diff workflows
  • align the standard-scan prompt, capability profile, skill, and artifact documentation with the no-ranking contract
  • when the workbench permits exactly one target kind, bind that authoritative kind during finalization and remove incompatible model-authored target coordinates

Why

The scoped-path SDK prompt instructed a standard scan to call make-repo-rank-input, even though the standard-scan skill explicitly says not to rank or filter files. That helper deliberately excludes tests, README files, binaries, and other non-source-like files.

A first report-only pilot against a 28-file authentication package spent 5.34M input tokens and reached its $5.049 cost limit while still in preflight. It produced a 20-row rank_input.jsonl, zero worklist rows, and no contract, coverage, report, or findings artifacts. The eight omitted files were the package README and its test files. This is one concrete failure mode behind the cost-without-findings behavior discussed in #25.

A second capped run using the initial version of this PR proved that changing only the prompt/helper contract was insufficient: the model could still defer the inventory step. It reached $5.078 after 9 minutes with 5.48M input tokens, no inventory, and no worklist.

An explicitly uncapped run then reached the natural terminal after 63m47s and an estimated $56.302 (71.39M input tokens, 68.94M cached, 320k output). It demonstrated the scanner's substantive value by producing a threat model, 55 candidate-ledger rows, and 48 partial finding drafts. It also exposed two deterministic integration defects:

  1. the filesystem inventory included five bootstrapped node_modules/.bin wrappers in addition to the 28 requested first-party files;
  2. finalization rejected a model-authored git_worktree kind even though the clean workbench target permitted only git_revision: scan.target.kind: must match the workbench target.

This revision fixes both defects. The uncapped findings remain partial/unsealed and application remediation is intentionally outside this PR.

Validation

  • pnpm run format
  • pnpm run types
  • pnpm test (378 passed, 3 skipped, 0 failed)
  • pnpm run build
  • pnpm pack --pack-destination ../../dist
  • pnpm run check:package ../../dist/openai-codex-security-0.1.1.tgz (179 entries; public import, CLI, and 95 bundled plugin files validated)
  • pnpm run test:package

Regression coverage proves that:

  • the SDK writes the complete standard inventory before the Codex turn starts;
  • README, binary, source, and test files remain in scope while .git, node_modules, and symlinks do not;
  • candidates located in test files are accepted by normalization; and
  • a sole workbench-allowed target kind replaces an incompatible model-authored draft during finalization.

@createsomethingtoday
createsomethingtoday marked this pull request as ready for review July 29, 2026 17:16
@createsomethingtoday

Copy link
Copy Markdown
Contributor Author

Post-fix recovery validation completed without another model turn. I preserved the failed original scan, registered a parent-linked recovery scan at the same repository revision and scope, copied the unsealed artifacts, and completed it through this branch. The corrected workbench sealed the contract successfully: validate_scan_contract.py reports status: valid; the workbench reports complete, 48 findings with derived IDs, and both Markdown and SARIF reports. A relative content digest confirmed the original artifact set and its preservation copy are identical. Separately, the corrected inventory helper emits exactly the 28 tracked scoped files and matches git ls-files with no node_modules or .git rows. The sealed coverage remains truthfully partial with four deferred questions, so this validates the integration/finalization fixes rather than claiming a complete security review.

@createsomethingtoday

Copy link
Copy Markdown
Contributor Author

Fresh natural-terminal validation now confirms this branch on the ordinary live path, not only recovery. A standard scoped scan against a separate 36-row authorization-package inventory completed after 32m44s. The model-authored unsealed manifest again used git_worktree; the workbench allowed only git_revision; this branch replaced the kind and incompatible snapshot coordinate, sealed successfully, generated Markdown/SARIF, and validate_scan_contract.py reports status: valid. Workbench readback is complete with complete coverage and 8 findings. The deterministic inventory was present before the Codex turn. Target revision remained clean and package TypeScript plus all 24 tests passed afterward. This directly validates both the pre-model inventory setup and singleton target-kind binding fixes in a new scan.

mldangelo-oai added a commit that referenced this pull request Jul 29, 2026
Preserve and harden the scoped-inventory design from external PR #71. Keep standard workflow instructions, explicitly selected dependency scopes, both attested inventories, and authoritative target finalization consistent with the released 0.1.3 base.

Co-authored-by: Create Something <[email protected]>
@createsomethingtoday

Copy link
Copy Markdown
Contributor Author

The extended exact-commit validation run reached completion after 56 minutes and surfaced two source-validated findings in the target project, but final save failed because immutable diff targets did not carry the required snapshotDigest. I opened focused follow-up PR #112 with a regression and the completion binding fix. The partial findings were retained and are being remediated before a fresh sealed run.

@mldangelo-oai mldangelo-oai added the bug Something isn't working label Aug 3, 2026
mldangelo-oai added a commit that referenced this pull request Aug 10, 2026
* fix: make standard scan inventory authoritative

* test: verify scan inventories across Windows line endings

* fix: close authoritative scan inventory gaps

Preserve and harden the scoped-inventory design from external PR #71. Keep standard workflow instructions, explicitly selected dependency scopes, both attested inventories, and authoritative target finalization consistent with the released 0.1.3 base.

Co-authored-by: Create Something <[email protected]>

* fix: isolate authoritative inventory outside writable scan roots

Address the fresh exact-head review findings without relying on recoverable snapshot hashes or fragile CLI configuration overrides. Keep the private inventory physically outside configured state, output, and repository roots; fail closed if no safe location exists; and honor manually selected dependency scopes.

Co-authored-by: Create Something <[email protected]>

* fix: enforce authoritative standard scan coverage

Verify exhaustive sealed per-file review, candidate scope, and completion against the protected host inventory. Make the fail-closed protected-root regression deterministic across Windows drive layouts.

Co-authored-by: Create Something <[email protected]>

* test: keep authoritative inventory regressions portable

Use the current workbench registration contract and a deterministic unavailable inventory-root fixture on every operating system, including native Windows.

Co-authored-by: Create Something <[email protected]>

* fix: complete authoritative scan verification

Reconcile candidate outcomes and sealed findings, validate full phase closures and empty scopes, enforce bounded inventory traversal, and execute verification from the isolated plugin copy.

Co-authored-by: Create Something <[email protected]>

* fix: preserve bounded review and diff target contracts

Allow independently bounded exhaustive review receipts, bind the authoritative digest for all Git diff modes, and preserve valid POSIX colon filenames without relaxing Windows path safety. Add failing-first regressions against the real inventory verifier and workbench finalizer.

Co-authored-by: Create Something <[email protected]>

* fix: seal authoritative scan verifier and candidate payloads

Stage the isolated Python verifier outside all model-writable roots before starting a scan. Bind reportable finding CWE, precise locations, severity, confidence, validation evidence, and attack-path closure to the authoritative candidate. Reject coverage surfaces that finalization cannot seal and document the exact durable-artifact mapping.

Co-authored-by: Create Something <[email protected]>

* fix: reverify finalized authoritative scan coverage

Verify sealed candidate and review artifacts again immediately after workbench recovery and before publishing completion. Materialize the actual installed plugin in the injection-resistant prompt fixture so the isolated verifier passes unchanged on Windows, macOS, and Linux.

Co-authored-by: Create Something <[email protected]>

* fix: preserve honest deferred inventory coverage

Validate host-attested inventory paths lexically so disappeared files remain durable deferred coverage, require the associated receipt surface to signal follow-up, and normalize supported list-valued change conditions into the canonical finding schema. Prove each edge case with failing-first real-helper regressions.

Co-authored-by: Create Something <[email protected]>

* fix: seal complete standard scan provenance

Seal the exact attested inventory and normalized candidate ledger alongside exhaustive review receipts. Preserve independently reportable child instances, canonical severity fields, escaped-path security, and deferred files after deletion; independently verify every protected input and final finding.

Co-authored-by: Create Something <[email protected]>

* fix: protect scan verifier interpreter and proof gaps

Reject a Python verifier inside model-writable scan state before starting Codex, bind deferred coverage to its exact validated proof gap, and regression-test protected interpreter, complete sealed provenance, independent child findings, and finalizer recovery.

Co-authored-by: Create Something <[email protected]>

* fix: verify every standard scan completion

Verify prompt-only scans before sealing, reconcile every source and shared sink across split findings, and regression-test both manual completion and scoped attack paths against current main.

Co-authored-by: Create Something <[email protected]>

* fix: reject writable Python verifier aliases

Reject both direct writable interpreter symlinks and symlinked state parents before starting a standard scan, while retaining trusted system Python and cross-platform test doubles.

Co-authored-by: Create Something <[email protected]>

* fix: seal complete standard scan provenance

Bind all authoritative scope receipts to one coverage surface, enforce one validated deferred proof gap per candidate, and regression-test contradictory, malformed, and falsely complete coverage.

Co-authored-by: Create Something <[email protected]>

* fix: reconcile native scan paths and deferred coverage

Preserve literal POSIX repository filenames across normalization, finalization, SARIF, and SDK contracts without weakening Windows or artifact paths; require every deferred row to resolve to an actually deferred candidate.

Co-authored-by: Create Something <[email protected]>

* fix: bind standard scan exclusions to coverage

Declare omitted Git metadata and installed dependency trees in the exact workbench, canonical coverage, and manual scan scope without hiding directly selected dependencies.

Co-authored-by: Create Something <[email protected]>

* fix: preserve overlapping scan scope coverage

Carve explicitly requested dependencies out of broader inventory exclusions, attest omitted sibling and transitive trees, and verify downstream workbench coverage against real overlapping scopes.

Co-authored-by: Create Something <[email protected]>

* fix: persist authoritative standard scan exclusions

Snapshot host-owned scan exclusions at registration, declare every omitted symbolic link, and preserve coverage when requested paths disappear. Validate upgrade compatibility and fail closed on tampered exclusion state.

Co-authored-by: Create Something <[email protected]>

* fix: attest standard scan exclusions and bound source reads

* test: cover complete registered inventory exclusions

* test: accept Windows inventory line endings

* fix: attest standard scan exclusions and bounded inventories

* test: terminate synthetic login process after emitting its result

* fix: authenticate complete registered scan exclusions

* fix: verify authoritative coverage before app scan completion

* test: synchronously flush synthetic ChatGPT login prompts

* fix: attest standard scan scope and recovered inventory

* refactor: deduplicate secure scope inventory handling

* fix: attest inventory contents and captured exclusions

* fix: bound inventory verification and escape scope exclusions

* fix: bound inventory hashing and reject special files

* Reject symlink scopes before processing parent traversal

* Keep tracked scoped files and reject Windows junctions

* fix(scan): exclude dependencies and binaries from broad scopes

* Preserve complete scoped inventories while rejecting redirecting links

* Reject every redirecting Windows reparse point

---------

Co-authored-by: Create Something <[email protected]>

Copy link
Copy Markdown
Contributor Author

Superseded by #88, which preserved and hardened the scoped-inventory design and validation evidence from this PR. #88 merged as d7a2bfbbfb93ce5c3e72861f214d340cff5a2595, retains CREATE SOMETHING co-author attribution, and shipped in Codex Security 0.1.9; the contribution remains in the current release line. Current main now uses the replacement make-repo-scope-input workflow with authoritative workbench target values, so rebasing this older implementation would duplicate or regress the shipped architecture. Closing while preserving this PR’s original real-scan reproductions and validation evidence.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants