openai / openai/codex-security
Path-target preflight accepts special files that scan setup later rejects
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10.8k
- Forks
- 801
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 257
Description
Summary
Path-target normalization checks that a selected path exists and remains inside the repository, but does not require the target to be a regular file or directory.
On POSIX, a FIFO, Unix-domain socket, or other special filesystem node can therefore pass local SDK/CLI preflight even though the bundled scan scope resolver later accepts only files and directories.
Reproduction / evidence
Current upstream main at 37bf87a692fc72d41f7312cc48808d699d204fba handles each path target in src/targets.ts by:
- checking
existsSync(candidate); - resolving it with
realpath(); - checking repository containment;
- returning the repository-relative path.
There is no file-type check.
A deterministic POSIX reproduction uses a Unix-domain socket inside a repository directory:
const server = createServer();
await listen(server, socketPath);
await normalizeTarget(repository, [socketPath]);
Current main accepts the socket as a paths target.
The bundled generate_rank_input.py scope resolver later does:
if not scope_path.is_dir() and not scope_path.is_file():
raise SystemExit(f"Scope path not found: {scope_path}")
so the same target cannot actually be scanned.
The public SDK documentation describes security.preflight() as validating local inputs without starting the runtime, which makes this mismatch observable before scan execution should begin.
Expected behavior
Path-target normalization should accept only canonical paths whose resolved target is a regular file or directory. Special filesystem nodes should fail local preflight with an InvalidTargetError.
Root cause
Existence and containment were validated, but filesystem type was not. The later bundled helper independently enforces the missing invariant.
Suggested fix
After resolving the candidate, stat() the canonical path and require isFile() || isDirectory() before returning the normalized target.
Add a POSIX regression using a Unix-domain socket inside the repository and keep ordinary file/directory path-target coverage unchanged.
Impact
This is a preflight/reliability bug. Invalid local targets can survive the SDK/CLI validation stage and fail only after the scan runtime/setup path is entered, defeating the purpose of local preflight and producing a later, less accurate scope error.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/targets.ts, then compare its path-target normalization with the bundled generate_rank_input.py scope resolver. Run the existing file and directory path-target coverage and add the POSIX Unix-domain socket regression described in the issue. Done means special files fail preflight with InvalidTargetError while ordinary files and directories remain accepted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, python, typescript
- Domain
- api, cli, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100