openai / openai/codex-security
Saved scan logs include same-thread events emitted after scan completion
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10.8k
- Forks
- 801
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 257
Description
Summary
readScanLogs() uses a saved scan's completedAt timestamp to reject independent worker sessions that start after the scan, but it does not apply the same completion boundary to events inside sessions that were already selected.
A post-scan prompt runs on the same Codex thread after complete-scan, so its later events can appear in codex-security scans logs as if they belonged to the completed security scan.
Reproduction / evidence
Current upstream main at 37bf87a692fc72d41f7312cc48808d699d204fba does this in readScanLogs():
belongsToScan()parsescompletedAtand excludes independent sessions whosestartedAt >= completedAt;- after the session set is selected, the event loop appends every event from each included session without checking
completedAt.
The SDK scan lifecycle completes/persists the scan first, then, when postScanPrompt is configured, invokes the follow-up on the same thread through runPostScan.
A deterministic saved-log fixture is therefore:
- root session starts at
12:00:00; - a scan event is timestamped
12:01:00; - saved scan
completedAtis12:02:00; - a same-thread post-scan event is timestamped
12:03:00; readScanLogs()currently returns both events.
Expected behavior: the 12:03:00 event is outside the saved scan's lifetime and should not be projected as scan activity.
Root cause
The completion boundary is enforced only while deciding which independent sessions belong to a Deep scan. It is not enforced at the per-event projection boundary for root, child, or already-selected worker sessions.
Suggested fix
Parse a finite completedAt once for log projection and omit timestamped events strictly after that instant. Preserve existing behavior for running scans (completedAt: null) and for legacy events that do not carry a usable timestamp.
Add a focused regression with before/after completion events in the same root session.
Impact
This is history/observability correctness. scans logs can mix post-scan assistant/tool activity into the evidence shown for a completed scan, making the saved activity timeline extend beyond the scan record it claims to describe.
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 at readScanLogs() and its belongsToScan() session selection, then inspect runPostScan in the complete-scan lifecycle. Add the focused same-root-session fixture with events before and after completedAt; done means post-completion events are omitted while running scans and untimestamped legacy events retain existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli, observability
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 75/100